2026-04-30 02:30:32 +08:00

32 lines
830 B
Go

// Package mysqlschema binds the shared MySQL schema helper to user-service initdb.
package mysqlschema
import (
"testing"
sharedmysqlschema "hyapp/internal/testutil/mysqlschema"
)
// Schema owns one temporary user-service database initialized from production DDL.
type Schema = sharedmysqlschema.Schema
// New creates an isolated user-service schema from USER_SERVICE_MYSQL_TEST_DSN.
func New(t testing.TB) *Schema {
t.Helper()
return sharedmysqlschema.New(t, sharedmysqlschema.Config{
EnvVar: "USER_SERVICE_MYSQL_TEST_DSN",
InitDBPath: initDBPath(t),
DatabasePrefix: "hyapp_user_test",
})
}
func initDBPath(t testing.TB) string {
t.Helper()
return sharedmysqlschema.InitDBPath(t,
sharedmysqlschema.CallerFile(t, 1),
"..", "..", "..", "deploy", "mysql", "initdb", "001_user_service.sql",
)
}