diff --git a/.golangci.yml b/.golangci.yml index 24ba97e..4ef3418 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -15,7 +15,6 @@ linters: - interfacer - lll - maligned - - paralleltest - scopelint - testpackage - thelper diff --git a/cmd/cider/main_test.go b/cmd/cider/main_test.go index faabcf4..3e0eb91 100644 --- a/cmd/cider/main_test.go +++ b/cmd/cider/main_test.go @@ -27,39 +27,51 @@ import ( ) func TestVersion(t *testing.T) { - for name, tt := range map[string]struct { + t.Parallel() + + testCases := []struct { + name string version, commit, date, builtBy string out string }{ - "all empty": { - out: "", + { + name: "all empty", + out: "", }, - "complete": { + { + name: "complete", version: "1.2.3", date: "12/12/12", commit: "aaaa", builtBy: "me", out: "1.2.3\ncommit: aaaa\nbuilt at: 12/12/12\nbuilt by: me", }, - "only version": { + { + name: "only version", version: "1.2.3", out: "1.2.3", }, - "version and date": { + { + name: "version and date", version: "1.2.3", date: "12/12/12", out: "1.2.3\nbuilt at: 12/12/12", }, - "version, date, built by": { + { + name: "version, date, built by", version: "1.2.3", date: "12/12/12", builtBy: "me", out: "1.2.3\nbuilt at: 12/12/12\nbuilt by: me", }, - } { + } + + for _, tt := range testCases { tt := tt - t.Run(name, func(t *testing.T) { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + assert.Equal(t, tt.out+licenseDisclaimer, buildVersion(tt.version, tt.commit, tt.date, tt.builtBy)) }) } diff --git a/internal/clicommand/check_test.go b/internal/clicommand/check_test.go index b879eed..f013921 100644 --- a/internal/clicommand/check_test.go +++ b/internal/clicommand/check_test.go @@ -30,6 +30,8 @@ import ( ) func TestCheckCmd(t *testing.T) { + t.Parallel() + var cmd = newCheckCmd() var path = filepath.Join(t.TempDir(), "foo.yaml") diff --git a/internal/clicommand/completions_test.go b/internal/clicommand/completions_test.go index a2e1ca3..080406a 100644 --- a/internal/clicommand/completions_test.go +++ b/internal/clicommand/completions_test.go @@ -27,6 +27,8 @@ import ( ) func TestCompletionsCmd(t *testing.T) { + t.Parallel() + cmd := newCompletionsCmd() cmd.cmd.SetArgs([]string{}) diff --git a/internal/clicommand/config_test.go b/internal/clicommand/config_test.go index e9d1301..3d5462e 100644 --- a/internal/clicommand/config_test.go +++ b/internal/clicommand/config_test.go @@ -30,6 +30,8 @@ import ( ) func TestConfig_Happy_CustomPath(t *testing.T) { + t.Parallel() + var path = filepath.Join(t.TempDir(), "foo.yaml") var proj config.Project @@ -44,6 +46,8 @@ func TestConfig_Happy_CustomPath(t *testing.T) { } func TestConfig_Happy_DefaultPath(t *testing.T) { + t.Parallel() + var folder = t.TempDir() var path = filepath.Join(folder, "cider.yaml") @@ -60,6 +64,8 @@ func TestConfig_Happy_DefaultPath(t *testing.T) { } func TestConfig_Err_DoesntExist(t *testing.T) { + t.Parallel() + cfg, err := loadConfig("", t.TempDir()) assert.Error(t, err) assert.Empty(t, cfg) diff --git a/internal/clicommand/error_test.go b/internal/clicommand/error_test.go index 341cd1f..1328263 100644 --- a/internal/clicommand/error_test.go +++ b/internal/clicommand/error_test.go @@ -30,6 +30,8 @@ import ( var errTestError = errors.New("TEST") func TestErrors(t *testing.T) { + t.Parallel() + err := wrapError(errTestError, "TEST") assert.Error(t, err) assert.Equal(t, "TEST", err.Error()) diff --git a/internal/clicommand/init_test.go b/internal/clicommand/init_test.go index 370f35f..a9a1649 100644 --- a/internal/clicommand/init_test.go +++ b/internal/clicommand/init_test.go @@ -28,6 +28,8 @@ import ( ) func TestInitCmd(t *testing.T) { + t.Parallel() + var folder = t.TempDir() var cmd = newInitCmd().cmd diff --git a/internal/clicommand/root.go b/internal/clicommand/root.go index d5ff36e..abb7ac5 100644 --- a/internal/clicommand/root.go +++ b/internal/clicommand/root.go @@ -25,6 +25,7 @@ import ( "errors" "fmt" "os" + "sync" "github.com/apex/log" "github.com/apex/log/handlers/cli" @@ -32,14 +33,14 @@ import ( "github.com/spf13/cobra" ) +// nolint: gochecknoglobals +// It's strange these need to be global. +var ( + loggerMu sync.Mutex +) + // Execute is the primary function to initiate the command line interface for Cider. func Execute(version string, exit func(int), args []string) { - if os.Getenv("CI") != "" { - color.NoColor = false - } - - log.SetHandler(cli.Default) - // nolint: forbidigo fmt.Println() // nolint: forbidigo @@ -68,7 +69,7 @@ func NewRoot(version string, exit func(int)) *Root { SilenceUsage: true, SilenceErrors: true, DisableAutoGenTag: true, - PersistentPreRun: root.setDebug, + PersistentPreRun: root.customizeLogger, } cmd.PersistentFlags().BoolVar(&root.debug, "debug", false, "Enable debug mode") @@ -110,7 +111,16 @@ func (cmd *Root) Execute(args []string) { } } -func (cmd *Root) setDebug(c *cobra.Command, args []string) { +func (cmd *Root) customizeLogger(c *cobra.Command, args []string) { + loggerMu.Lock() + defer loggerMu.Unlock() + + if os.Getenv("CI") != "" { + color.NoColor = false + } + + log.SetHandler(cli.Default) + if cmd.debug { log.SetLevel(log.DebugLevel) log.Debug("debug logs enabled") diff --git a/internal/clicommand/root_test.go b/internal/clicommand/root_test.go index 0da2a41..b769458 100644 --- a/internal/clicommand/root_test.go +++ b/internal/clicommand/root_test.go @@ -28,6 +28,8 @@ import ( ) func TestRootCmd(t *testing.T) { + t.Parallel() + exit := func(code int) { assert.Equal(t, 0, code) } @@ -37,6 +39,8 @@ func TestRootCmd(t *testing.T) { } func TestRootCmd_Error(t *testing.T) { + t.Parallel() + exit := func(code int) { assert.NotEqual(t, 0, code) } diff --git a/internal/client/assets_test.go b/internal/client/assets_test.go index 6d3042d..db0f748 100644 --- a/internal/client/assets_test.go +++ b/internal/client/assets_test.go @@ -31,6 +31,8 @@ import ( // Test UploadRoutingCoverage func TestUploadRoutingCoverage_Happy(t *testing.T) { + t.Parallel() + asset := newTestAsset(t, "TEST") ctx, client := newTestContext( response{ diff --git a/internal/client/client_test.go b/internal/client/client_test.go index 947840b..2bc961b 100644 --- a/internal/client/client_test.go +++ b/internal/client/client_test.go @@ -32,6 +32,8 @@ import ( // Test GetApp func TestGetApp_Happy(t *testing.T) { + t.Parallel() + expectedBundleID := "com.app.bundleid" ctx, client := newTestContext(response{ Response: asc.AppsResponse{ @@ -54,6 +56,8 @@ func TestGetApp_Happy(t *testing.T) { } func TestGetApp_Err(t *testing.T) { + t.Parallel() + ctx, client := newTestContext(response{ StatusCode: http.StatusNotFound, RawResponse: `{}`, @@ -66,6 +70,8 @@ func TestGetApp_Err(t *testing.T) { } func TestGetApp_ErrNoApps(t *testing.T) { + t.Parallel() + ctx, client := newTestContext(response{ RawResponse: `{"data":[]}`, }) @@ -79,6 +85,8 @@ func TestGetApp_ErrNoApps(t *testing.T) { // Test GetAppInfo func TestGetAppInfo_Happy(t *testing.T) { + t.Parallel() + expectedState := asc.AppStoreVersionStatePrepareForSubmission app := asc.App{} ctx, client := newTestContext(response{ @@ -106,6 +114,8 @@ func TestGetAppInfo_Happy(t *testing.T) { } func TestGetAppInfo_Err(t *testing.T) { + t.Parallel() + app := asc.App{} ctx, client := newTestContext(response{ StatusCode: http.StatusNotFound, @@ -120,6 +130,8 @@ func TestGetAppInfo_Err(t *testing.T) { } func TestGetAppInfo_ErrNoData(t *testing.T) { + t.Parallel() + app := asc.App{} ctx, client := newTestContext(response{ RawResponse: `{}`, @@ -139,6 +151,8 @@ const ( ) func TestGetBuild_Happy(t *testing.T) { + t.Parallel() + expectedProcessingState := validProcessingState app := asc.App{ Attributes: &asc.AppAttributes{ @@ -167,6 +181,8 @@ func TestGetBuild_Happy(t *testing.T) { } func TestGetBuild_HappyOverrideBuild(t *testing.T) { + t.Parallel() + expectedProcessingState := validProcessingState app := asc.App{ Attributes: &asc.AppAttributes{ @@ -196,6 +212,8 @@ func TestGetBuild_HappyOverrideBuild(t *testing.T) { } func TestGetBuild_ErrNoVersion(t *testing.T) { + t.Parallel() + app := asc.App{ Attributes: &asc.AppAttributes{ BundleID: asc.String("com.app.bundleid"), @@ -214,6 +232,8 @@ func TestGetBuild_ErrNoVersion(t *testing.T) { } func TestGetBuild_Err(t *testing.T) { + t.Parallel() + app := asc.App{ Attributes: &asc.AppAttributes{ BundleID: asc.String("com.app.bundleid"), @@ -234,6 +254,8 @@ func TestGetBuild_Err(t *testing.T) { } func TestGetBuild_ErrNoBuilds(t *testing.T) { + t.Parallel() + app := asc.App{ Attributes: &asc.AppAttributes{ BundleID: asc.String("com.app.bundleid"), @@ -253,6 +275,8 @@ func TestGetBuild_ErrNoBuilds(t *testing.T) { } func TestGetBuild_ErrNoAttributes(t *testing.T) { + t.Parallel() + app := asc.App{ Attributes: &asc.AppAttributes{ BundleID: asc.String("com.app.bundleid"), @@ -272,6 +296,8 @@ func TestGetBuild_ErrNoAttributes(t *testing.T) { } func TestGetBuild_ErrNoProcessingState(t *testing.T) { + t.Parallel() + app := asc.App{ Attributes: &asc.AppAttributes{ BundleID: asc.String("com.app.bundleid"), @@ -291,6 +317,8 @@ func TestGetBuild_ErrNoProcessingState(t *testing.T) { } func TestGetBuild_ErrInvalidProcessingState(t *testing.T) { + t.Parallel() + app := asc.App{ Attributes: &asc.AppAttributes{ BundleID: asc.String("com.app.bundleid"), @@ -312,6 +340,8 @@ func TestGetBuild_ErrInvalidProcessingState(t *testing.T) { // Test ReleaseForAppIsInitial func TestReleaseForAppIsInitial_HappyInitial(t *testing.T) { + t.Parallel() + app := asc.App{} ctx, client := newTestContext(response{ Response: asc.AppStoreVersionsResponse{ @@ -329,6 +359,8 @@ func TestReleaseForAppIsInitial_HappyInitial(t *testing.T) { } func TestReleaseForAppIsInitial_Err(t *testing.T) { + t.Parallel() + app := asc.App{} ctx, client := newTestContext(response{ StatusCode: http.StatusNotFound, @@ -343,6 +375,8 @@ func TestReleaseForAppIsInitial_Err(t *testing.T) { } func TestReleaseForAppIsInitial_HappyNotInitial(t *testing.T) { + t.Parallel() + app := asc.App{} ctx, client := newTestContext(response{ Response: asc.AppStoreVersionsResponse{ diff --git a/internal/client/clienttest/clienttest_test.go b/internal/client/clienttest/clienttest_test.go index ca91fbc..47f749a 100644 --- a/internal/client/clienttest/clienttest_test.go +++ b/internal/client/clienttest/clienttest_test.go @@ -30,6 +30,8 @@ import ( ) func TestClient(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) c := clienttest.Client{} @@ -107,6 +109,8 @@ func TestClient(t *testing.T) { } func TestCredentials(t *testing.T) { + t.Parallel() + c := clienttest.Credentials{} assert.NotNil(t, c.Client()) } diff --git a/internal/client/store_test.go b/internal/client/store_test.go index d1613c3..3dc8120 100644 --- a/internal/client/store_test.go +++ b/internal/client/store_test.go @@ -33,6 +33,8 @@ import ( // Test UpdateApp func TestUpdateApp_Happy(t *testing.T) { + t.Parallel() + now := time.Now() ctx, client := newTestContext( @@ -86,6 +88,8 @@ func TestUpdateApp_Happy(t *testing.T) { // Test UpdateAppLocalizations func TestUpdateAppLocalizations_Happy(t *testing.T) { + t.Parallel() + prepareForSubmission := asc.AppStoreVersionStatePrepareForSubmission readyForSale := asc.AppStoreVersionStateReadyForSale ctx, client := newTestContext( @@ -149,6 +153,8 @@ func TestUpdateAppLocalizations_Happy(t *testing.T) { // Test CreateVersionIfNeeded func TestCreateVersionIfNeeded_Happy(t *testing.T) { + t.Parallel() + now := time.Now() ctx, client := newTestContext( response{ @@ -173,6 +179,8 @@ func TestCreateVersionIfNeeded_Happy(t *testing.T) { // Test UpdateVersionLocalizations func TestUpdateVersionLocalizations_Happy(t *testing.T) { + t.Parallel() + asset := newTestAsset(t, "TEST") previewID := "TEST-Preview-en_US" screenshotID := "TEST-Screenshot-en_US" @@ -403,6 +411,8 @@ func TestUpdateVersionLocalizations_Happy(t *testing.T) { // Test UpdateIDFADeclaration func TestUpdateIDFADeclaration_Happy(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ Response: asc.IDFADeclarationResponse{ @@ -422,6 +432,8 @@ func TestUpdateIDFADeclaration_Happy(t *testing.T) { } func TestUpdateIDFADeclaration_ErrUpdate(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ RawResponse: `{"data":{"id":"TEST"}}`, @@ -438,6 +450,8 @@ func TestUpdateIDFADeclaration_ErrUpdate(t *testing.T) { } func TestUpdateIDFADeclaration_ErrCreate(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ StatusCode: http.StatusNotFound, @@ -457,6 +471,8 @@ func TestUpdateIDFADeclaration_ErrCreate(t *testing.T) { // Test UpdateReviewDetails func TestUpdateReviewDetails_Happy(t *testing.T) { + t.Parallel() + asset := newTestAsset(t, "TEST") attachmentID := "TEST-Attachment-1" @@ -531,6 +547,8 @@ func TestUpdateReviewDetails_Happy(t *testing.T) { } func TestUpdateReviewDetails_ErrUpdate(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ RawResponse: `{"data":{"id":"TEST"}}`, @@ -547,6 +565,8 @@ func TestUpdateReviewDetails_ErrUpdate(t *testing.T) { } func TestUpdateReviewDetails_ErrCreate(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ StatusCode: http.StatusNotFound, @@ -569,6 +589,8 @@ func TestUpdateReviewDetails_ErrCreate(t *testing.T) { // Test EnablePhasedRelease func TestEnablePhasedRelease_Update(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ Response: asc.AppStoreVersionPhasedReleaseResponse{ @@ -588,6 +610,8 @@ func TestEnablePhasedRelease_Update(t *testing.T) { } func TestEnablePhasedRelease_Create(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ RawResponse: `{}`, @@ -605,6 +629,8 @@ func TestEnablePhasedRelease_Create(t *testing.T) { // Test SubmitApp func TestSubmitApp_Happy(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ RawResponse: `{}`, @@ -617,6 +643,8 @@ func TestSubmitApp_Happy(t *testing.T) { } func TestSubmitApp_Err(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ StatusCode: http.StatusNotFound, diff --git a/internal/client/testflight_test.go b/internal/client/testflight_test.go index db97aec..649de50 100644 --- a/internal/client/testflight_test.go +++ b/internal/client/testflight_test.go @@ -36,6 +36,8 @@ const ( // Test UpdateBetaAppLocalizations func TestUpdateBetaAppLocalizations_Happy(t *testing.T) { + t.Parallel() + localizations := config.TestflightLocalizations{ "en-US": { Description: "TEST", @@ -88,6 +90,8 @@ func TestUpdateBetaAppLocalizations_Happy(t *testing.T) { } func TestUpdateBetaAppLocalizations_ErrList(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ StatusCode: http.StatusNotFound, @@ -101,6 +105,8 @@ func TestUpdateBetaAppLocalizations_ErrList(t *testing.T) { } func TestUpdateBetaAppLocalizations_ErrUpdate(t *testing.T) { + t.Parallel() + localizations := config.TestflightLocalizations{ "en-US": { Description: "TEST", @@ -133,6 +139,8 @@ func TestUpdateBetaAppLocalizations_ErrUpdate(t *testing.T) { } func TestUpdateBetaAppLocalizations_ErrCreate(t *testing.T) { + t.Parallel() + localizations := config.TestflightLocalizations{ "en-US": { Description: "TEST", @@ -174,6 +182,8 @@ func TestUpdateBetaAppLocalizations_ErrCreate(t *testing.T) { // Test UpdateBetaBuildDetails func TestUpdateBetaBuildDetails_Happy(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ RawResponse: `{}`, @@ -186,6 +196,8 @@ func TestUpdateBetaBuildDetails_Happy(t *testing.T) { } func TestUpdateBetaBuildDetails_Err(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ StatusCode: http.StatusNotFound, @@ -203,6 +215,8 @@ func TestUpdateBetaBuildDetails_Err(t *testing.T) { // Test UpdateBetaBuildLocalizations func TestUpdateBetaBuildLocalizations_Happy(t *testing.T) { + t.Parallel() + localizations := config.TestflightLocalizations{ "en-US": { Description: "TEST", @@ -247,6 +261,8 @@ func TestUpdateBetaBuildLocalizations_Happy(t *testing.T) { } func TestUpdateBetaBuildLocalizations_ErrList(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ StatusCode: http.StatusNotFound, @@ -260,6 +276,8 @@ func TestUpdateBetaBuildLocalizations_ErrList(t *testing.T) { } func TestUpdateBetaBuildLocalizations_ErrUpdate(t *testing.T) { + t.Parallel() + localizations := config.TestflightLocalizations{ "en-US": { Description: "TEST", @@ -292,6 +310,8 @@ func TestUpdateBetaBuildLocalizations_ErrUpdate(t *testing.T) { } func TestUpdateBetaBuildLocalizations_ErrCreate(t *testing.T) { + t.Parallel() + localizations := config.TestflightLocalizations{ "en-US": { Description: "TEST", @@ -333,6 +353,8 @@ func TestUpdateBetaBuildLocalizations_ErrCreate(t *testing.T) { // Test UpdateBetaLicenseAgreement func TestUpdateBetaLicenseAgreement_Happy(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ RawResponse: `{"data":{"id":"TEST"}}`, @@ -348,6 +370,8 @@ func TestUpdateBetaLicenseAgreement_Happy(t *testing.T) { } func TestUpdateBetaLicenseAgreement_NoLicense(t *testing.T) { + t.Parallel() + ctx, client := newTestContext() defer ctx.Close() @@ -356,6 +380,8 @@ func TestUpdateBetaLicenseAgreement_NoLicense(t *testing.T) { } func TestUpdateBetaLicenseAgreement_ErrGet(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ StatusCode: http.StatusNotFound, @@ -369,6 +395,8 @@ func TestUpdateBetaLicenseAgreement_ErrGet(t *testing.T) { } func TestUpdateBetaLicenseAgreement_ErrUpdate(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ RawResponse: `{"data":{"id":"TEST"}}`, @@ -387,6 +415,8 @@ func TestUpdateBetaLicenseAgreement_ErrUpdate(t *testing.T) { // Test AssignBetaGroups func TestAssignBetaGroups_Happy(t *testing.T) { + t.Parallel() + testEmail := asc.Email("email2@test.com") ctx, client := newTestContext( response{ @@ -474,6 +504,8 @@ func TestAssignBetaGroups_Happy(t *testing.T) { } func TestAssignBetaGroups_WarnNoGroupsInput(t *testing.T) { + t.Parallel() + ctx, client := newTestContext() defer ctx.Close() @@ -482,6 +514,8 @@ func TestAssignBetaGroups_WarnNoGroupsInput(t *testing.T) { } func TestAssignBetaGroups_ErrList(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ StatusCode: http.StatusNotFound, @@ -495,6 +529,8 @@ func TestAssignBetaGroups_ErrList(t *testing.T) { } func TestAssignBetaGroups_ErrUpdate(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ Response: asc.BetaGroupsResponse{ @@ -522,6 +558,8 @@ func TestAssignBetaGroups_ErrUpdate(t *testing.T) { } func TestAssignBetaGroups_ErrAssign(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ Response: asc.BetaGroupsResponse{ @@ -547,6 +585,8 @@ func TestAssignBetaGroups_ErrAssign(t *testing.T) { } func TestAssignBetaGroups_ErrCreate(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ RawResponse: `{"data":[]}`, @@ -567,6 +607,8 @@ func TestAssignBetaGroups_ErrCreate(t *testing.T) { // Test AssignBetaTesters func TestAssignBetaTesters_Happy(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ Response: asc.BetaTestersResponse{ @@ -609,6 +651,8 @@ func TestAssignBetaTesters_Happy(t *testing.T) { } func TestAssignBetaTesters_WarnNoTestersInput(t *testing.T) { + t.Parallel() + ctx, client := newTestContext() defer ctx.Close() @@ -617,6 +661,8 @@ func TestAssignBetaTesters_WarnNoTestersInput(t *testing.T) { } func TestAssignBetaTesters_ErrList(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ StatusCode: http.StatusNotFound, @@ -630,6 +676,8 @@ func TestAssignBetaTesters_ErrList(t *testing.T) { } func TestAssignBetaTesters_WarnNoTestersMatching(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ RawResponse: `{"data":[]}`, @@ -642,6 +690,8 @@ func TestAssignBetaTesters_WarnNoTestersMatching(t *testing.T) { } func TestAssignBetaTesters_ErrAssign(t *testing.T) { + t.Parallel() + testEmail := asc.Email("test@email.com") ctx, client := newTestContext( response{ @@ -671,6 +721,8 @@ func TestAssignBetaTesters_ErrAssign(t *testing.T) { // Test UpdateBetaReviewDetails func TestUpdateBetaReviewDetails_Happy(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ RawResponse: `{"data":{"id":"TEST"}}`, @@ -692,6 +744,8 @@ func TestUpdateBetaReviewDetails_Happy(t *testing.T) { } func TestUpdateBetaReviewDetails_ErrGet(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ StatusCode: http.StatusNotFound, @@ -705,6 +759,8 @@ func TestUpdateBetaReviewDetails_ErrGet(t *testing.T) { } func TestUpdateBetaReviewDetails_ErrUpdate(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ RawResponse: `{"data":{"id":"TEST"}}`, @@ -723,6 +779,8 @@ func TestUpdateBetaReviewDetails_ErrUpdate(t *testing.T) { // Test SubmitBetaApp func TestSubmitBetaApp_Happy(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ RawResponse: `{}`, @@ -735,6 +793,8 @@ func TestSubmitBetaApp_Happy(t *testing.T) { } func TestSubmitBetaApp_Err(t *testing.T) { + t.Parallel() + ctx, client := newTestContext( response{ StatusCode: http.StatusNotFound, diff --git a/internal/closer/closer_test.go b/internal/closer/closer_test.go index ef6dfd0..76c5f58 100644 --- a/internal/closer/closer_test.go +++ b/internal/closer/closer_test.go @@ -30,6 +30,8 @@ import ( var errAlreadyClosed = errors.New("already closed") func TestClose(t *testing.T) { + t.Parallel() + var expectingErr bool onCloseErr = func(err error) { diff --git a/internal/git/errors_test.go b/internal/git/errors_test.go index 904a375..b00d473 100644 --- a/internal/git/errors_test.go +++ b/internal/git/errors_test.go @@ -27,18 +27,24 @@ import ( ) func TestErrDirtyMessage(t *testing.T) { + t.Parallel() + err := ErrDirty{"TEST"} expected := "git is currently in a dirty state, please check in your pipeline what can be changing the following files:\nTEST" assert.Equal(t, expected, err.Error()) } func TestErrWrongRefMessage(t *testing.T) { + t.Parallel() + err := ErrWrongRef{"TEST", "TEST"} expected := "git tag TEST was not made against commit TEST" assert.Equal(t, expected, err.Error()) } func TestErrNotRepositoryMessage(t *testing.T) { + t.Parallel() + err := ErrNotRepository{"TEST"} expected := "the directory at TEST is not a git repository" assert.Equal(t, expected, err.Error()) diff --git a/internal/git/git_test.go b/internal/git/git_test.go index 26c1d7b..6365003 100644 --- a/internal/git/git_test.go +++ b/internal/git/git_test.go @@ -47,6 +47,8 @@ func newMockGitWithContext(ctx *context.Context, t *testing.T, commands ...shell } func TestNew(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) client := New(ctx) ok := client.IsRepo() @@ -54,6 +56,8 @@ func TestNew(t *testing.T) { } func TestSanitizeProcess(t *testing.T) { + t.Parallel() + runFunc := func(client *Git) (*shell.CompletedProcess, error) { return client.RunInEnv(map[string]string{ "TEST": "TEST", @@ -87,6 +91,8 @@ func TestSanitizeProcess(t *testing.T) { } func TestShowRef(t *testing.T) { + t.Parallel() + // Selected the initial commit of this repo, because I needed a sha1 hash. expected := "eac16d260ebf8af83873c9704169cf40a5501f84" client := newMockGit( @@ -99,6 +105,8 @@ func TestShowRef(t *testing.T) { } func TestExtractRemoteFromConfig_Happy(t *testing.T) { + t.Parallel() + expected := Repo{ Name: "cider", Owner: "cidertool", @@ -115,6 +123,8 @@ func TestExtractRemoteFromConfig_Happy(t *testing.T) { } func TestExtractRemoteFromConfig_ErrIsNotRepo(t *testing.T) { + t.Parallel() + client := newMockGit( t, shelltest.Command{Stdout: "false"}, @@ -125,6 +135,8 @@ func TestExtractRemoteFromConfig_ErrIsNotRepo(t *testing.T) { } func TestExtractRemoteFromConfig_ErrNoRemoteNamedOrigin(t *testing.T) { + t.Parallel() + client := newMockGit( t, shelltest.Command{Stdout: "true"}, @@ -136,6 +148,8 @@ func TestExtractRemoteFromConfig_ErrNoRemoteNamedOrigin(t *testing.T) { } func TestExtractRepoFromURL(t *testing.T) { + t.Parallel() + var repo Repo expected := Repo{ diff --git a/internal/middleware/error_test.go b/internal/middleware/error_test.go index 82fa681..f818e67 100644 --- a/internal/middleware/error_test.go +++ b/internal/middleware/error_test.go @@ -33,6 +33,8 @@ import ( var errTestError = errors.New("TEST") func TestErrHandler_WrapsError(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) wrapped := ErrHandler(func(ctx *context.Context) error { return errTestError @@ -42,6 +44,8 @@ func TestErrHandler_WrapsError(t *testing.T) { } func TestErrHandler_IgnoresNoError(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) wrapped := ErrHandler(func(ctx *context.Context) error { return nil @@ -51,6 +55,8 @@ func TestErrHandler_IgnoresNoError(t *testing.T) { } func TestErrHandler_HandlesSkip(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) wrapped := ErrHandler(func(ctx *context.Context) error { return pipe.Skip("TEST") diff --git a/internal/middleware/logging.go b/internal/middleware/logging.go index 0a5f074..b7f365e 100644 --- a/internal/middleware/logging.go +++ b/internal/middleware/logging.go @@ -21,6 +21,8 @@ along with Cider. If not, see . package middleware import ( + "sync" + "github.com/apex/log" "github.com/apex/log/handlers/cli" "github.com/cidertool/cider/pkg/context" @@ -36,6 +38,9 @@ const DefaultInitialPadding Padding = 3 // ExtraPadding is the double of the DefaultInitialPadding. const ExtraPadding Padding = DefaultInitialPadding * 2 +// nolint: gochecknoglobals +var loggerMu sync.Mutex + // Logging pretty prints the given action and its title. // You can have different padding levels by providing different initial // paddings. The middleware will print the title in the given padding and the @@ -44,6 +49,9 @@ const ExtraPadding Padding = DefaultInitialPadding * 2 // The middleware always resets to the default padding. func Logging(title string, next Action, padding Padding) Action { return func(ctx *context.Context) error { + loggerMu.Lock() + defer loggerMu.Unlock() + defer func() { cli.Default.Padding = int(DefaultInitialPadding) }() diff --git a/internal/middleware/logging_test.go b/internal/middleware/logging_test.go index 25d102a..f5c3acb 100644 --- a/internal/middleware/logging_test.go +++ b/internal/middleware/logging_test.go @@ -29,6 +29,8 @@ import ( ) func TestLogging(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) wrapped := Logging("TEST", func(ctx *context.Context) error { return nil diff --git a/internal/parallel/group_test.go b/internal/parallel/group_test.go index f09d7ac..c3c55ce 100644 --- a/internal/parallel/group_test.go +++ b/internal/parallel/group_test.go @@ -29,21 +29,25 @@ import ( "github.com/stretchr/testify/assert" ) -var errTestError = errors.New("TEST") +// nolint: gochecknoglobals +var ( + errTestError = errors.New("TEST") + groupMu sync.Mutex +) func TestGroup(t *testing.T) { - var g = New(4) + t.Parallel() - var lock sync.Mutex + var g = New(4) var counter int for i := 0; i < 10; i++ { g.Go(func() error { time.Sleep(10 * time.Millisecond) - lock.Lock() + groupMu.Lock() counter++ - lock.Unlock() + groupMu.Unlock() return nil }) @@ -53,6 +57,8 @@ func TestGroup(t *testing.T) { } func TestGroupOrder(t *testing.T) { + t.Parallel() + var num = 10 var g = New(1) @@ -73,6 +79,8 @@ func TestGroupOrder(t *testing.T) { } func TestGroupOrderError(t *testing.T) { + t.Parallel() + var g = New(1) var output = []int{} diff --git a/internal/pipe/defaults/defaults_test.go b/internal/pipe/defaults/defaults_test.go index a955591..4539ffd 100644 --- a/internal/pipe/defaults/defaults_test.go +++ b/internal/pipe/defaults/defaults_test.go @@ -33,6 +33,8 @@ import ( var errTestError = errors.New("TEST") func TestDefaults(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) pipe := Pipe{} diff --git a/internal/pipe/env/env_test.go b/internal/pipe/env/env_test.go index ef57459..5bb5792 100644 --- a/internal/pipe/env/env_test.go +++ b/internal/pipe/env/env_test.go @@ -31,6 +31,8 @@ import ( ) func TestEnv(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) pipe := Pipe{} diff --git a/internal/pipe/git/git_test.go b/internal/pipe/git/git_test.go index b63da67..3d66f4a 100644 --- a/internal/pipe/git/git_test.go +++ b/internal/pipe/git/git_test.go @@ -35,6 +35,8 @@ import ( ) func TestGit_Happy(t *testing.T) { + t.Parallel() + expected := context.GitInfo{ CurrentTag: "1.0.0", Commit: "abcdef1234567890abcdef1234567890abcdef12", @@ -64,6 +66,8 @@ func TestGit_Happy(t *testing.T) { } func TestGit_RealGitClient(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) ctx.CurrentDirectory = "TEST" p := Pipe{} @@ -72,6 +76,8 @@ func TestGit_RealGitClient(t *testing.T) { } func TestGit_SkipGit(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) ctx.Version = "1.0" ctx.SkipGit = true @@ -82,6 +88,8 @@ func TestGit_SkipGit(t *testing.T) { } func TestGit_Happy_EnvCurrentTag(t *testing.T) { + t.Parallel() + expected := context.GitInfo{ CurrentTag: "1.0.0", Commit: "abcdef1234567890abcdef1234567890abcdef12", @@ -114,6 +122,8 @@ func TestGit_Happy_EnvCurrentTag(t *testing.T) { } func TestGit_Err_NoGit(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) p := Pipe{} p.client = &git.Git{ @@ -131,6 +141,8 @@ func TestGit_Err_NoGit(t *testing.T) { } func TestGit_Err_NotInRepo(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) p := Pipe{} p.client = newMockGitWithContext(ctx, @@ -142,6 +154,8 @@ func TestGit_Err_NotInRepo(t *testing.T) { } func TestGit_Err_BadCommit(t *testing.T) { + t.Parallel() + expected := context.GitInfo{ ShortCommit: "abcdef12", } @@ -164,6 +178,8 @@ func TestGit_Err_BadCommit(t *testing.T) { } func TestGit_Err_BadTime(t *testing.T) { + t.Parallel() + expected := context.GitInfo{ ShortCommit: "abcdef12", FullCommit: "abcdef1234567890abcdef1234567890abcdef12", @@ -199,6 +215,8 @@ func TestGit_Err_BadTime(t *testing.T) { } func TestGit_Err_BadTag(t *testing.T) { + t.Parallel() + expected := context.GitInfo{ CurrentTag: "1.0.0", Commit: "abcdef1234567890abcdef1234567890abcdef12", @@ -223,6 +241,8 @@ func TestGit_Err_BadTag(t *testing.T) { } func TestGit_Err_DirtyWorkingCopy(t *testing.T) { + t.Parallel() + expected := context.GitInfo{ CurrentTag: "1.0.0", Commit: "abcdef1234567890abcdef1234567890abcdef12", @@ -248,6 +268,8 @@ func TestGit_Err_DirtyWorkingCopy(t *testing.T) { } func TestGit_Err_InvalidTag(t *testing.T) { + t.Parallel() + expected := context.GitInfo{ CurrentTag: "1.0.0", Commit: "abcdef1234567890abcdef1234567890abcdef12", diff --git a/internal/pipe/pipe_test.go b/internal/pipe/pipe_test.go index 5308807..f0817f1 100644 --- a/internal/pipe/pipe_test.go +++ b/internal/pipe/pipe_test.go @@ -27,6 +27,8 @@ import ( ) func TestPipeSkip(t *testing.T) { + t.Parallel() + skip := Skip("TEST") var err error = ErrSkip{reason: "TEST"} @@ -39,6 +41,8 @@ func TestPipeSkip(t *testing.T) { } func TestErrMissingApp(t *testing.T) { + t.Parallel() + err := ErrMissingApp{Name: "TEST"} assert.Error(t, err) assert.EqualError(t, err, "no app defined in configuration matching the name TEST") diff --git a/internal/pipe/publish/publish_test.go b/internal/pipe/publish/publish_test.go index 27b0df5..f6accab 100644 --- a/internal/pipe/publish/publish_test.go +++ b/internal/pipe/publish/publish_test.go @@ -31,11 +31,15 @@ import ( ) func TestPublish_String(t *testing.T) { + t.Parallel() + p := Pipe{} assert.Equal(t, "publishing from app store connect", p.String()) } func TestPublish_Happy_Testflight(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{ "TEST": {}, }) @@ -50,6 +54,8 @@ func TestPublish_Happy_Testflight(t *testing.T) { } func TestPublish_Happy_Store(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{ "TEST": {}, }) @@ -64,6 +70,8 @@ func TestPublish_Happy_Store(t *testing.T) { } func TestPublish_Happy_NoApps(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) p := Pipe{} @@ -72,6 +80,8 @@ func TestPublish_Happy_NoApps(t *testing.T) { } func TestPublish_Err_NoPublishMode(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) ctx.AppsToRelease = []string{"TEST"} p := Pipe{} @@ -81,6 +91,8 @@ func TestPublish_Err_NoPublishMode(t *testing.T) { } func TestPublish_Err_AppMismatchTestflight(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{ "TEST_": {}, }) @@ -95,6 +107,8 @@ func TestPublish_Err_AppMismatchTestflight(t *testing.T) { } func TestPublish_Err_AppMismatchStore(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{ "TEST_": {}, }) diff --git a/internal/pipe/semver/semver_test.go b/internal/pipe/semver/semver_test.go index 36051e7..55ccf07 100644 --- a/internal/pipe/semver/semver_test.go +++ b/internal/pipe/semver/semver_test.go @@ -29,6 +29,8 @@ import ( ) func TestSemver(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) pipe := Pipe{} diff --git a/internal/pipe/store/store_test.go b/internal/pipe/store/store_test.go index 2148bb9..7d7ab5e 100644 --- a/internal/pipe/store/store_test.go +++ b/internal/pipe/store/store_test.go @@ -31,6 +31,8 @@ import ( ) func TestStore_Happy(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{ "TEST": { BundleID: "com.test.TEST", @@ -69,6 +71,8 @@ func TestStore_Happy(t *testing.T) { } func TestStore_Happy_Skips(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{ "TEST": { BundleID: "com.test.TEST", @@ -86,6 +90,8 @@ func TestStore_Happy_Skips(t *testing.T) { } func TestStore_Happy_NoApps(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) ctx.Credentials = &clienttest.Credentials{} p := Pipe{} diff --git a/internal/pipe/template/template_test.go b/internal/pipe/template/template_test.go index a08175a..0e8cfdc 100644 --- a/internal/pipe/template/template_test.go +++ b/internal/pipe/template/template_test.go @@ -38,11 +38,15 @@ const ( ) func TestTemplatePipeHeader(t *testing.T) { + t.Parallel() + pipe := Pipe{} assert.Equal(t, "applying template values", pipe.String()) } func TestTemplateEmptyProjectPasses(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) pipe := Pipe{} err := pipe.Run(ctx) @@ -52,6 +56,8 @@ func TestTemplateEmptyProjectPasses(t *testing.T) { } func TestTemplateFullyDefinedProjectWithGoodTemplatesPasses(t *testing.T) { + t.Parallel() + ctx := context.New(fullyPopulatedProject(true)) expected := ctx.Version @@ -132,6 +138,8 @@ func TestTemplateFullyDefinedProjectWithGoodTemplatesPasses(t *testing.T) { } func TestTemplateWithBadPatterns(t *testing.T) { + t.Parallel() + proj := fullyPopulatedProject(false) ctx := context.New(proj) pipe := Pipe{} diff --git a/internal/pipe/testflight/testflight_test.go b/internal/pipe/testflight/testflight_test.go index 424f518..cc113e2 100644 --- a/internal/pipe/testflight/testflight_test.go +++ b/internal/pipe/testflight/testflight_test.go @@ -31,6 +31,8 @@ import ( ) func TestTestflight_Happy(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{ "TEST": { BundleID: "com.test.TEST", @@ -62,6 +64,8 @@ func TestTestflight_Happy(t *testing.T) { } func TestTestflight_Happy_Skips(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{ "TEST": { BundleID: "com.test.TEST", @@ -78,6 +82,8 @@ func TestTestflight_Happy_Skips(t *testing.T) { } func TestTestflight_Happy_NoApps(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) ctx.Credentials = &clienttest.Credentials{} p := Pipe{} diff --git a/internal/shell/shell_test.go b/internal/shell/shell_test.go index 11ab5e5..a7e7432 100644 --- a/internal/shell/shell_test.go +++ b/internal/shell/shell_test.go @@ -29,6 +29,8 @@ import ( ) func TestExec(t *testing.T) { + t.Parallel() + sh := New(context.New(config.Project{})) cmd := sh.NewCommand("echo", "dogs") ps, err := sh.Exec(cmd) @@ -37,6 +39,8 @@ func TestExec(t *testing.T) { } func TestExec_Error(t *testing.T) { + t.Parallel() + sh := New(context.New(config.Project{})) cmd := sh.NewCommand("exit", "1") ps, err := sh.Exec(cmd) @@ -45,6 +49,8 @@ func TestExec_Error(t *testing.T) { } func TestEscapeArgs(t *testing.T) { + t.Parallel() + original := []string{"dan", "wears", "big jorts"} expected := []string{"dan", "wears", "'big jorts'"} actual := escapeArgs(original) @@ -52,12 +58,16 @@ func TestEscapeArgs(t *testing.T) { } func TestExists(t *testing.T) { + t.Parallel() + sh := New(context.New(config.Project{})) assert.True(t, sh.Exists("git")) assert.False(t, sh.Exists("nonexistent_program.exe")) } func TestCurrentDirectory(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) ctx.CurrentDirectory = "TEST" sh := New(ctx) diff --git a/internal/shell/shelltest/shelltest_test.go b/internal/shell/shelltest/shelltest_test.go index 954d0ad..7902e96 100644 --- a/internal/shell/shelltest/shelltest_test.go +++ b/internal/shell/shelltest/shelltest_test.go @@ -29,6 +29,8 @@ import ( ) func TestShell(t *testing.T) { + t.Parallel() + ctx := context.New(config.Project{}) ctx.CurrentDirectory = "TEST" sh := Shell{ diff --git a/internal/template/template_test.go b/internal/template/template_test.go index 1145e46..7aa2708 100644 --- a/internal/template/template_test.go +++ b/internal/template/template_test.go @@ -29,6 +29,8 @@ import ( ) func TestTemplate(t *testing.T) { + t.Parallel() + tmpl, err := New(context.New(config.Project{})). WithEnv(map[string]string{ "DOG": "HAPPY", @@ -44,11 +46,15 @@ func TestTemplate(t *testing.T) { } func TestInvalidTemplate(t *testing.T) { + t.Parallel() + _, err := New(context.New(config.Project{})).Apply(`{{ .timestamp`) assert.Error(t, err) } func TestEmptyTemplate(t *testing.T) { + t.Parallel() + tmpl, err := New(context.New(config.Project{})).Apply("") assert.NoError(t, err) assert.Empty(t, tmpl) diff --git a/pkg/config/config_convert_test.go b/pkg/config/config_convert_test.go index 4893c3c..840639c 100644 --- a/pkg/config/config_convert_test.go +++ b/pkg/config/config_convert_test.go @@ -28,6 +28,8 @@ import ( ) func TestPlatformAPIValue(t *testing.T) { + t.Parallel() + var plat Platform plat = PlatformiOS assert.Equal(t, *plat.APIValue(), asc.PlatformIOS) @@ -45,6 +47,8 @@ func TestPlatformAPIValue(t *testing.T) { } func TestReleaseTypeAPIValue(t *testing.T) { + t.Parallel() + var release releaseType release = ReleaseTypeManual assert.Equal(t, *release.APIValue(), "MANUAL") @@ -62,6 +66,8 @@ func TestReleaseTypeAPIValue(t *testing.T) { } func TestContentIntensityAPIValue(t *testing.T) { + t.Parallel() + var intensity contentIntensity intensity = ContentIntensityNone assert.Equal(t, *intensity.APIValue(), "NONE") @@ -79,6 +85,8 @@ func TestContentIntensityAPIValue(t *testing.T) { } func TestKidsAgeBandAPIValue(t *testing.T) { + t.Parallel() + var band kidsAgeBand band = KidsAgeBandFiveAndUnder assert.Equal(t, *band.APIValue(), asc.KidsAgeBandFiveAndUnder) @@ -96,6 +104,8 @@ func TestKidsAgeBandAPIValue(t *testing.T) { } func TestPreviewTypeAPIValue(t *testing.T) { + t.Parallel() + var preview previewType preview = PreviewTypeAppleTV assert.Equal(t, *preview.APIValue(), asc.PreviewTypeAppleTV) @@ -137,6 +147,8 @@ func TestPreviewTypeAPIValue(t *testing.T) { } func TestScreenshotTypeAPIValue(t *testing.T) { + t.Parallel() + var screenshot screenshotType screenshot = ScreenshotTypeAppleTV assert.Equal(t, *screenshot.APIValue(), asc.ScreenshotDisplayTypeAppAppleTV) @@ -198,6 +210,8 @@ func TestScreenshotTypeAPIValue(t *testing.T) { } func TestPreviewSetsGetPreviews(t *testing.T) { + t.Parallel() + sets := make(PreviewSets) sets[PreviewTypeAppleTV] = []Preview{} @@ -234,6 +248,8 @@ func TestPreviewSetsGetPreviews(t *testing.T) { } func TestGetScreenshotSetsGetScreenshots(t *testing.T) { + t.Parallel() + sets := make(ScreenshotSets) sets[ScreenshotTypeAppleTV] = []File{} diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index e47b83a..2d266eb 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -31,22 +31,30 @@ import ( var errTestError = errors.New("test error") func TestValidConfiguration(t *testing.T) { + t.Parallel() + f, err := Load("testdata/valid.yml") assert.NoError(t, err) assert.Len(t, f, 1) } func TestMissingConfiguration(t *testing.T) { + t.Parallel() + _, err := Load("testdata/doesnotexist.yml") assert.Error(t, err) } func TestInvalidConfiguration(t *testing.T) { + t.Parallel() + _, err := Load("testdata/invalid.yml") assert.Error(t, err) } func TestMarshalledIsValidConfiguration(t *testing.T) { + t.Parallel() + f, err := Load("testdata/valid.yml") assert.NoError(t, err) str, err := f.String() @@ -57,6 +65,8 @@ func TestMarshalledIsValidConfiguration(t *testing.T) { } func TestBrokenFile(t *testing.T) { + t.Parallel() + _, err := LoadReader(errReader(0)) assert.Error(t, err) } @@ -68,6 +78,8 @@ func (errReader) Read(p []byte) (int, error) { } func TestCopy(t *testing.T) { + t.Parallel() + p := Project{ "App1": {}, "App2": {}, @@ -80,6 +92,8 @@ func TestCopy(t *testing.T) { } func TestCopy_Err(t *testing.T) { + t.Parallel() + p := Project{ "App1": {}, "App2": {}, @@ -92,6 +106,8 @@ func TestCopy_Err(t *testing.T) { } func TestAppsMatching(t *testing.T) { + t.Parallel() + p := Project{ "App1": {}, "App2": {}, diff --git a/pkg/context/context_test.go b/pkg/context/context_test.go index d9bdb5f..728d52e 100644 --- a/pkg/context/context_test.go +++ b/pkg/context/context_test.go @@ -30,6 +30,8 @@ import ( ) func TestNew(t *testing.T) { + t.Parallel() + assert.NoError(t, os.Setenv("TEST", "DOG")) ctx := New(config.Project{}) @@ -37,6 +39,8 @@ func TestNew(t *testing.T) { } func TestNewWithTimeout(t *testing.T) { + t.Parallel() + ctx, cancel := NewWithTimeout(config.Project{}, time.Second) assert.NotEmpty(t, ctx.Env) cancel() @@ -45,6 +49,8 @@ func TestNewWithTimeout(t *testing.T) { } func TestEnv(t *testing.T) { + t.Parallel() + var env = Env{"DOG": "FRIEND"} anotherEnv := env.Copy() assert.Equal(t, env, anotherEnv) @@ -53,6 +59,8 @@ func TestEnv(t *testing.T) { } func TestPublishMode(t *testing.T) { + t.Parallel() + var mode PublishMode mode = PublishModeAppStore assert.Equal(t, "appstore", mode.String()) diff --git a/pkg/context/credentials_test.go b/pkg/context/credentials_test.go index 04fd955..2e6f763 100644 --- a/pkg/context/credentials_test.go +++ b/pkg/context/credentials_test.go @@ -27,6 +27,8 @@ import ( ) func TestNewCredentials(t *testing.T) { + t.Parallel() + privateKey := []byte(` -----BEGIN PRIVATE KEY----- MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgTHOfkv1Dj2Yp8hyT diff --git a/pkg/context/interrupt_test.go b/pkg/context/interrupt_test.go index 0eb5f3a..af00ead 100644 --- a/pkg/context/interrupt_test.go +++ b/pkg/context/interrupt_test.go @@ -31,12 +31,16 @@ import ( var errTestError = errors.New("TEST") func TestInterruptOK(t *testing.T) { + t.Parallel() + assert.NoError(t, NewInterrupt().Run(context.Background(), func() error { return nil })) } func TestInterruptErrors(t *testing.T) { + t.Parallel() + assert.EqualError(t, NewInterrupt().Run(context.Background(), func() error { return errTestError }), errTestError.Error())