forked from concourse/governance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailgun_test.go
52 lines (42 loc) · 1.21 KB
/
mailgun_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
package governance_test
import (
"os"
"testing"
"github.com/concourse/governance"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const domain = "concourse-ci.org"
func TestMailgun(t *testing.T) {
config, err := governance.LoadConfig(os.DirFS("."))
require.NoError(t, err)
desired := config.DesiredMailgunState(domain)
actual, err := governance.LoadMailgunState(domain)
require.NoError(t, err)
for _, desiredRoute := range desired.Routes {
t.Run(desiredRoute.Description, func(t *testing.T) {
var found bool
for _, actualRoute := range actual.Routes {
if actualRoute.Description == desiredRoute.Description {
found = true
assert.Equal(t, desiredRoute.Expression, actualRoute.Expression)
assert.ElementsMatch(t, desiredRoute.Actions, actualRoute.Actions)
break
}
}
assert.True(t, found, "route is not configured")
})
}
for _, actualRoute := range actual.Routes {
t.Run(actualRoute.Description, func(t *testing.T) {
var found bool
for _, desiredRoute := range desired.Routes {
if desiredRoute.Description == actualRoute.Description {
found = true
break
}
}
assert.True(t, found, "route is not desired")
})
}
}