Skip to content

Commit

Permalink
wip add test
Browse files Browse the repository at this point in the history
  • Loading branch information
shoenig committed May 12, 2022
1 parent f8a555d commit c6a8ea6
Showing 1 changed file with 47 additions and 8 deletions.
55 changes: 47 additions & 8 deletions dependency/nomad_services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,55 @@ func TestNewNomadServicesQueryQuery(t *testing.T) {
}
}

func TestNomadServicesQuery_Fetch(t *testing.T) {
func TestNomadServicesQuery_Fetch_1arg(t *testing.T) {
cases := []struct {
name string
service string
exp []*NomadServicesSnippet
}{
{
name: "all",
service: "",
exp: []*NomadServicesSnippet{
&NomadServicesSnippet{
Name: "example-cache",
Tags: ServiceTags([]string{"tag1", "tag2"}),
},
},
},
}

for i, tc := range cases {
t.Run(fmt.Sprintf("%d_%s", i, tc.name), func(t *testing.T) {
d, err := NewNomadServicesQuery(tc.service)
if err != nil {
t.Fatal(err)
}

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

require.Equal(t, tc.exp, act)
})
}
}

func TestNomadServicesQuery_Fetch_3arg(t *testing.T) {
cases := []struct {
name string
i string
exp []*NomadServicesSnippet
name string
service string
count int
key string
exp []*NomadServicesSnippet
}{
{
"all",
"",
[]*NomadServicesSnippet{
name: "choose one",
service: "example-cache",
count: 1,
key: "abc123",
exp: []*NomadServicesSnippet{
&NomadServicesSnippet{
Name: "example-cache",
Tags: ServiceTags([]string{"tag1", "tag2"}),
Expand All @@ -74,7 +112,7 @@ func TestNomadServicesQuery_Fetch(t *testing.T) {

for i, tc := range cases {
t.Run(fmt.Sprintf("%d_%s", i, tc.name), func(t *testing.T) {
d, err := NewNomadServicesQuery(tc.i)
d, err := NewNomadServiceChooseQuery(tc.count, tc.key, tc.service)
if err != nil {
t.Fatal(err)
}
Expand All @@ -88,6 +126,7 @@ func TestNomadServicesQuery_Fetch(t *testing.T) {
})
}
}

func TestNomadServicesQuery_String(t *testing.T) {

cases := []struct {
Expand Down

0 comments on commit c6a8ea6

Please sign in to comment.