MCPcopy Index your code
hub / github.com/dnote/dnote / TestGetUserByEmail

Function TestGetUserByEmail

pkg/server/app/users_test.go:82–109  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

80}
81
82func TestGetUserByEmail(t *testing.T) {
83 t.Run("success", func(t *testing.T) {
84 db := testutils.InitMemoryDB(t)
85
86 user := testutils.SetupUserData(db, "alice@example.com", "password123")
87
88 a := NewTest()
89 a.DB = db
90
91 foundUser, err := a.GetUserByEmail("alice@example.com")
92
93 assert.Equal(t, err, nil, "should not error")
94 assert.Equal(t, foundUser.Email.String, "alice@example.com", "email mismatch")
95 assert.Equal(t, foundUser.ID, user.ID, "user ID mismatch")
96 })
97
98 t.Run("not found", func(t *testing.T) {
99 db := testutils.InitMemoryDB(t)
100
101 a := NewTest()
102 a.DB = db
103
104 user, err := a.GetUserByEmail("nonexistent@example.com")
105
106 assert.Equal(t, err, ErrNotFound, "should return ErrNotFound")
107 assert.Equal(t, user, (*database.User)(nil), "user should be nil")
108 })
109}
110
111func TestGetAllUsers(t *testing.T) {
112 t.Run("success with multiple users", func(t *testing.T) {

Callers

nothing calls this directly

Calls 5

InitMemoryDBFunction · 0.92
SetupUserDataFunction · 0.92
EqualFunction · 0.92
NewTestFunction · 0.85
GetUserByEmailMethod · 0.80

Tested by

no test coverage detected