-
Notifications
You must be signed in to change notification settings - Fork 7
/
drt_assertions_test.go
74 lines (64 loc) · 1.19 KB
/
drt_assertions_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package testing
import "testing"
func TestDRTAssertions(t *testing.T) {
t.Run("equal pass", func(t *testing.T) {
wd := testHelper.RequireNewWorkingDir(t)
defer wd.Close()
wd.RequireSetConfig(t, `
data "testing_assertions" "test" {
equal "foo" {
got = "a"
want = "a"
}
}
`)
wd.RequireInit(t)
wd.RequireApply(t)
})
t.Run("equal fail", func(t *testing.T) {
wd := testHelper.RequireNewWorkingDir(t)
defer wd.Close()
wd.RequireSetConfig(t, `
data "testing_assertions" "test" {
equal "foo" {
got = "a"
want = "b"
}
}
`)
wd.RequireInit(t)
err := wd.Apply()
if err == nil {
t.Error("succeeded; want error")
}
})
t.Run("check pass", func(t *testing.T) {
wd := testHelper.RequireNewWorkingDir(t)
defer wd.Close()
wd.RequireSetConfig(t, `
data "testing_assertions" "test" {
check "foo" {
expect = true
}
}
`)
wd.RequireInit(t)
wd.RequireApply(t)
})
t.Run("check fail", func(t *testing.T) {
wd := testHelper.RequireNewWorkingDir(t)
defer wd.Close()
wd.RequireSetConfig(t, `
data "testing_assertions" "test" {
check "foo" {
expect = false
}
}
`)
wd.RequireInit(t)
err := wd.Apply()
if err == nil {
t.Error("succeeded; want error")
}
})
}