MCPcopy
hub / github.com/apache/answer / initTestDataSource

Function initTestDataSource

internal/repo/repo_test/repo_main_test.go:107–137  ·  view source on GitHub ↗
(dbSetting TestDBSetting)

Source from the content-addressed store, hash-verified

105}
106
107func initTestDataSource(dbSetting TestDBSetting) error {
108 connection, imageCleanUp, err := initDatabaseImage(dbSetting)
109 if err != nil {
110 return err
111 }
112 dbSetting.Connection = connection
113
114 dbEngine, err := initDatabase(dbSetting)
115 if err != nil {
116 return err
117 }
118
119 newCache, err := initCache()
120 if err != nil {
121 return err
122 }
123
124 newData, dbCleanUp, err := data.NewData(dbEngine, newCache)
125 if err != nil {
126 return err
127 }
128 testDataSource = newData
129
130 tearDown = func() {
131 dbCleanUp()
132 log.Info("cleanup test database successfully")
133 imageCleanUp()
134 log.Info("cleanup test database image successfully")
135 }
136 return nil
137}
138
139func initDatabaseImage(dbSetting TestDBSetting) (connection string, cleanup func(), err error) {
140 // sqlite3 don't need to set up image

Callers 1

TestMainFunction · 0.70

Calls 5

NewDataFunction · 0.92
initDatabaseImageFunction · 0.70
initDatabaseFunction · 0.70
initCacheFunction · 0.70
InfoMethod · 0.65

Tested by

no test coverage detected