MCPcopy Create free account
hub / github.com/QuantumNous/new-api / initModelListColumnNames

Function initModelListColumnNames

controller/model_list_test.go:64–95  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62}
63
64func initModelListColumnNames(t *testing.T) {
65 t.Helper()
66
67 originalIsMasterNode := common.IsMasterNode
68 originalSQLitePath := common.SQLitePath
69 originalMainDatabaseType := common.MainDatabaseType()
70 originalLogDatabaseType := common.LogDatabaseType()
71 originalSQLDSN, hadSQLDSN := os.LookupEnv("SQL_DSN")
72 defer func() {
73 common.IsMasterNode = originalIsMasterNode
74 common.SQLitePath = originalSQLitePath
75 common.SetDatabaseTypes(originalMainDatabaseType, originalLogDatabaseType)
76 if hadSQLDSN {
77 require.NoError(t, os.Setenv("SQL_DSN", originalSQLDSN))
78 } else {
79 require.NoError(t, os.Unsetenv("SQL_DSN"))
80 }
81 }()
82
83 common.IsMasterNode = false
84 common.SQLitePath = fmt.Sprintf("file:%s_init?mode=memory&cache=shared", strings.ReplaceAll(t.Name(), "/", "_"))
85 common.SetDatabaseTypes(common.DatabaseTypeSQLite, common.DatabaseTypeSQLite)
86 require.NoError(t, os.Setenv("SQL_DSN", "local"))
87
88 require.NoError(t, model.InitDB())
89 if model.DB != nil {
90 sqlDB, err := model.DB.DB()
91 if err == nil {
92 _ = sqlDB.Close()
93 }
94 }
95}
96
97func withTieredBillingConfig(t *testing.T, modes map[string]string, exprs map[string]string) {
98 t.Helper()

Callers 1

Calls 5

MainDatabaseTypeFunction · 0.92
LogDatabaseTypeFunction · 0.92
SetDatabaseTypesFunction · 0.92
InitDBFunction · 0.92
CloseMethod · 0.45

Tested by

no test coverage detected