-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
23 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,7 @@ func TestHighlights(t *testing.T) { | |
|
||
mustReturnStatus(response, fiber.StatusOK, t) | ||
|
||
assertHighlights(app, t, adminCookie, adminUser.Username, 1) | ||
assertHighlights(app, t, adminCookie, 1) | ||
|
||
response, err = highlight(adminCookie, app, "john-doe-test-epub", fiber.MethodDelete, t) | ||
if err != nil { | ||
|
@@ -84,7 +84,7 @@ func TestHighlights(t *testing.T) { | |
|
||
mustReturnStatus(response, fiber.StatusOK, t) | ||
|
||
assertHighlights(app, t, adminCookie, adminUser.Username, 0) | ||
assertHighlights(app, t, adminCookie, 0) | ||
}) | ||
|
||
t.Run("Deleting a document also removes it from the highlights of all users", func(t *testing.T) { | ||
|
@@ -105,7 +105,7 @@ func TestHighlights(t *testing.T) { | |
|
||
mustReturnStatus(response, fiber.StatusOK, t) | ||
|
||
assertHighlights(app, t, regularUserCookie, regularUser.Username, 1) | ||
assertHighlights(app, t, regularUserCookie, 1) | ||
|
||
adminCookie, err = login(app, "[email protected]", "admin", t) | ||
if err != nil { | ||
|
@@ -122,7 +122,7 @@ func TestHighlights(t *testing.T) { | |
if total != 0 { | ||
t.Errorf("Expected no highlights in DB for user, got %d", total) | ||
} | ||
assertHighlights(app, t, adminCookie, regularUser.Username, 0) | ||
assertHighlights(app, t, adminCookie, 0) | ||
}) | ||
|
||
t.Run("Deleting a user also remove his/her highlights", func(t *testing.T) { | ||
|
@@ -143,7 +143,7 @@ func TestHighlights(t *testing.T) { | |
|
||
mustReturnStatus(response, fiber.StatusOK, t) | ||
|
||
assertHighlights(app, t, regularUserCookie, regularUser.Username, 1) | ||
assertHighlights(app, t, regularUserCookie, 1) | ||
|
||
adminCookie, err = login(app, "[email protected]", "admin", t) | ||
if err != nil { | ||
|
@@ -160,13 +160,12 @@ func TestHighlights(t *testing.T) { | |
if total != 0 { | ||
t.Errorf("Expected no highlights in DB for deleted user, got %d", total) | ||
} | ||
assertNoHighlights(app, t, adminCookie, regularUser.Username) | ||
}) | ||
} | ||
|
||
func highlight(cookie *http.Cookie, app *fiber.App, slug string, method string, t *testing.T) (*http.Response, error) { | ||
t.Helper() | ||
req, err := http.NewRequest(method, fmt.Sprintf("/documents/%s/highlight", slug), nil) | ||
req, err := http.NewRequest(method, fmt.Sprintf("/highlights/%s", slug), nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -176,10 +175,10 @@ func highlight(cookie *http.Cookie, app *fiber.App, slug string, method string, | |
return app.Test(req) | ||
} | ||
|
||
func assertHighlights(app *fiber.App, t *testing.T, cookie *http.Cookie, username string, expectedResults int) { | ||
func assertHighlights(app *fiber.App, t *testing.T, cookie *http.Cookie, expectedResults int) { | ||
t.Helper() | ||
|
||
req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("/en/highlights/%s", username), nil) | ||
req, err := http.NewRequest(http.MethodGet, "/en/highlights", nil) | ||
req.AddCookie(cookie) | ||
if err != nil { | ||
t.Fatalf("Unexpected error: %v", err.Error()) | ||
|
@@ -202,10 +201,10 @@ func assertHighlights(app *fiber.App, t *testing.T, cookie *http.Cookie, usernam | |
} | ||
} | ||
|
||
func assertNoHighlights(app *fiber.App, t *testing.T, cookie *http.Cookie, username string) { | ||
func assertNoHighlights(app *fiber.App, t *testing.T, cookie *http.Cookie) { | ||
t.Helper() | ||
|
||
req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("/en/highlights/%s", username), nil) | ||
req, err := http.NewRequest(http.MethodGet, "/en/highlights", nil) | ||
req.AddCookie(cookie) | ||
if err != nil { | ||
t.Fatalf("Unexpected error: %v", err.Error()) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters