MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestFullProcess

Function TestFullProcess

sqlchain/mirror/mirror_test.go:213–323  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

211}
212
213func TestFullProcess(t *testing.T) {
214 log.SetLevel(log.DebugLevel)
215
216 Convey("test mirror full process", t, func() {
217 var (
218 err error
219 )
220
221 startNodes()
222 defer stopNodes()
223
224 err = client.Init(FJ(testWorkingDir, "./mirror/node_c/config.yaml"), []byte(""))
225 So(err, ShouldBeNil)
226
227 // wait bp chain service to start
228 ctx, ccl1 := context.WithTimeout(context.Background(), 1*time.Minute)
229 defer ccl1()
230 err = test.WaitBPChainService(ctx, 3*time.Second)
231 So(err, ShouldBeNil)
232
233 // create
234 meta := client.ResourceMeta{}
235 meta.Node = 1
236 _, dsn, err := client.Create(meta)
237 So(err, ShouldBeNil)
238 dsnCfg, err := client.ParseDSN(dsn)
239 So(err, ShouldBeNil)
240
241 log.Infof("the created database dsn is %v", dsn)
242
243 db, err := sql.Open("covenantsql", dsn)
244 So(err, ShouldBeNil)
245 defer db.Close()
246
247 // wait for creation
248 ctx, ccl2 := context.WithTimeout(context.Background(), 5*time.Minute)
249 defer ccl2()
250 err = client.WaitDBCreation(ctx, dsn)
251 So(err, ShouldBeNil)
252
253 _, err = db.Exec("CREATE TABLE test (test int)")
254 So(err, ShouldBeNil)
255
256 _, err = db.Exec("INSERT INTO test VALUES(?)", 4)
257 So(err, ShouldBeNil)
258
259 row := db.QueryRow("SELECT * FROM test LIMIT 1")
260
261 var result int
262 err = row.Scan(&result)
263 So(err, ShouldBeNil)
264 So(result, ShouldEqual, 4)
265
266 // run mirror node
267 utils.RemoveAll(FJ(testWorkingDir, "./mirror/node_mirror/"+dsnCfg.DatabaseID+"*"))
268 defer utils.RemoveAll(FJ(testWorkingDir, "./mirror/node_mirror/"+dsnCfg.DatabaseID+"*"))
269
270 var mirrorCmd *utils.CMD

Callers

nothing calls this directly

Calls 15

SetLevelFunction · 0.92
InitFunction · 0.92
WaitBPChainServiceFunction · 0.92
CreateFunction · 0.92
ParseDSNFunction · 0.92
InfofFunction · 0.92
WaitDBCreationFunction · 0.92
RemoveAllFunction · 0.92
RunCommandNBFunction · 0.92
WaitToConnectFunction · 0.92
waitForMirrorCompleteFunction · 0.85
QueryRowMethod · 0.80

Tested by

no test coverage detected