Skip to content

Commit

Permalink
adding group update/delete tests (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
luthermonson authored Sep 4, 2023
1 parent 29b2e77 commit 15ed1f1
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
33 changes: 33 additions & 0 deletions access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ func TestDomain(t *testing.T) {
assert.False(t, bool(d.AutoCreate))
}

func TestNewGroup(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
client := mockClient()

assert.Nil(t, client.NewGroup("groupid", "comment"))
}

func TestGroup(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
Expand All @@ -111,6 +119,31 @@ func TestGroups(t *testing.T) {
}
}

func TestGroup_Update(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
client := mockClient()
group := Group{
client: client,
}
assert.Error(t, group.Update()) // no groupid
group.GroupID = "groupid"
assert.Nil(t, group.Update())
}

func TestGroup_Delete(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
client := mockClient()
group := Group{
client: client,
}

assert.Error(t, group.Delete())
group.GroupID = "groupid"
assert.Nil(t, group.Delete())
}

func TestUser(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
Expand Down
20 changes: 20 additions & 0 deletions tests/mocks/pve7x/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -849,4 +849,24 @@ func access() {
Post("^/access/domains/test$").
Reply(200).
JSON(``)

gock.New(config.C.URI).
Post("^/access/groups").
Reply(200).
JSON(``)

gock.New(config.C.URI).
Put("^/access/groups/groupid").
Reply(200).
JSON(``)

gock.New(config.C.URI).
Delete("^/access/groups/groupid").
Reply(200).
JSON(``)

gock.New(config.C.URI).
Post("^/access/groups/groupid").
Reply(200).
JSON(``)
}

0 comments on commit 15ed1f1

Please sign in to comment.