Skip to content

Commit

Permalink
Fix colangci-lint run
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobortolan committed Jan 18, 2024
1 parent 54b5c36 commit 4773436
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api_v2/services/user_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func PatchUserSettings(db *gorm.DB, user *model.User, req *protobuf.PatchUserSet
} else if errors.Is(err, gorm.ErrRecordNotFound) {
// no last change found, so we can just continue
} else {
diff := time.Now().Sub(lastChange.CreatedAt)
diff := time.Since(lastChange.CreatedAt)
if diff.Hours() < 24*30*3 {
return nil, e.WithStatus(http.StatusBadRequest, errors.New("preferred name can only be changed every 3 months"))
}
Expand Down
10 changes: 5 additions & 5 deletions api_v2/tests/notification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ func TestPostDeviceToken_AlreadyExists(t *testing.T) {
// Case device_token already exsits (e.g., submitted same token twice)
ctx := metadata.NewIncomingContext(context.Background(), md_student_loggedin)
req := &protobuf.PostDeviceTokenRequest{DeviceToken: "TestPostDeviceToken_AlreadyExists"}
_, _ = a.PostDeviceToken(ctx, req)
_, err := a.PostDeviceToken(ctx, req)
_, err = a.PostDeviceToken(ctx, req)
if status.Code(err) != codes.AlreadyExists {
t.Errorf("expected ALREAD_EXISTS, got %v", err)
}
Expand All @@ -120,11 +120,11 @@ func TestDeleteDeviceToken(t *testing.T) {
// Create device_token first
ctx := metadata.NewIncomingContext(context.Background(), md_student_loggedin)
req_post := &protobuf.PostDeviceTokenRequest{DeviceToken: "TestDeleteDeviceToken"}
_, err := a.PostDeviceToken(ctx, req_post)
_, _ = a.PostDeviceToken(ctx, req_post)

// Delete device_token
req := &protobuf.DeleteDeviceTokenRequest{DeviceToken: "TestDeleteDeviceToken"}
_, err = a.DeleteDeviceToken(ctx, req)
_, err := a.DeleteDeviceToken(ctx, req)
if status.Code(err) != codes.OK {
t.Errorf("expected OK, got %v", err)
}
Expand Down Expand Up @@ -161,12 +161,12 @@ func TestDeleteDeviceToken_Unauthenticated(t *testing.T) {
// Create device_token first
ctx := metadata.NewIncomingContext(context.Background(), md_student_loggedin)
req_post := &protobuf.PostDeviceTokenRequest{DeviceToken: "TestDeleteDeviceToken_Unauthenticated"}
_, err := a.PostDeviceToken(ctx, req_post)
_, _ = a.PostDeviceToken(ctx, req_post)

// Case invalid jwt
ctx = metadata.NewIncomingContext(context.Background(), md_invalid_jwt)
req := &protobuf.DeleteDeviceTokenRequest{DeviceToken: "TestDeleteDeviceToken_Unauthenticated"}
_, err = a.DeleteDeviceToken(ctx, req)
_, err := a.DeleteDeviceToken(ctx, req)
if status.Code(err) != codes.Unauthenticated {
t.Errorf("expected UNAUTHENTICATED, got %v", err)
}
Expand Down

0 comments on commit 4773436

Please sign in to comment.