Skip to content

Commit

Permalink
Remove runTestActionCmd and use runTestCmd instead
Browse files Browse the repository at this point in the history
`runTestCmd` is identical to `runTestActionCmd` except that it

  * runs the command multiple times if the `repeat` property is greater
    than zero,
  * calls its storage `storage` instead of `store`,
  * fails if the `Create` method returns an error, and
  * logs a "running cmd" message.

This is most easily demonstrated by copying the functions to their own
files and diffing the files with this command:

    git diff --no-index --ignore-space-change --color-words=. runTestActionCmd.go runTestCmd.go

Also, `runTestCmd` is used 32 times; `runTestActionCmd` only 1.

Signed-off-by: Simon Alling <alling.simon@gmail.com>
  • Loading branch information
SimonAlling committed Dec 10, 2021
1 parent 8ca4013 commit 0f15b01
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
21 changes: 0 additions & 21 deletions cmd/helm/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,6 @@ func runTestCmd(t *testing.T, tests []cmdTestCase) {
}
}

func runTestActionCmd(t *testing.T, tests []cmdTestCase) {
t.Helper()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
defer resetEnv()()

store := storageFixture()
for _, rel := range tt.rels {
store.Create(rel)
}
_, out, err := executeActionCommandC(store, tt.cmd)
if (err != nil) != tt.wantError {
t.Errorf("expected error, got '%v'", err)
}
if tt.golden != "" {
test.AssertGoldenString(t, out, tt.golden)
}
})
}
}

func storageFixture() *storage.Storage {
return storage.Init(driver.NewMemory())
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/helm/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func TestInstall(t *testing.T) {
},
}

runTestActionCmd(t, tests)
runTestCmd(t, tests)
}

func TestInstallOutputCompletion(t *testing.T) {
Expand Down

0 comments on commit 0f15b01

Please sign in to comment.