diff --git a/internal/dbmodel/group_test.go b/internal/dbmodel/group_test.go index e9b12b849..6d3725f1e 100644 --- a/internal/dbmodel/group_test.go +++ b/internal/dbmodel/group_test.go @@ -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) +}