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"
|
|
|
|
)
|
|
|
|
|
2021-09-07 20:29:32 +00:00
|
|
|
func TestCompileConfigEntries(t testing.T,
|
2019-07-15 15:09:52 +00:00
|
|
|
serviceName string,
|
2019-08-05 18:30:35 +00:00
|
|
|
evaluateInNamespace string,
|
2021-09-07 20:29:32 +00:00
|
|
|
evaluateInPartition string,
|
2019-08-05 18:30:35 +00:00
|
|
|
evaluateInDatacenter string,
|
2019-08-19 18:03:03 +00:00
|
|
|
evaluateInTrustDomain string,
|
2021-09-07 20:29:32 +00:00
|
|
|
setup func(req *CompileRequest), entries ...structs.ConfigEntry) *structs.CompiledDiscoveryChain {
|
2019-07-15 15:09:52 +00:00
|
|
|
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,
|
2021-09-07 20:29:32 +00:00
|
|
|
EvaluateInPartition: evaluateInPartition,
|
2019-08-19 18:03:03 +00:00
|
|
|
EvaluateInDatacenter: evaluateInDatacenter,
|
|
|
|
EvaluateInTrustDomain: evaluateInTrustDomain,
|
|
|
|
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
|
|
|
|
}
|