Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit 370c4f5

Browse files
committed
Refactor run test with file
1 parent e3c552f commit 370c4f5

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

internals/secrethub/run_test.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,6 @@ func TestRunCommand_RunWithFile(t *testing.T) {
943943
}
944944

945945
cases := map[string]struct {
946-
envFileContent string
947946
script string
948947
command RunCommand
949948
err error
@@ -1004,16 +1003,9 @@ func TestRunCommand_RunWithFile(t *testing.T) {
10041003

10051004
for name, tc := range cases {
10061005
t.Run(name, func(t *testing.T) {
1007-
envFile := filepath.Join(os.TempDir(), tc.command.envFile)
1008-
err := ioutil.WriteFile(envFile, []byte(tc.envFileContent), os.ModePerm)
1009-
if err != nil {
1010-
log.Fatal("Cannot create file for test", err)
1011-
}
1012-
defer os.Remove(envFile)
1013-
10141006
if tc.script != "" {
10151007
scriptFile := filepath.Join(os.TempDir(), tc.command.command[1])
1016-
err = ioutil.WriteFile(scriptFile, []byte(tc.script), os.ModePerm)
1008+
err := ioutil.WriteFile(scriptFile, []byte(tc.script), os.ModePerm)
10171009
if err != nil {
10181010
log.Fatal("Cannot create file for test", err)
10191011
}
@@ -1024,9 +1016,7 @@ func TestRunCommand_RunWithFile(t *testing.T) {
10241016
fakeIO := ui.NewFakeIO()
10251017
tc.command.io = fakeIO
10261018

1027-
tc.command.envFile = envFile
1028-
1029-
err = tc.command.Run()
1019+
err := tc.command.Run()
10301020
assert.Equal(t, err, tc.err)
10311021
assert.Equal(t, fakeIO.StdOut.String(), tc.expectedStdOut)
10321022
})

0 commit comments

Comments
 (0)