Skip to content

Commit

Permalink
export API to set RefTime of Updater (#641)
Browse files Browse the repository at this point in the history
* export API to set RefTime of Updater

Signed-off-by: Adam Korczynski <[email protected]>

* Update metadata/updater/updater.go

Co-authored-by: Fredrik Skogman <[email protected]>
Signed-off-by: AdamKorcz <[email protected]>

* update name in test

Signed-off-by: Adam Korczynski <[email protected]>

* add comment to UnsafeSetRefTime

Signed-off-by: Adam Korczynski <[email protected]>

* Update metadata/updater/updater.go

Co-authored-by: Fredrik Skogman <[email protected]>
Signed-off-by: AdamKorcz <[email protected]>

---------

Signed-off-by: Adam Korczynski <[email protected]>
Signed-off-by: AdamKorcz <[email protected]>
Co-authored-by: Fredrik Skogman <[email protected]>
  • Loading branch information
AdamKorcz and kommendorkapten authored Jun 18, 2024
1 parent 4186614 commit f1d8916
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions metadata/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,13 @@ func (update *Updater) GetTrustedMetadataSet() trustedmetadata.TrustedMetadata {
return *update.trusted
}

// UnsafeSetRefTime sets the reference time that the updater uses.
// This should only be done in tests.
// Using this function is useful when testing time-related behavior in go-tuf.
func (update *Updater) UnsafeSetRefTime(t time.Time) {
update.trusted.RefTime = t
}

func IsWindowsPath(path string) bool {
match, _ := regexp.MatchString(`^[a-zA-Z]:\\`, path)
return match
Expand Down
2 changes: 1 addition & 1 deletion metadata/updater/updater_top_level_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func runRefresh(updaterConfig *config.UpdaterConfig, moveInTime time.Time) (Upda
}

if moveInTime != time.Now() {
updater.trusted.RefTime = moveInTime
updater.UnsafeSetRefTime(moveInTime)
}

return *updater, updater.Refresh()
Expand Down

0 comments on commit f1d8916

Please sign in to comment.