Skip to content

Commit c91a991

Browse files
committed
Migrate delete user account tests to new test fixtures package
1 parent 8c09d03 commit c91a991

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

internal/api/handlers/auth/delete_user_account_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"allaboutapps.dev/aw/go-starter/internal/api/httperrors"
1010
"allaboutapps.dev/aw/go-starter/internal/models"
1111
"allaboutapps.dev/aw/go-starter/internal/test"
12+
"allaboutapps.dev/aw/go-starter/internal/test/fixtures"
1213
"github.com/labstack/echo/v4"
1314
"github.com/stretchr/testify/require"
1415
"github.com/volatiletech/null/v8"
@@ -50,13 +51,13 @@ func assertUserAndRelatedData(ctx context.Context, s *api.Server, t *testing.T,
5051
func TestDeleteUserAccount(t *testing.T) {
5152
test.WithTestServer(t, func(s *api.Server) {
5253
ctx := context.Background()
53-
fix := test.Fixtures()
54+
fix := fixtures.Fixtures()
5455

5556
// expect the user to have a app user profile and different kinds of tokens (access, refresh, push, password reset)
5657
assertUserAndRelatedData(ctx, s, t, fix.User1.ID, true)
5758

5859
payload := test.GenericPayload{
59-
"currentPassword": test.PlainTestUserPassword,
60+
"currentPassword": fixtures.PlainTestUserPassword,
6061
}
6162

6263
res := test.PerformRequest(t, s, "DELETE", "/api/v1/auth/account", payload, test.HeadersWithAuth(t, fix.User1AccessToken1.Token))
@@ -69,7 +70,7 @@ func TestDeleteUserAccount(t *testing.T) {
6970

7071
func TestDeleteUserAccountCurrentPasswordWrong(t *testing.T) {
7172
test.WithTestServer(t, func(s *api.Server) {
72-
fix := test.Fixtures()
73+
fix := fixtures.Fixtures()
7374

7475
payload := test.GenericPayload{
7576
"currentPassword": "wrongpassword",
@@ -82,7 +83,7 @@ func TestDeleteUserAccountCurrentPasswordWrong(t *testing.T) {
8283

8384
func TestDeleteUserAccountMissingCurrentPassword(t *testing.T) {
8485
test.WithTestServer(t, func(s *api.Server) {
85-
fix := test.Fixtures()
86+
fix := fixtures.Fixtures()
8687

8788
res := test.PerformRequest(t, s, "DELETE", "/api/v1/auth/account", nil, test.HeadersWithAuth(t, fix.User1AccessToken1.Token))
8889
require.Equal(t, http.StatusBadRequest, res.Result().StatusCode)
@@ -98,7 +99,7 @@ func TestDeleteUserAccountNoAuth(t *testing.T) {
9899

99100
func TestDeleteUserAccountUserNotActive(t *testing.T) {
100101
test.WithTestServer(t, func(s *api.Server) {
101-
fix := test.Fixtures()
102+
fix := fixtures.Fixtures()
102103
ctx := context.Background()
103104

104105
fix.User1.IsActive = false
@@ -116,7 +117,7 @@ func TestDeleteUserAccountUserNotActive(t *testing.T) {
116117

117118
func TestDeleteUserAccountUserNotLocal(t *testing.T) {
118119
test.WithTestServer(t, func(s *api.Server) {
119-
fix := test.Fixtures()
120+
fix := fixtures.Fixtures()
120121
ctx := context.Background()
121122

122123
fix.User1.Password = null.String{}

0 commit comments

Comments
 (0)