Skip to content

Commit

Permalink
[NET-7571]
Browse files Browse the repository at this point in the history
- bug fix for SeatGeek: Services function in CT (consul-template) does not update the namespace for each services API call
- opts should be defaulted to the opts at query creation.
- then they should be merged with the opts present in Fetch.
- currently the merge was the other way around.
- ENT test support is not there, so no test cases added as of now.
  • Loading branch information
kkavish committed Feb 6, 2024
1 parent 9bd3d8e commit b30687a
Showing 1 changed file with 21 additions and 32 deletions.
53 changes: 21 additions & 32 deletions dependency/catalog_services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,14 @@ func TestCatalogServicesQuery_Fetch(t *testing.T) {
cases := []struct {
name string
i string
opts *QueryOptions
exp []*CatalogSnippet
err bool
}{
{
"all",
"",
nil,
[]*CatalogSnippet{
{
Name: "consul",
Expand All @@ -123,49 +126,35 @@ func TestCatalogServicesQuery_Fetch(t *testing.T) {
Tags: ServiceTags([]string{}),
},
},
false,
},
//no ENT support for test cases as of now.
{
"namespace_bar",
"?ns=bar&partition=default",
&QueryOptions{ConsulPartition: "default", ConsulNamespace: "bar"},
nil,
true,
},
// no ENT support as of now.
//{
// "namespace_bar",
// "?ns=bar&partition=default",
// []*CatalogSnippet{
// {
// Name: "consul",
// Tags: ServiceTags([]string{}),
// },
// {
// Name: "foobar-sidecar-proxy",
// Tags: ServiceTags([]string{}),
// },
// {
// Name: "service-meta",
// Tags: ServiceTags([]string{"tag1"}),
// },
// {
// Name: "service-taggedAddresses",
// Tags: ServiceTags([]string{}),
// },
// },
//},
}

var d *CatalogServicesQuery
for i, tc := range cases {
t.Run(fmt.Sprintf("%d_%s", i, tc.name), func(t *testing.T) {

if i == 0 {
dq, err := NewCatalogServicesQuery(tc.i)
if err != nil {
t.Fatal(err)
}
d = dq
d, err := NewCatalogServicesQuery(tc.i)
if err != nil {
t.Fatal(err)
}

act, _, err := d.Fetch(testClients, nil)
if err != nil {
act, _, err := d.Fetch(testClients, tc.opts)
if (err != nil) != tc.err {
t.Fatal(err)
}

if act == nil && tc.err {
return
}

assert.Equal(t, tc.exp, act)
})
}
Expand Down

0 comments on commit b30687a

Please sign in to comment.