func init() { TableCollection = csdb.NewTableManager( csdb.AddTableByName(TableIndexStore, "store"), csdb.AddTableByName(TableIndexGroup, "store_group"), csdb.AddTableByName(TableIndexWebsite, "store_website"), ) // Don't forget to call TableCollection.ReInit(...) in your code to load the column definitions. }
func TestNewTableManager(t *testing.T) { assert.Equal(t, csdb.NewTableManager().Len(), csdb.Index(0)) const ( TableIndexStore csdb.Index = iota // Table: store TableIndexGroup // Table: store_group TableIndexWebsite // Table: store_website TableIndexZZZ // the maximum index, which is not available. ) tm1 := csdb.NewTableManager( csdb.AddTableByName(TableIndexStore, "store"), csdb.AddTableByName(TableIndexGroup, "store_group"), csdb.AddTableByName(TableIndexWebsite, "store_website"), ) assert.Equal(t, tm1.Len(), csdb.Index(3)) }
func TestNewTableManagerPanic(t *testing.T) { defer func() { if r := recover(); r != nil { assert.Contains(t, r.(string), csdb.ErrManagerIncorrectValue.Error()) } }() tm0 := csdb.NewTableManager( csdb.AddTableByName(csdb.Index(0), ""), ) assert.NotNil(t, tm0) assert.Equal(t, tm0.Len(), csdb.Index(0)) }
func TestNewTableManagerInit(t *testing.T) { dbc := csdb.MustConnectTest() defer dbc.Close() i := csdb.Index(4711) tm0 := csdb.NewTableManager(csdb.AddTableByName(i, "admin_user")) assert.EqualError(t, tm0.Init(dbc.NewSession(), true), csdb.ErrManagerInitReload.Error()) err := tm0.Init(dbc.NewSession()) assert.NoError(t, err) table, err2 := tm0.Structure(i) assert.NoError(t, err2) assert.Equal(t, 1, table.CountPK) assert.Equal(t, 1, table.CountUnique) assert.True(t, len(table.Columns.FieldNames()) >= 15) assert.Nil(t, tm0.Init(dbc.NewSession())) }
func init() { TableCollection = csdb.NewTableManager( csdb.AddTableByName(TableIndexCoreConfigData, "core_config_data"), ) // Don't forget to call TableCollection.ReInit(...) in your code to load the column definitions. }