1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-12-15 23:41:26 +02:00

test: replace mock pkg/clock with narrowly targeted stub clocks. (#3238)

The package under pkg/clock is github.com/benbjohnson/clock, which is
archived. It's also way more complex than is what is actually needed
here, so we can entirely remove the dependency and remove the helper
package.

Fixes #2840.

Signed-off-by: David Symonds <dsymonds@gmail.com>
This commit is contained in:
David Symonds
2025-10-28 20:05:02 +11:00
committed by GitHub
parent 8f687e4d0c
commit 110d51d1d7
13 changed files with 50 additions and 594 deletions

View File

@@ -22,7 +22,7 @@ func TestCreatedAtNow(t *testing.T) {
ss := &SessionState{}
now := time.Unix(1234567890, 0)
ss.Clock.Set(now)
ss.Clock = func() time.Time { return now }
ss.CreatedAtNow()
g.Expect(*ss.CreatedAt).To(Equal(now))
@@ -33,9 +33,9 @@ func TestExpiresIn(t *testing.T) {
ss := &SessionState{}
now := time.Unix(1234567890, 0)
ss.Clock.Set(now)
ss.Clock = func() time.Time { return now }
ttl := time.Duration(743) * time.Second
ttl := 743 * time.Second
ss.ExpiresIn(ttl)
g.Expect(*ss.ExpiresOn).To(Equal(ss.CreatedAt.Add(ttl)))