Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteCreatedEntities ¶
DeleteCreatedEntities records all created entities on the gorm.DB connection and returns a function which can be called on defer to delete created entities in reverse order on function exit.
In addition to that, the WIT cache is cleared as well in order to respect any deletions made to the db.
Usage:
func TestDatabaseActions(t *testing.T) {
// setup database connection db := .... // setup auto clean up of created entities defer DeleteCreatedEntities(db)() repo := NewRepo(db) repo.Create(X) repo.Create(X) repo.Create(X) }
Output:
2017/01/31 12:08:08 Deleting from x 6d143405-1232-40de-bc73-835b543cd972 2017/01/31 12:08:08 Deleting from x 0685068d-4934-4d9a-bac2-91eebbca9575 2017/01/31 12:08:08 Deleting from x 2d20944e-7952-40c1-bd15-f3fa1a70026d
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.