Skip to content

Commit

Permalink
Integration test endpoints will now ensure items selected for test de…
Browse files Browse the repository at this point in the history
…letion meet minimum retention period.
  • Loading branch information
diamondap committed Mar 25, 2024
1 parent f6537fd commit 394b177
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions web/api/admin/integration_test_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ func prepareFileDeletionPreconditions(gfID int64) (*pgmodels.WorkItem, error) {
return nil, err
}

// Ensure file has met minimum retention period.
gf.CreatedAt = time.Now().Add(time.Hour * 24 * -365)
err = gf.Save()
if err != nil {
return nil, err
}

instAdmin, err := getInstAdmin(gf.InstitutionID)
if err != nil {
return nil, err
Expand Down Expand Up @@ -111,6 +118,29 @@ func prepareObjectDeletionPreconditions(objID int64) (*pgmodels.WorkItem, error)
return nil, err
}

// Ensure object has met minimum retention period.
oneYearAgo := time.Now().Add(time.Hour * 24 * -365)
obj.CreatedAt = oneYearAgo
err = obj.Save()
if err != nil {
return nil, err
}

// And files too.
query := pgmodels.NewQuery().
Where("intellectual_object_id", "=", obj.ID)
files, err := pgmodels.GenericFileSelect(query)
if err != nil {
return nil, err
}
for _, gf := range files {
gf.CreatedAt = oneYearAgo
err = gf.Save()
if err != nil {
return nil, err
}
}

instAdmin, err := getInstAdmin(obj.InstitutionID)
if err != nil {
return nil, err
Expand Down

0 comments on commit 394b177

Please sign in to comment.