Skip to content

Commit

Permalink
Fix client tests
Browse files Browse the repository at this point in the history
Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>
  • Loading branch information
dborovcanin committed Mar 29, 2024
1 parent e2e0736 commit 3c28c8a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions pkg/clients/postgres/clients_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func TestRetrieveAll(t *testing.T) {
Identity: namegen.Generate() + emailSuffix,
Secret: password,
},
Tags: namegen.GenerateNames(5),
Tags: generateNames(5),
Metadata: mgclients.Metadata{
"department": namegen.Generate(),
},
Expand Down Expand Up @@ -683,7 +683,7 @@ func TestRetrieveByIDs(t *testing.T) {
Identity: name + emailSuffix,
Secret: password,
},
Tags: namegen.GenerateNames(5),
Tags: generateNames(5),
Metadata: map[string]interface{}{"name": name},
CreatedAt: time.Now().UTC().Truncate(time.Millisecond),
Status: clients.EnabledStatus,
Expand Down Expand Up @@ -1501,23 +1501,23 @@ func TestUpdateTags(t *testing.T) {
desc: "for enabled client",
client: mgclients.Client{
ID: client1.ID,
Tags: namegen.GenerateNames(5),
Tags: generateNames(5),
},
err: nil,
},
{
desc: "for disabled client",
client: mgclients.Client{
ID: client2.ID,
Tags: namegen.GenerateNames(5),
Tags: generateNames(5),
},
err: repoerr.ErrNotFound,
},
{
desc: "for invalid client",
client: mgclients.Client{
ID: testsutil.GenerateUUID(t),
Tags: namegen.GenerateNames(5),
Tags: generateNames(5),
},
err: repoerr.ErrNotFound,
},
Expand Down Expand Up @@ -1825,7 +1825,7 @@ func generateClient(t *testing.T, status mgclients.Status, role mgclients.Role,
Identity: namegen.Generate() + emailSuffix,
Secret: password,
},
Tags: namegen.GenerateNames(5),
Tags: generateNames(5),
Metadata: mgclients.Metadata{
"name": namegen.Generate(),
},
Expand Down Expand Up @@ -1874,3 +1874,11 @@ func getIDs(clis []mgclients.Client) []string {

return ids
}

func generateNames(num int) []string {
ret := make([]string, num)
for i := 0; i < num; i++ {
ret[i] = namegen.Generate()
}
return ret
}

0 comments on commit 3c28c8a

Please sign in to comment.