Skip to content

Commit 9a782c9

Browse files
committed
refactor(tests): fix test not wrapped in t.Run
1 parent a13ed27 commit 9a782c9

1 file changed

Lines changed: 40 additions & 38 deletions

File tree

internal/app/app_client_test.go

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -692,46 +692,48 @@ func TestAppClient_CleanupAppsJSONFiles(t *testing.T) {
692692
},
693693
}
694694

695-
for _, tc := range tests {
696-
ac, _, _, pathToAppsJSON, pathToDevAppsJSON, teardown := setup(t)
697-
defer teardown(t)
698-
ctx := slackcontext.MockContext(t.Context())
699-
700-
err := afero.WriteFile(ac.fs, pathToAppsJSON, tc.appsJSON, 0600)
701-
require.NoError(t, err)
702-
err = afero.WriteFile(ac.fs, pathToDevAppsJSON, tc.devAppsJSON, 0600)
703-
require.NoError(t, err)
704-
705-
_, err = ac.fs.Stat(pathToAppsJSON)
706-
require.NoError(t, err, "failed to access the apps.json file")
707-
deployedApps, _, err := ac.GetDeployedAll(ctx)
708-
require.NoError(t, err)
709-
710-
_, err = ac.fs.Stat(pathToDevAppsJSON)
711-
require.NoError(t, err, "failed to access the apps.dev.json file")
712-
localApps, err := ac.GetLocalAll(ctx)
713-
require.NoError(t, err)
714-
715-
ac.CleanUp()
716-
717-
dotSlackFolder := filepath.Dir(pathToAppsJSON)
718-
_, err = ac.fs.Stat(dotSlackFolder)
719-
require.NoError(t, err, "failed to access the .slack directory")
720-
721-
appsJSON, err := afero.ReadFile(ac.fs, pathToAppsJSON)
722-
if len(deployedApps) == 0 {
723-
require.ErrorIs(t, err, os.ErrNotExist, "apps.json was not deleted")
724-
} else {
695+
for name, tc := range tests {
696+
t.Run(name, func(t *testing.T) {
697+
ac, _, _, pathToAppsJSON, pathToDevAppsJSON, teardown := setup(t)
698+
defer teardown(t)
699+
ctx := slackcontext.MockContext(t.Context())
700+
701+
err := afero.WriteFile(ac.fs, pathToAppsJSON, tc.appsJSON, 0600)
702+
require.NoError(t, err)
703+
err = afero.WriteFile(ac.fs, pathToDevAppsJSON, tc.devAppsJSON, 0600)
704+
require.NoError(t, err)
705+
706+
_, err = ac.fs.Stat(pathToAppsJSON)
725707
require.NoError(t, err, "failed to access the apps.json file")
726-
assert.Equal(t, appsJSONExample, appsJSON)
727-
}
708+
deployedApps, _, err := ac.GetDeployedAll(ctx)
709+
require.NoError(t, err)
728710

729-
devAppsJSON, err := afero.ReadFile(ac.fs, pathToDevAppsJSON)
730-
if len(localApps) == 0 {
731-
require.ErrorIs(t, err, os.ErrNotExist, "apps.dev.json was not deleted")
732-
} else {
711+
_, err = ac.fs.Stat(pathToDevAppsJSON)
733712
require.NoError(t, err, "failed to access the apps.dev.json file")
734-
assert.Equal(t, devAppsJSONExample, devAppsJSON)
735-
}
713+
localApps, err := ac.GetLocalAll(ctx)
714+
require.NoError(t, err)
715+
716+
ac.CleanUp()
717+
718+
dotSlackFolder := filepath.Dir(pathToAppsJSON)
719+
_, err = ac.fs.Stat(dotSlackFolder)
720+
require.NoError(t, err, "failed to access the .slack directory")
721+
722+
appsJSON, err := afero.ReadFile(ac.fs, pathToAppsJSON)
723+
if len(deployedApps) == 0 {
724+
require.ErrorIs(t, err, os.ErrNotExist, "apps.json was not deleted")
725+
} else {
726+
require.NoError(t, err, "failed to access the apps.json file")
727+
assert.Equal(t, appsJSONExample, appsJSON)
728+
}
729+
730+
devAppsJSON, err := afero.ReadFile(ac.fs, pathToDevAppsJSON)
731+
if len(localApps) == 0 {
732+
require.ErrorIs(t, err, os.ErrNotExist, "apps.dev.json was not deleted")
733+
} else {
734+
require.NoError(t, err, "failed to access the apps.dev.json file")
735+
assert.Equal(t, devAppsJSONExample, devAppsJSON)
736+
}
737+
})
736738
}
737739
}

0 commit comments

Comments
 (0)