예제 #1
0
func TestOverrideTables(t *testing.T) {
	testCases := []struct {
		table     string
		cacheType int
	}{{
		table:     "vitess_cached2",
		cacheType: schema.CacheRW,
	}, {
		table:     "vitess_view",
		cacheType: schema.CacheRW,
	}, {
		table:     "vitess_part1",
		cacheType: schema.CacheW,
	}, {
		table:     "vitess_part2",
		cacheType: schema.CacheW,
	}}
	for _, tcase := range testCases {
		table, ok := framework.DebugSchema()[tcase.table]
		if !ok {
			t.Errorf("Table %s not found in schema", tcase.table)
			return
		}
		if table.Type != tcase.cacheType {
			t.Errorf("Type: %d, want %d", table.Type, tcase.cacheType)
		}
	}
}
예제 #2
0
func TestUncacheableTables(t *testing.T) {
	client := framework.NewClient()

	nocacheTables := []struct {
		name   string
		create string
		drop   string
	}{{
		create: "create table vitess_nocache(eid int, primary key (eid)) comment 'vitess_nocache'",
		drop:   "drop table vitess_nocache",
	}, {
		create: "create table vitess_nocache(somecol int)",
		drop:   "drop table vitess_nocache",
	}, {
		create: "create table vitess_nocache(charcol varchar(10), primary key(charcol))",
		drop:   "drop table vitess_nocache",
	}}
	for _, tcase := range nocacheTables {
		_, err := client.Execute(tcase.create, nil)
		if err != nil {
			t.Error(err)
			return
		}
		table, ok := framework.DebugSchema()["vitess_nocache"]
		client.Execute(tcase.drop, nil)
		if !ok {
			t.Errorf("%s: table vitess_nocache not found in schema", tcase.create)
			continue
		}
		if table.Type != schema.CacheNone {
			t.Errorf("Type: %d, want %d", table.Type, schema.CacheNone)
		}
	}
}