github.com/cilium/cilium@v1.16.2/test/controlplane/suite/suite.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Cilium 3 4 package suite 5 6 import ( 7 "os" 8 "testing" 9 ) 10 11 type testCase struct { 12 name string 13 test func(t *testing.T) 14 } 15 16 var allTestCases []testCase 17 18 func AddTestCase(name string, fun func(t *testing.T)) { 19 allTestCases = append(allTestCases, testCase{name, fun}) 20 } 21 22 func RunSuite(t *testing.T) { 23 ParseFlags() 24 cwd, err := os.Getwd() 25 if err != nil { 26 t.Fatal(err) 27 } 28 for _, tc := range allTestCases { 29 t.Run(tc.name, tc.test) 30 31 // Switch back to test root 32 // FIXME: maybe just consider embedding instead? 33 os.Chdir(cwd) 34 } 35 }