From 4cc0f9cc832bef447bb6ea9f9011e895f759dd0e Mon Sep 17 00:00:00 2001 From: Kyle Sanderson Date: Sat, 23 Nov 2024 06:16:09 -0800 Subject: [PATCH] feat(tests): add Parallelization where possible (#1823) * feat(tests): add Parallelization where possible --- internal/action/exec_test.go | 2 ++ internal/config/config_test.go | 1 + internal/domain/client_test.go | 1 + internal/domain/filter_test.go | 14 ++++++++++++++ internal/domain/indexer_test.go | 4 ++++ internal/domain/macros_test.go | 1 + internal/domain/rejections_test.go | 2 ++ internal/domain/releasetags_test.go | 3 +++ internal/feed/rss_test.go | 2 ++ internal/http/auth_test.go | 4 ++++ internal/indexer/definition_test.go | 1 + internal/indexer/indexer_test.go | 1 + internal/logger/sanitize_test.go | 1 + internal/notification/message_builder_test.go | 6 ++++-- pkg/argon2id/argon2id_test.go | 5 +++++ pkg/sanitize/sanitize_test.go | 1 + pkg/version/version_test.go | 2 ++ pkg/wildcard/match_test.go | 4 ++++ 18 files changed, 53 insertions(+), 2 deletions(-) diff --git a/internal/action/exec_test.go b/internal/action/exec_test.go index 994c6cf..239134b 100644 --- a/internal/action/exec_test.go +++ b/internal/action/exec_test.go @@ -14,6 +14,7 @@ import ( ) func Test_service_parseMacros(t *testing.T) { + t.Parallel() type args struct { release domain.Release action *domain.Action @@ -67,6 +68,7 @@ func Test_service_parseMacros(t *testing.T) { } func Test_service_execCmd(t *testing.T) { + t.Parallel() type args struct { release domain.Release action *domain.Action diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 1e6f65c..57ee7b5 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -13,6 +13,7 @@ import ( ) func TestAppConfig_processLines(t *testing.T) { + t.Parallel() type fields struct { Config *domain.Config m *sync.Mutex diff --git a/internal/domain/client_test.go b/internal/domain/client_test.go index 25e362d..5556372 100644 --- a/internal/domain/client_test.go +++ b/internal/domain/client_test.go @@ -10,6 +10,7 @@ import ( ) func TestDownloadClient_qbitBuildLegacyHost(t *testing.T) { + t.Parallel() type fields struct { ID int32 Name string diff --git a/internal/domain/filter_test.go b/internal/domain/filter_test.go index fb00b65..a859e34 100644 --- a/internal/domain/filter_test.go +++ b/internal/domain/filter_test.go @@ -10,6 +10,7 @@ import ( ) func TestFilter_CheckFilter(t *testing.T) { + t.Parallel() type args struct { filter Filter rejectionReasons *RejectionReasons @@ -1443,6 +1444,7 @@ func TestFilter_CheckFilter(t *testing.T) { } func TestFilter_CheckFilter1(t *testing.T) { + t.Parallel() type fields Filter type args struct { r *Release @@ -2069,6 +2071,7 @@ func TestFilter_CheckFilter1(t *testing.T) { } func Test_containsMatch(t *testing.T) { + t.Parallel() type args struct { tags []string filters []string @@ -2092,6 +2095,7 @@ func Test_containsMatch(t *testing.T) { } func Test_containsAllMatch(t *testing.T) { + t.Parallel() type args struct { tags []string filters []string @@ -2117,6 +2121,7 @@ func Test_containsAllMatch(t *testing.T) { } func Test_contains(t *testing.T) { + t.Parallel() type args struct { tag string filter string @@ -2144,6 +2149,7 @@ func Test_contains(t *testing.T) { } func Test_containsSlice(t *testing.T) { + t.Parallel() type args struct { tag string filters []string @@ -2166,6 +2172,7 @@ func Test_containsSlice(t *testing.T) { } func Test_containsAny(t *testing.T) { + t.Parallel() type args struct { tags []string filter string @@ -2187,6 +2194,7 @@ func Test_containsAny(t *testing.T) { } func Test_containsAll(t *testing.T) { + t.Parallel() type args struct { tags []string filter string @@ -2212,6 +2220,7 @@ func Test_containsAll(t *testing.T) { } func Test_sliceContainsSlice(t *testing.T) { + t.Parallel() type args struct { tags []string filters []string @@ -2235,6 +2244,7 @@ func Test_sliceContainsSlice(t *testing.T) { } func Test_containsIntStrings(t *testing.T) { + t.Parallel() type args struct { value int filterList string @@ -2262,6 +2272,7 @@ func Test_containsIntStrings(t *testing.T) { } func Test_matchRegex(t *testing.T) { + t.Parallel() type args struct { tag string filter string @@ -2289,6 +2300,7 @@ func Test_matchRegex(t *testing.T) { } func Test_validation(t *testing.T) { + t.Parallel() tests := []struct { name string filter Filter @@ -2308,6 +2320,7 @@ func Test_validation(t *testing.T) { } func Test_checkSizeFilter(t *testing.T) { + t.Parallel() tests := []struct { name string filter Filter @@ -2338,6 +2351,7 @@ func Test_checkSizeFilter(t *testing.T) { } func Test_containsFuzzy(t *testing.T) { + t.Parallel() type args struct { tag string filter string diff --git a/internal/domain/indexer_test.go b/internal/domain/indexer_test.go index 3636f55..af43d2b 100644 --- a/internal/domain/indexer_test.go +++ b/internal/domain/indexer_test.go @@ -10,6 +10,7 @@ import ( ) func TestIndexerIRCParseMatch_ParseUrls(t *testing.T) { + t.Parallel() type fields struct { TorrentURL string TorrentName string @@ -165,6 +166,7 @@ func TestIndexerIRCParseMatch_ParseUrls(t *testing.T) { } func TestIndexerIRCParseMatch_ParseTorrentName(t *testing.T) { + t.Parallel() type fields struct { TorrentURL string TorrentName string @@ -238,6 +240,7 @@ func TestIndexerIRCParseMatch_ParseTorrentName(t *testing.T) { } func TestIRCParserGazelleGames_Parse(t *testing.T) { + t.Parallel() type args struct { rls *Release vars map[string]string @@ -316,6 +319,7 @@ func TestIRCParserGazelleGames_Parse(t *testing.T) { } func TestIRCParserOrpheus_Parse(t *testing.T) { + t.Parallel() type args struct { rls *Release vars map[string]string diff --git a/internal/domain/macros_test.go b/internal/domain/macros_test.go index 4b6ffb6..08d0f27 100644 --- a/internal/domain/macros_test.go +++ b/internal/domain/macros_test.go @@ -12,6 +12,7 @@ import ( ) func TestMacros_Parse(t *testing.T) { + t.Parallel() currentTime := time.Now() type fields struct { diff --git a/internal/domain/rejections_test.go b/internal/domain/rejections_test.go index b68be56..8e77752 100644 --- a/internal/domain/rejections_test.go +++ b/internal/domain/rejections_test.go @@ -10,6 +10,7 @@ import ( ) func TestRejectionReasons_String(t *testing.T) { + t.Parallel() type fields struct { data []Rejection } @@ -55,6 +56,7 @@ func TestRejectionReasons_String(t *testing.T) { } func TestRejectionReasons_StringTruncated(t *testing.T) { + t.Parallel() type fields struct { data []Rejection } diff --git a/internal/domain/releasetags_test.go b/internal/domain/releasetags_test.go index 2cfecc1..36371e7 100644 --- a/internal/domain/releasetags_test.go +++ b/internal/domain/releasetags_test.go @@ -10,6 +10,7 @@ import ( ) func TestParseReleaseTags(t *testing.T) { + t.Parallel() type args struct { tags []string } @@ -29,6 +30,7 @@ func TestParseReleaseTags(t *testing.T) { } func TestParseReleaseTagString(t *testing.T) { + t.Parallel() type args struct { tags string } @@ -64,6 +66,7 @@ func TestParseReleaseTagString(t *testing.T) { } func Test_cleanReleaseTags(t *testing.T) { + t.Parallel() type args struct { tagString string } diff --git a/internal/feed/rss_test.go b/internal/feed/rss_test.go index d055564..45cac16 100644 --- a/internal/feed/rss_test.go +++ b/internal/feed/rss_test.go @@ -17,6 +17,7 @@ import ( ) func TestRSSJob_processItem(t *testing.T) { + t.Parallel() now := time.Now() nowMinusTime := time.Now().Add(time.Duration(-3000) * time.Second) @@ -234,6 +235,7 @@ func TestRSSJob_processItem(t *testing.T) { } func Test_isMaxAge(t *testing.T) { + t.Parallel() type args struct { maxAge int item time.Time diff --git a/internal/http/auth_test.go b/internal/http/auth_test.go index 03bfa36..952c3bd 100644 --- a/internal/http/auth_test.go +++ b/internal/http/auth_test.go @@ -92,6 +92,7 @@ func setupAuthHandler() { } func TestAuthHandlerLogin(t *testing.T) { + t.Parallel() logger := zerolog.Nop() encoder := encoder{} cookieStore := sessions.NewCookieStore([]byte("test")) @@ -153,6 +154,7 @@ func TestAuthHandlerLogin(t *testing.T) { } func TestAuthHandlerValidateOK(t *testing.T) { + t.Parallel() logger := zerolog.Nop() encoder := encoder{} cookieStore := sessions.NewCookieStore([]byte("test")) @@ -224,6 +226,7 @@ func TestAuthHandlerValidateOK(t *testing.T) { } func TestAuthHandlerValidateBad(t *testing.T) { + t.Parallel() logger := zerolog.Nop() encoder := encoder{} cookieStore := sessions.NewCookieStore([]byte("test")) @@ -271,6 +274,7 @@ func TestAuthHandlerValidateBad(t *testing.T) { } func TestAuthHandlerLoginBad(t *testing.T) { + t.Parallel() logger := zerolog.Nop() encoder := encoder{} cookieStore := sessions.NewCookieStore([]byte("test")) diff --git a/internal/indexer/definition_test.go b/internal/indexer/definition_test.go index af40371..60146fc 100644 --- a/internal/indexer/definition_test.go +++ b/internal/indexer/definition_test.go @@ -11,6 +11,7 @@ import ( ) func TestYamlExpectations(t *testing.T) { + t.Parallel() s := &service{definitions: map[string]domain.IndexerDefinition{}} err := s.LoadIndexerDefinitions() diff --git a/internal/indexer/indexer_test.go b/internal/indexer/indexer_test.go index e5c9f3d..8c6012e 100644 --- a/internal/indexer/indexer_test.go +++ b/internal/indexer/indexer_test.go @@ -14,6 +14,7 @@ import ( ) func TestIndexersParseAndFilter(t *testing.T) { + t.Parallel() type fields struct { identifier string identifierExternal string diff --git a/internal/logger/sanitize_test.go b/internal/logger/sanitize_test.go index 695ce59..cd34736 100644 --- a/internal/logger/sanitize_test.go +++ b/internal/logger/sanitize_test.go @@ -11,6 +11,7 @@ import ( ) func TestSanitizeLogFile(t *testing.T) { + t.Parallel() testCases := []struct { name string input string diff --git a/internal/notification/message_builder_test.go b/internal/notification/message_builder_test.go index 4574397..a7e165d 100644 --- a/internal/notification/message_builder_test.go +++ b/internal/notification/message_builder_test.go @@ -4,13 +4,15 @@ package notification import ( - "github.com/autobrr/autobrr/internal/domain" - "github.com/stretchr/testify/assert" "testing" "time" + + "github.com/autobrr/autobrr/internal/domain" + "github.com/stretchr/testify/assert" ) func TestNotificationBuilderPlainText_BuildBody(t *testing.T) { + t.Parallel() type args struct { payload domain.NotificationPayload } diff --git a/pkg/argon2id/argon2id_test.go b/pkg/argon2id/argon2id_test.go index ba4c35e..764d92b 100644 --- a/pkg/argon2id/argon2id_test.go +++ b/pkg/argon2id/argon2id_test.go @@ -10,6 +10,7 @@ import ( ) func TestCreateHash(t *testing.T) { + t.Parallel() hashRX, err := regexp.Compile(`^\$argon2id\$v=19\$m=65536,t=1,p=2\$[A-Za-z0-9+/]{22}\$[A-Za-z0-9+/]{43}$`) if err != nil { t.Fatal(err) @@ -35,6 +36,7 @@ func TestCreateHash(t *testing.T) { } func TestComparePasswordAndHash(t *testing.T) { + t.Parallel() hash, err := CreateHash("pa$$word", DefaultParams) if err != nil { t.Fatal(err) @@ -60,6 +62,7 @@ func TestComparePasswordAndHash(t *testing.T) { } func TestDecodeHash(t *testing.T) { + t.Parallel() hash, err := CreateHash("pa$$word", DefaultParams) if err != nil { t.Fatal(err) @@ -75,6 +78,7 @@ func TestDecodeHash(t *testing.T) { } func TestCheckHash(t *testing.T) { + t.Parallel() hash, err := CreateHash("pa$$word", DefaultParams) if err != nil { t.Fatal(err) @@ -93,6 +97,7 @@ func TestCheckHash(t *testing.T) { } func TestStrictDecoding(t *testing.T) { + t.Parallel() // "bug" valid hash: $argon2id$v=19$m=65536,t=1,p=2$UDk0zEuIzbt0x3bwkf8Bgw$ihSfHWUJpTgDvNWiojrgcN4E0pJdUVmqCEdRZesx9tE ok, _, err := CheckHash("bug", "$argon2id$v=19$m=65536,t=1,p=2$UDk0zEuIzbt0x3bwkf8Bgw$ihSfHWUJpTgDvNWiojrgcN4E0pJdUVmqCEdRZesx9tE") if err != nil { diff --git a/pkg/sanitize/sanitize_test.go b/pkg/sanitize/sanitize_test.go index 8e42aac..c135acb 100644 --- a/pkg/sanitize/sanitize_test.go +++ b/pkg/sanitize/sanitize_test.go @@ -5,6 +5,7 @@ import ( ) func TestStringAndFilterString(t *testing.T) { + t.Parallel() tests := []struct { name string input string diff --git a/pkg/version/version_test.go b/pkg/version/version_test.go index 84083dc..9be2fbf 100644 --- a/pkg/version/version_test.go +++ b/pkg/version/version_test.go @@ -10,6 +10,7 @@ import ( ) func TestGitHubReleaseChecker_checkNewVersion(t *testing.T) { + t.Parallel() type fields struct { Repo string } @@ -112,6 +113,7 @@ func TestGitHubReleaseChecker_checkNewVersion(t *testing.T) { } func Test_isDevelop(t *testing.T) { + t.Parallel() tests := []struct { name string version string diff --git a/pkg/wildcard/match_test.go b/pkg/wildcard/match_test.go index 021a679..802839a 100644 --- a/pkg/wildcard/match_test.go +++ b/pkg/wildcard/match_test.go @@ -15,6 +15,7 @@ import ( // A '*' in a provided string will not result in matching the strings before and after the '*' of the string provided. // Sample usage: In resource matching for bucket policy validation. func TestMatch(t *testing.T) { + t.Parallel() tests := []struct { pattern string text string @@ -151,6 +152,7 @@ func TestMatch(t *testing.T) { } func TestMatchSimple(t *testing.T) { + t.Parallel() tests := []struct { pattern string name string @@ -183,6 +185,7 @@ func TestMatchSimple(t *testing.T) { } func TestMatchSliceSimple(t *testing.T) { + t.Parallel() tests := []struct { patterns []string name string @@ -209,6 +212,7 @@ func TestMatchSliceSimple(t *testing.T) { } func TestMatchSlice(t *testing.T) { + t.Parallel() tests := []struct { patterns []string name string