feat(observabillity): #153 instrument sqlx
This commit was merged in pull request #160.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package test_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"spend-sparrow/internal/db"
|
||||
"spend-sparrow/internal/service"
|
||||
"spend-sparrow/internal/types"
|
||||
@@ -36,7 +37,7 @@ func TestSignUp(t *testing.T) {
|
||||
|
||||
underTest := service.NewAuth(mockAuthDb, mockRandom, mockClock, mockMail, &settings)
|
||||
|
||||
_, err := underTest.SignUp("invalid email address", "SomeStrongPassword123!")
|
||||
_, err := underTest.SignUp(context.Background(), "invalid email address", "SomeStrongPassword123!")
|
||||
|
||||
assert.Equal(t, service.ErrInvalidEmail, err)
|
||||
})
|
||||
@@ -58,7 +59,7 @@ func TestSignUp(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, password := range weakPasswords {
|
||||
_, err := underTest.SignUp("some@valid.email", password)
|
||||
_, err := underTest.SignUp(context.Background(), "some@valid.email", password)
|
||||
assert.Equal(t, service.ErrInvalidPassword, err)
|
||||
}
|
||||
})
|
||||
@@ -81,10 +82,10 @@ func TestSignUp(t *testing.T) {
|
||||
mockRandom.EXPECT().UUID().Return(userId, nil)
|
||||
mockRandom.EXPECT().Bytes(16).Return(salt, nil)
|
||||
mockClock.EXPECT().Now().Return(createTime)
|
||||
mockAuthDb.EXPECT().InsertUser(expected).Return(nil)
|
||||
mockAuthDb.EXPECT().InsertUser(context.Background(), expected).Return(nil)
|
||||
|
||||
underTest := service.NewAuth(mockAuthDb, mockRandom, mockClock, mockMail, &settings)
|
||||
actual, err := underTest.SignUp(email, password)
|
||||
actual, err := underTest.SignUp(context.Background(), email, password)
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -109,11 +110,11 @@ func TestSignUp(t *testing.T) {
|
||||
mockRandom.EXPECT().Bytes(16).Return(salt, nil)
|
||||
mockClock.EXPECT().Now().Return(createTime)
|
||||
|
||||
mockAuthDb.EXPECT().InsertUser(user).Return(db.ErrAlreadyExists)
|
||||
mockAuthDb.EXPECT().InsertUser(context.Background(), user).Return(db.ErrAlreadyExists)
|
||||
|
||||
underTest := service.NewAuth(mockAuthDb, mockRandom, mockClock, mockMail, &settings)
|
||||
|
||||
_, err := underTest.SignUp(user.Email, password)
|
||||
_, err := underTest.SignUp(context.Background(), user.Email, password)
|
||||
assert.Equal(t, service.ErrAccountExists, err)
|
||||
})
|
||||
}
|
||||
@@ -140,7 +141,7 @@ func TestSendVerificationMail(t *testing.T) {
|
||||
mockClock := mocks.NewMockClock(t)
|
||||
mockMail := mocks.NewMockMail(t)
|
||||
|
||||
mockAuthDb.EXPECT().GetTokensByUserIdAndType(userId, types.TokenTypeEmailVerify).Return(tokens, nil)
|
||||
mockAuthDb.EXPECT().GetTokensByUserIdAndType(context.Background(), userId, types.TokenTypeEmailVerify).Return(tokens, nil)
|
||||
|
||||
mockMail.EXPECT().SendMail(email, "Welcome to spend-sparrow", mock.MatchedBy(func(message string) bool {
|
||||
return strings.Contains(message, token.Token)
|
||||
@@ -148,6 +149,6 @@ func TestSendVerificationMail(t *testing.T) {
|
||||
|
||||
underTest := service.NewAuth(mockAuthDb, mockRandom, mockClock, mockMail, &settings)
|
||||
|
||||
underTest.SendVerificationMail(userId, email)
|
||||
underTest.SendVerificationMail(context.Background(), userId, email)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user