Skip to content

Commit

Permalink
Use UTC time in test
Browse files Browse the repository at this point in the history
Signed-off-by: bcmmbaga <[email protected]>
  • Loading branch information
bcmmbaga committed Nov 21, 2024
1 parent 0ee56e1 commit 82746d9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions management/server/sql_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ func TestSqlite_SavePeer(t *testing.T) {
IP: net.IP{127, 0, 0, 1},
Meta: nbpeer.PeerSystemMeta{Hostname: "testingpeer"},
Name: "peer name",
Status: &nbpeer.PeerStatus{Connected: true, LastSeen: time.Now().Local()},
Status: &nbpeer.PeerStatus{Connected: true, LastSeen: time.Now().UTC()},
}
ctx := context.Background()
err = store.SavePeer(ctx, LockingStrengthUpdate, account.Id, peer)
Expand Down Expand Up @@ -422,7 +422,7 @@ func TestSqlite_SavePeer(t *testing.T) {
assert.Equal(t, updatedPeer.Status.Connected, actual.Status.Connected)
assert.Equal(t, updatedPeer.Status.LoginExpired, actual.Status.LoginExpired)
assert.Equal(t, updatedPeer.Status.RequiresApproval, actual.Status.RequiresApproval)
assert.WithinDurationf(t, updatedPeer.Status.LastSeen, actual.Status.LastSeen, time.Millisecond, "LastSeen should be equal")
assert.WithinDurationf(t, updatedPeer.Status.LastSeen, actual.Status.LastSeen.UTC(), time.Millisecond, "LastSeen should be equal")
}

func TestSqlite_SavePeerStatus(t *testing.T) {
Expand All @@ -434,7 +434,7 @@ func TestSqlite_SavePeerStatus(t *testing.T) {
require.NoError(t, err)

// save status of non-existing peer
newStatus := nbpeer.PeerStatus{Connected: false, LastSeen: time.Now().Local()}
newStatus := nbpeer.PeerStatus{Connected: false, LastSeen: time.Now().UTC()}
err = store.SavePeerStatus(context.Background(), LockingStrengthUpdate, account.Id, "non-existing-peer", newStatus)
assert.Error(t, err)
parsedErr, ok := status.FromError(err)
Expand All @@ -448,7 +448,7 @@ func TestSqlite_SavePeerStatus(t *testing.T) {
IP: net.IP{127, 0, 0, 1},
Meta: nbpeer.PeerSystemMeta{},
Name: "peer name",
Status: &nbpeer.PeerStatus{Connected: true, LastSeen: time.Now().Local()},
Status: &nbpeer.PeerStatus{Connected: true, LastSeen: time.Now().UTC()},
}

err = store.SaveAccount(context.Background(), account)
Expand All @@ -464,7 +464,7 @@ func TestSqlite_SavePeerStatus(t *testing.T) {
assert.Equal(t, newStatus.Connected, actual.Connected)
assert.Equal(t, newStatus.LoginExpired, actual.LoginExpired)
assert.Equal(t, newStatus.RequiresApproval, actual.RequiresApproval)
assert.WithinDurationf(t, newStatus.LastSeen, actual.LastSeen, time.Millisecond, "LastSeen should be equal")
assert.WithinDurationf(t, newStatus.LastSeen, actual.LastSeen.UTC(), time.Millisecond, "LastSeen should be equal")

newStatus.Connected = true

Expand All @@ -478,7 +478,7 @@ func TestSqlite_SavePeerStatus(t *testing.T) {
assert.Equal(t, newStatus.Connected, actual.Connected)
assert.Equal(t, newStatus.LoginExpired, actual.LoginExpired)
assert.Equal(t, newStatus.RequiresApproval, actual.RequiresApproval)
assert.WithinDurationf(t, newStatus.LastSeen, actual.LastSeen, time.Millisecond, "LastSeen should be equal")
assert.WithinDurationf(t, newStatus.LastSeen, actual.LastSeen.UTC(), time.Millisecond, "LastSeen should be equal")
}

func TestSqlite_SavePeerLocation(t *testing.T) {
Expand Down

0 comments on commit 82746d9

Please sign in to comment.