Skip to content

Commit

Permalink
updated some of the tests to use t.Parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
ganigeorgiev committed Jan 3, 2024
1 parent 0599955 commit 8f625da
Show file tree
Hide file tree
Showing 46 changed files with 374 additions and 0 deletions.
18 changes: 18 additions & 0 deletions apis/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
)

func TestAdminAuthWithPassword(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "empty data",
Expand Down Expand Up @@ -119,6 +121,8 @@ func TestAdminAuthWithPassword(t *testing.T) {
}

func TestAdminRequestPasswordReset(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "empty data",
Expand Down Expand Up @@ -188,6 +192,8 @@ func TestAdminRequestPasswordReset(t *testing.T) {
}

func TestAdminConfirmPasswordReset(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "empty data",
Expand Down Expand Up @@ -277,6 +283,8 @@ func TestAdminConfirmPasswordReset(t *testing.T) {
}

func TestAdminRefresh(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down Expand Up @@ -350,6 +358,8 @@ func TestAdminRefresh(t *testing.T) {
}

func TestAdminsList(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down Expand Up @@ -453,6 +463,8 @@ func TestAdminsList(t *testing.T) {
}

func TestAdminView(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down Expand Up @@ -508,6 +520,8 @@ func TestAdminView(t *testing.T) {
}

func TestAdminDelete(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down Expand Up @@ -603,6 +617,8 @@ func TestAdminDelete(t *testing.T) {
}

func TestAdminCreate(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized (while having at least 1 existing admin)",
Expand Down Expand Up @@ -757,6 +773,8 @@ func TestAdminCreate(t *testing.T) {
}

func TestAdminUpdate(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down
12 changes: 12 additions & 0 deletions apis/api_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
)

func TestNewApiErrorWithRawData(t *testing.T) {
t.Parallel()

e := apis.NewApiError(
300,
"message_test",
Expand All @@ -33,6 +35,8 @@ func TestNewApiErrorWithRawData(t *testing.T) {
}

func TestNewApiErrorWithValidationData(t *testing.T) {
t.Parallel()

e := apis.NewApiError(
300,
"message_test",
Expand Down Expand Up @@ -66,6 +70,8 @@ func TestNewApiErrorWithValidationData(t *testing.T) {
}

func TestNewNotFoundError(t *testing.T) {
t.Parallel()

scenarios := []struct {
message string
data any
Expand All @@ -87,6 +93,8 @@ func TestNewNotFoundError(t *testing.T) {
}

func TestNewBadRequestError(t *testing.T) {
t.Parallel()

scenarios := []struct {
message string
data any
Expand All @@ -108,6 +116,8 @@ func TestNewBadRequestError(t *testing.T) {
}

func TestNewForbiddenError(t *testing.T) {
t.Parallel()

scenarios := []struct {
message string
data any
Expand All @@ -129,6 +139,8 @@ func TestNewForbiddenError(t *testing.T) {
}

func TestNewUnauthorizedError(t *testing.T) {
t.Parallel()

scenarios := []struct {
message string
data any
Expand Down
12 changes: 12 additions & 0 deletions apis/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
)

func TestBackupsList(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down Expand Up @@ -84,6 +86,8 @@ func TestBackupsList(t *testing.T) {
}

func TestBackupsCreate(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down Expand Up @@ -198,6 +202,8 @@ func TestBackupsCreate(t *testing.T) {
}

func TestBackupsUpload(t *testing.T) {
t.Parallel()

// create dummy form data bodies
type body struct {
buffer io.Reader
Expand Down Expand Up @@ -330,6 +336,8 @@ func TestBackupsUpload(t *testing.T) {
}

func TestBackupsDownload(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down Expand Up @@ -485,6 +493,8 @@ func TestBackupsDownload(t *testing.T) {
}

func TestBackupsDelete(t *testing.T) {
t.Parallel()

noTestBackupFilesChanges := func(t *testing.T, app *tests.TestApp) {
files, err := getBackupFiles(app)
if err != nil {
Expand Down Expand Up @@ -645,6 +655,8 @@ func TestBackupsDelete(t *testing.T) {
}

func TestBackupsRestore(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down
10 changes: 10 additions & 0 deletions apis/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
)

func Test404(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Method: http.MethodGet,
Expand Down Expand Up @@ -53,6 +55,8 @@ func Test404(t *testing.T) {
}

func TestCustomRoutesAndErrorsHandling(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "custom route",
Expand Down Expand Up @@ -142,6 +146,8 @@ func TestCustomRoutesAndErrorsHandling(t *testing.T) {
}

func TestRemoveTrailingSlashMiddleware(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "non /api/* route (exact match)",
Expand Down Expand Up @@ -215,6 +221,8 @@ func TestRemoveTrailingSlashMiddleware(t *testing.T) {
}

func TestEagerRequestInfoCache(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "custom non-api group route",
Expand Down Expand Up @@ -316,6 +324,8 @@ func TestEagerRequestInfoCache(t *testing.T) {
}

func TestErrorHandler(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "apis.ApiError",
Expand Down
12 changes: 12 additions & 0 deletions apis/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
)

func TestCollectionsList(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down Expand Up @@ -125,6 +127,8 @@ func TestCollectionsList(t *testing.T) {
}

func TestCollectionView(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down Expand Up @@ -193,6 +197,8 @@ func TestCollectionView(t *testing.T) {
}

func TestCollectionDelete(t *testing.T) {
t.Parallel()

ensureDeletedFiles := func(app *tests.TestApp, collectionId string) {
storageDir := filepath.Join(app.DataDir(), "storage", collectionId)

Expand Down Expand Up @@ -338,6 +344,8 @@ func TestCollectionDelete(t *testing.T) {
}

func TestCollectionCreate(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down Expand Up @@ -715,6 +723,8 @@ func TestCollectionCreate(t *testing.T) {
}

func TestCollectionUpdate(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down Expand Up @@ -1082,6 +1092,8 @@ func TestCollectionUpdate(t *testing.T) {
}

func TestCollectionsImport(t *testing.T) {
t.Parallel()

totalCollections := 11

scenarios := []tests.ApiScenario{
Expand Down
6 changes: 6 additions & 0 deletions apis/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
)

func TestFileToken(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down Expand Up @@ -92,6 +94,8 @@ func TestFileToken(t *testing.T) {
}

func TestFileDownload(t *testing.T) {
t.Parallel()

_, currentFile, _, _ := runtime.Caller(0)
dataDirRelPath := "../tests/data/"

Expand Down Expand Up @@ -391,6 +395,8 @@ func TestFileDownload(t *testing.T) {
}

func TestConcurrentThumbsGeneration(t *testing.T) {
t.Parallel()

app, err := tests.NewTestApp()
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 2 additions & 0 deletions apis/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
)

func TestHealthAPI(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "health status returns 200",
Expand Down
6 changes: 6 additions & 0 deletions apis/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
)

func TestLogsList(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down Expand Up @@ -78,6 +80,8 @@ func TestLogsList(t *testing.T) {
}

func TestLogView(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down Expand Up @@ -136,6 +140,8 @@ func TestLogView(t *testing.T) {
}

func TestLogsStats(t *testing.T) {
t.Parallel()

scenarios := []tests.ApiScenario{
{
Name: "unauthorized",
Expand Down
Loading

0 comments on commit 8f625da

Please sign in to comment.