// loadMasks adds masks to run tests. func loadMasks(db *db.DB, file string) error { masks, err := mfix.Get(file) if err != nil { return err } for _, msk := range masks { if err := mfix.Add(db, msk); err != nil { return err } } return nil }
// loadTestData adds all the test data into the database. func loadTestData(t *testing.T, db *db.DB) { t.Log("\tWhen loading data for the tests") { err := tstdata.Generate(db) if err != nil { t.Fatalf("\t%s\tShould be able to load system with test data : %v", tests.Failed, err) } t.Logf("\t%s\tShould be able to load system with test data.", tests.Success) scripts := []string{ "basic_script_pre.json", "basic_script_pst.json", } for _, file := range scripts { scr, err := sfix.Get(file) if err != nil { t.Fatalf("\t%s\tShould load script document from file : %v", tests.Failed, err) } t.Logf("\t%s\tShould load script document from file.", tests.Success) // We need these scripts loaded under another name to allow tests // to run in parallel. scr.Name = strings.Replace(scr.Name, "STEST_O", "STEST_T", 1) if err := script.Upsert(tests.Context, db, scr); err != nil { t.Fatalf("\t%s\tShould be able to create a script : %s", tests.Failed, err) } t.Logf("\t%s\tShould be able to create a script.", tests.Success) } masks, err := mfix.Get("basic.json") if err != nil { t.Fatalf("\t%s\tShould load mask documents from file : %v", tests.Failed, err) } t.Logf("\t%s\tShould load mask documents from file.", tests.Success) for _, msk := range masks { if err := mfix.Add(db, msk); err != nil { t.Fatalf("\t%s\tShould be able to create a mask : %s", tests.Failed, err) } t.Logf("\t%s\tShould be able to create a mask.", tests.Success) } } }