Browse Source

fix tests after renaming now

Marcus Efraimsson 7 years ago
parent
commit
f040f9a400
1 changed files with 8 additions and 8 deletions
  1. 8 8
      pkg/services/auth/auth_token_test.go

+ 8 - 8
pkg/services/auth/auth_token_test.go

@@ -19,7 +19,7 @@ func TestUserAuthToken(t *testing.T) {
 		userID := int64(10)
 		userID := int64(10)
 
 
 		t := time.Date(2018, 12, 13, 13, 45, 0, 0, time.UTC)
 		t := time.Date(2018, 12, 13, 13, 45, 0, 0, time.UTC)
-		now = func() time.Time {
+		getTime = func() time.Time {
 			return t
 			return t
 		}
 		}
 
 
@@ -60,7 +60,7 @@ func TestUserAuthToken(t *testing.T) {
 			token, err = ctx.getAuthTokenByID(token.Id)
 			token, err = ctx.getAuthTokenByID(token.Id)
 			So(err, ShouldBeNil)
 			So(err, ShouldBeNil)
 
 
-			now = func() time.Time {
+			getTime = func() time.Time {
 				return t.Add(time.Hour)
 				return t.Add(time.Hour)
 			}
 			}
 
 
@@ -75,7 +75,7 @@ func TestUserAuthToken(t *testing.T) {
 			So(err, ShouldBeNil)
 			So(err, ShouldBeNil)
 			So(stillGood, ShouldNotBeNil)
 			So(stillGood, ShouldNotBeNil)
 
 
-			now = func() time.Time {
+			getTime = func() time.Time {
 				return t.Add(24 * 7 * time.Hour)
 				return t.Add(24 * 7 * time.Hour)
 			}
 			}
 			notGood, err := userAuthTokenService.LookupToken(token.UnhashedToken)
 			notGood, err := userAuthTokenService.LookupToken(token.UnhashedToken)
@@ -102,7 +102,7 @@ func TestUserAuthToken(t *testing.T) {
 			token, err = ctx.getAuthTokenByID(token.Id)
 			token, err = ctx.getAuthTokenByID(token.Id)
 			So(err, ShouldBeNil)
 			So(err, ShouldBeNil)
 
 
-			now = func() time.Time {
+			getTime = func() time.Time {
 				return t.Add(time.Hour)
 				return t.Add(time.Hour)
 			}
 			}
 
 
@@ -116,7 +116,7 @@ func TestUserAuthToken(t *testing.T) {
 			So(err, ShouldBeNil)
 			So(err, ShouldBeNil)
 			token.UnhashedToken = unhashedToken
 			token.UnhashedToken = unhashedToken
 
 
-			So(token.RotatedAt, ShouldEqual, now().Unix())
+			So(token.RotatedAt, ShouldEqual, getTime().Unix())
 			So(token.ClientIp, ShouldEqual, "192.168.10.12")
 			So(token.ClientIp, ShouldEqual, "192.168.10.12")
 			So(token.UserAgent, ShouldEqual, "a new user agent")
 			So(token.UserAgent, ShouldEqual, "a new user agent")
 			So(token.AuthTokenSeen, ShouldBeFalse)
 			So(token.AuthTokenSeen, ShouldBeFalse)
@@ -129,7 +129,7 @@ func TestUserAuthToken(t *testing.T) {
 			So(err, ShouldBeNil)
 			So(err, ShouldBeNil)
 			So(lookedUp, ShouldNotBeNil)
 			So(lookedUp, ShouldNotBeNil)
 			So(lookedUp.AuthTokenSeen, ShouldBeTrue)
 			So(lookedUp.AuthTokenSeen, ShouldBeTrue)
-			So(lookedUp.SeenAt, ShouldEqual, now().Unix())
+			So(lookedUp.SeenAt, ShouldEqual, getTime().Unix())
 
 
 			lookedUp, err = userAuthTokenService.LookupToken(unhashedPrev)
 			lookedUp, err = userAuthTokenService.LookupToken(unhashedPrev)
 			So(err, ShouldBeNil)
 			So(err, ShouldBeNil)
@@ -137,7 +137,7 @@ func TestUserAuthToken(t *testing.T) {
 			So(lookedUp.Id, ShouldEqual, token.Id)
 			So(lookedUp.Id, ShouldEqual, token.Id)
 			So(lookedUp.AuthTokenSeen, ShouldBeTrue)
 			So(lookedUp.AuthTokenSeen, ShouldBeTrue)
 
 
-			now = func() time.Time {
+			getTime = func() time.Time {
 				return t.Add(time.Hour + (2 * time.Minute))
 				return t.Add(time.Hour + (2 * time.Minute))
 			}
 			}
 
 
@@ -170,7 +170,7 @@ func TestUserAuthToken(t *testing.T) {
 		})
 		})
 
 
 		Reset(func() {
 		Reset(func() {
-			now = time.Now
+			getTime = time.Now
 		})
 		})
 	})
 	})
 }
 }