test: verify GetUserByID rejects disabled users and returns user with error

This commit is contained in:
kolaente 2026-03-23 12:27:47 +01:00 committed by kolaente
parent 8b614a4cb3
commit 525f5ee407
1 changed files with 25 additions and 0 deletions

View File

@ -623,3 +623,28 @@ func TestConfirmDeletion(t *testing.T) {
})
})
}
func TestGetUserByID_DisabledUser(t *testing.T) {
db.LoadAndAssertFixtures(t)
s := db.NewSession()
defer s.Close()
// user17 is disabled (status=2)
u, err := GetUserByID(s, 17)
require.Error(t, err)
assert.True(t, IsErrAccountDisabled(err), "GetUserByID should return ErrAccountDisabled, got: %v", err)
// User should still be returned alongside the error
assert.NotNil(t, u)
assert.Equal(t, int64(17), u.ID)
}
func TestGetUserByID_ActiveUser(t *testing.T) {
db.LoadAndAssertFixtures(t)
s := db.NewSession()
defer s.Close()
// user1 is active
u, err := GetUserByID(s, 1)
require.NoError(t, err)
assert.Equal(t, int64(1), u.ID)
}