Skip to content

Commit

Permalink
add test for group deletion (#1497)
Browse files Browse the repository at this point in the history
* add test for group hard deletion
  • Loading branch information
SimoneDutto authored Dec 16, 2024
1 parent fd629e9 commit 6fa9787
Showing 1 changed file with 22 additions and 0 deletions.
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)
}

// TestHardDeleteGroupEntry tests hard delete of groups, to make sure we can create a group with the same name after deleting it.
func TestHardDeleteGroupEntry(t *testing.T) {
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)
}

0 comments on commit 6fa9787

Please sign in to comment.