-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup server-side VCR testing for UI regression
- Enable mocking time with `clock` package - Enable mocking new ID creation - Add VCR setup in middleware - Fix duplicate metric registration - Fix empty NotificationClientID for creating Garden - Generate some tests
- Loading branch information
1 parent
f920597
commit 8a63e94
Showing
47 changed files
with
3,944 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package clock | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/benbjohnson/clock" | ||
"github.com/go-co-op/gocron" | ||
) | ||
|
||
// Clock allows mocking time | ||
type Clock struct { | ||
clock.Clock | ||
} | ||
|
||
// DefaultClock is the underlying Clock used and can be overridden to mock | ||
var DefaultClock = Clock{clock.New()} | ||
|
||
var _ gocron.TimeWrapper = Clock{} | ||
|
||
func (c Clock) Now(loc *time.Location) time.Time { | ||
return c.Clock.Now().In(loc) | ||
} | ||
|
||
func (c Clock) Unix(sec int64, nsec int64) time.Time { | ||
return time.Unix(sec, nsec).In(DefaultClock.Clock.Now().Location()) | ||
} | ||
|
||
func Now() time.Time { | ||
return DefaultClock.Clock.Now() | ||
} | ||
|
||
// MockTime sets up the DefaultClock with a consistent time so it can be used across tests | ||
func MockTime() *clock.Mock { | ||
mock := clock.NewMock() | ||
mock.Set(time.Date(2023, time.August, 23, 10, 0, 0, 0, time.UTC)) | ||
DefaultClock = Clock{Clock: mock} | ||
return mock | ||
} | ||
|
||
// Reset returns the DefaultClock to real time | ||
func Reset() { | ||
DefaultClock = Clock{clock.New()} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.