Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for group deletion #1497

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions internal/dbmodel/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,25 @@ func TestGroupEntry(t *testing.T) {
c.Assert(result.Error, qt.IsNil)
c.Assert(ge3, qt.DeepEquals, ge)
}

// test we hard delete groups, so when we can recreate the group with the same name after deleting it.
SimoneDutto marked this conversation as resolved.
Show resolved Hide resolved
func TestHardDeleteGroupEntry(t *testing.T) {
SimoneDutto marked this conversation as resolved.
Show resolved Hide resolved
c := qt.New(t)
db := gormDB(t)

ge := dbmodel.GroupEntry{
Name: "test-group-1",
}
c.Assert(db.Create(&ge).Error, qt.IsNil)
c.Assert(ge.ID, qt.Equals, uint(1))

c.Assert(db.Delete(ge).Error, qt.IsNil)

result := db.First(&ge)
c.Assert(result.Error, qt.ErrorMatches, "record not found")

ge1 := dbmodel.GroupEntry{
Name: "test-group-1",
}
c.Assert(db.Create(&ge1).Error, qt.IsNil)
}
Loading