2019-07-15 15:09:52 +00:00
|
|
|
package discoverychain
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
|
|
|
"github.com/mitchellh/go-testing-interface"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCompileConfigEntries(
|
|
|
|
t testing.T,
|
|
|
|
serviceName string,
|
2019-08-05 18:30:35 +00:00
|
|
|
evaluateInNamespace string,
|
|
|
|
evaluateInDatacenter string,
|
2019-08-19 18:03:03 +00:00
|
|
|
evaluateInTrustDomain string,
|
2019-08-05 18:30:35 +00:00
|
|
|
useInDatacenter string,
|
2019-08-02 03:03:34 +00:00
|
|
|
setup func(req *CompileRequest),
|
2019-07-15 15:09:52 +00:00
|
|
|
entries ...structs.ConfigEntry,
|
|
|
|
) *structs.CompiledDiscoveryChain {
|
|
|
|
set := structs.NewDiscoveryChainConfigEntries()
|
|
|
|
|
|
|
|
set.AddEntries(entries...)
|
|
|
|
|
2019-08-02 03:03:34 +00:00
|
|
|
req := CompileRequest{
|
2019-08-19 18:03:03 +00:00
|
|
|
ServiceName: serviceName,
|
|
|
|
EvaluateInNamespace: evaluateInNamespace,
|
|
|
|
EvaluateInDatacenter: evaluateInDatacenter,
|
|
|
|
EvaluateInTrustDomain: evaluateInTrustDomain,
|
|
|
|
UseInDatacenter: useInDatacenter,
|
|
|
|
Entries: set,
|
2019-08-02 03:03:34 +00:00
|
|
|
}
|
|
|
|
if setup != nil {
|
|
|
|
setup(&req)
|
|
|
|
}
|
|
|
|
|
|
|
|
chain, err := Compile(req)
|
2019-07-15 15:09:52 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
return chain
|
|
|
|
}
|