From a51815740b210dd1bc6749f71e286e15119dd147 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Mon, 2 Dec 2024 10:42:28 +0530 Subject: [PATCH] added global test Signed-off-by: Harshit Gangal --- .../{vschemas/schema.sql => schemas/sschema.sql} | 0 .../planbuilder/testdata/schemas/uschema.sql | 0 go/vt/vtgate/vindexes/vschema_test.go | 15 +++++++++++++++ 3 files changed, 15 insertions(+) rename go/vt/vtgate/planbuilder/testdata/{vschemas/schema.sql => schemas/sschema.sql} (100%) create mode 100644 go/vt/vtgate/planbuilder/testdata/schemas/uschema.sql diff --git a/go/vt/vtgate/planbuilder/testdata/vschemas/schema.sql b/go/vt/vtgate/planbuilder/testdata/schemas/sschema.sql similarity index 100% rename from go/vt/vtgate/planbuilder/testdata/vschemas/schema.sql rename to go/vt/vtgate/planbuilder/testdata/schemas/sschema.sql diff --git a/go/vt/vtgate/planbuilder/testdata/schemas/uschema.sql b/go/vt/vtgate/planbuilder/testdata/schemas/uschema.sql new file mode 100644 index 00000000000..e69de29bb2d diff --git a/go/vt/vtgate/vindexes/vschema_test.go b/go/vt/vtgate/vindexes/vschema_test.go index 25f8e135698..f9bcf43ddaa 100644 --- a/go/vt/vtgate/vindexes/vschema_test.go +++ b/go/vt/vtgate/vindexes/vschema_test.go @@ -21,6 +21,7 @@ import ( "encoding/json" "errors" "fmt" + "os" "reflect" "strings" "testing" @@ -3551,6 +3552,20 @@ func TestFindTableWithSequences(t *testing.T) { } } +func TestGlobalTables(t *testing.T) { + input, err := os.ReadFile("../planbuilder/testdata/vschemas/schema.json") + require.NoError(t, err) + + var vs vschemapb.SrvVSchema + err = json2.UnmarshalPB(input, &vs) + require.NoError(t, err) + + got := BuildVSchema(&vs, sqlparser.NewTestParser()) + tbl, err := got.findGlobalTable("user", false) + require.NoError(t, err) + assert.NotNil(t, tbl) +} + func vindexNames(vindexes []*ColumnVindex) (result []string) { for _, vindex := range vindexes { result = append(result, vindex.Name)