...
1
2 package integrationlevels
3
4 import (
5 "context"
6 "os"
7 "testing"
8
9 "gotest.tools/v3/assert"
10
11 "edge-infra.dev/test/f2"
12 "edge-infra.dev/test/f2/integration"
13 )
14
15
16
17
18
19
20
21
22
23
24 var f f2.Framework
25
26 func TestMain(m *testing.M) {
27 f = f2.New(context.Background())
28 os.Exit(f.Run(m))
29 }
30
31 func TestSkipIfNot(t *testing.T) {
32
33
34 integration.SkipIfNot(t, integration.L2)
35
36 fin := f2.NewFeature("SkipIfNot").
37 Test("test skip if not", func(ctx f2.Context, t *testing.T) f2.Context {
38 t.Log("in SkipIfNot", "level", 2)
39 assert.Assert(t, true)
40
41 return ctx
42 }).Feature()
43
44 f.Test(t, fin)
45 }
46
47 func TestSkipIf(t *testing.T) {
48 fin := f2.NewFeature("SkipIf").
49 Test("test skip if", func(ctx f2.Context, t *testing.T) f2.Context {
50
51
52 integration.SkipIf(t, integration.L2)
53
54 t.Log("in SkipIf", "level", 1)
55 assert.Assert(t, true)
56
57 return ctx
58 }).Feature()
59
60 f.Test(t, fin)
61 }
62
63 func TestLevels(t *testing.T) {
64 fin := f2.NewFeature("Levels").
65 Test("test levels", func(ctx f2.Context, t *testing.T) f2.Context {
66
67
68
69
70
71 if integration.IsL1() {
72 t.Log("in TestLevels", "level", 1)
73 }
74
75 if integration.IsL2() {
76 t.Log("in TestLevels", "level", 2)
77 }
78 assert.Assert(t, true)
79
80 return ctx
81 }).Feature()
82
83 f.Test(t, fin)
84 }
85
View as plain text