...
1 package integration
2
3 import (
4 "edge-infra.dev/test/framework"
5 "edge-infra.dev/test/framework/config"
6 )
7
8 var isIntegrationTest bool
9
10 func init() {
11 config.Flags.BoolVar(&isIntegrationTest, "integration", false,
12 "whether or not this is an integration test run")
13 }
14
15 func IsIntegrationTest() bool {
16 return isIntegrationTest
17 }
18
19
20
21
22
23
24
25
26 func Skip(steps ...framework.Step) framework.Step {
27 return func(f *framework.Framework) {
28 if isIntegrationTest && len(steps) > 0 {
29 for _, s := range steps {
30 s(f)
31 }
32 }
33 }
34 }
35
36
37 func SkipIf(f *framework.Framework) {
38 if isIntegrationTest {
39 f.Skip("integration", "this test can only be ran as a unit test")
40 }
41 }
42
43
44 func SkipIfNot(f *framework.Framework) {
45 if !isIntegrationTest {
46 f.Skip("integration", "this test can only be ran as an integration test")
47 }
48 }
49
50
51
52 func Only(e bool) bool {
53 return isIntegrationTest && e
54 }
55
View as plain text