github.com/quay/claircore@v1.5.28/test/integration/examples_test.go (about) 1 package integration_test 2 3 import ( 4 "context" 5 "os" 6 "testing" 7 8 "github.com/quay/claircore/test/integration" 9 ) 10 11 func ExampleDBSetup() { 12 var m *testing.M // This should come from TestMain's argument. 13 var c int 14 defer func() { os.Exit(c) }() 15 defer integration.DBSetup()() 16 c = m.Run() 17 } 18 19 func ExampleSkip() { 20 var t *testing.T // This should come from the test function's argument. 21 t.Parallel() 22 integration.Skip(t) 23 t.Log("OK") // Do some test that needs external setup. 24 } 25 26 func ExampleNeedDB() { 27 var t *testing.T // This should come from the test function's argument. 28 integration.NeedDB(t) 29 30 ctx := context.Background() 31 db, err := integration.NewDB(ctx, t) 32 if err != nil { 33 t.Fatal(err) 34 } 35 defer db.Close(ctx, t) 36 37 t.Log("OK") // Do some test that needs a database. 38 }