Added LoadDefaultSchema to platform testing utils to make test setup easier. (#38706)

<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #38234

Minor developer experience improvement for tests using MySQL.
This is a code review follow up.
This commit is contained in:
Victor Lyuboslavsky
2026-01-26 16:02:12 -06:00
committed by GitHub
parent 89fb977695
commit 089cf9a3ba
3 changed files with 11 additions and 11 deletions
@@ -5,6 +5,7 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"
@@ -107,6 +108,14 @@ type DatastoreTestOptions struct {
UniqueTestName string
}
// LoadDefaultSchema loads the default database schema for testing.
func LoadDefaultSchema(t testing.TB, testName string, opts *DatastoreTestOptions) {
_, thisFile, _, _ := runtime.Caller(0)
schemaPath := filepath.Join(filepath.Dir(thisFile), "../../../datastore/mysql/schema.sql")
LoadSchema(t, testName, opts, schemaPath)
}
// LoadSchema loads a database schema from the specified path for testing.
func LoadSchema(t testing.TB, testName string, opts *DatastoreTestOptions, schemaPath string) {
schema, err := os.ReadFile(schemaPath)
if err != nil {