-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
testing.go
37 lines (31 loc) · 959 Bytes
/
testing.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
package discoverychain
import (
"github.com/mitchellh/go-testing-interface"
"github.com/stretchr/testify/require"
"github.com/hashicorp/consul/agent/configentry"
"github.com/hashicorp/consul/agent/structs"
)
func TestCompileConfigEntries(t testing.T,
serviceName string,
evaluateInNamespace string,
evaluateInPartition string,
evaluateInDatacenter string,
evaluateInTrustDomain string,
setup func(req *CompileRequest), entries ...structs.ConfigEntry) *structs.CompiledDiscoveryChain {
set := configentry.NewDiscoveryChainSet()
set.AddEntries(entries...)
req := CompileRequest{
ServiceName: serviceName,
EvaluateInNamespace: evaluateInNamespace,
EvaluateInPartition: evaluateInPartition,
EvaluateInDatacenter: evaluateInDatacenter,
EvaluateInTrustDomain: evaluateInTrustDomain,
Entries: set,
}
if setup != nil {
setup(&req)
}
chain, err := Compile(req)
require.NoError(t, err)
return chain
}