minishift: Some unit tests do not use testify

General information

We still do not use testify/assert for assertions in some of the units tests. Maybe we missed it in the review. Refer the old issue for using testify https://github.com/minishift/minishift/issues/250 and the patch at https://github.com/minishift/minishift/commit/838f4d50ce96e022f4990d37ba56704869b2f250

  • Minishift version: Latest Master i.e. acb558a890b0e3afb93304e57a418b355cbbda63

Actual

$ git grep 'Fatal'
cmd/minishift/cmd/delete_test.go:               t.Fatalf("Expected cache dir '%s' to be deleted", state.InstanceDirs.Cache)
cmd/minishift/cmd/delete_test.go:               t.Fatalf("Expected cache dir '%s' to still exist", state.InstanceDirs.Cache)
cmd/testing/cli/harness.go:             t.Fatal(err)
cmd/testing/cli/harness.go:             t.Fatalf("Unexpected error during setup: %s", err.Error())
cmd/testing/cli/harness.go:                     t.Fatalf("Expected error '%s'. Got '%s'.", expectedErrorMessage, tee.StderrBuffer.String())
cmd/testing/cli/harness.go:                     t.Fatalf("Expected exit code %d. Got %d.", expectedExitCode, code)
cmd/testing/cli/harness.go:             t.Fatal("The called method unexpectedly called atexit.")
cmd/testing/cli/harness.go:             t.Fatal(err)
cmd/testing/cli/harness.go:             t.Fatal(err)
cmd/testing/cli/harness.go:             t.Fatal(err)
cmd/testing/cli/viper.go:                       t.Fatalf("Config %s not read correctly: %v", testOption.ConfigValue, err)
pkg/minikube/kubeconfig/config_test.go:         t.Fatalf("Error delete file %s", testSystemConfigPath)
pkg/minikube/machine/client_test.go:            log.Fatal(err)
pkg/minishift/addon/manager/addon_manager_test.go:              t.Fatal(fmt.Sprintf("No error expected, but got: \"%s\"", err.Error()))
pkg/minishift/provisioner/minishift_detector_test.go:           t.Fatalf("Error starting ssh server: %s", err)
pkg/minishift/registration/redhat_test.go:              t.Fatalf("Error starting ssh server: %s", err)
pkg/testing/assert.go:          t.Fatalf("String slices do not match. Expected %v, got %v", expected, actual)
pkg/testing/assert.go:          t.Fatalf("String slices differ in length. Expected %v, got %v", expected, actual)
pkg/testing/assert.go:                  t.Fatalf("%s and %s differ. Expected %v, got %v", expected[i], actual[i], expected, actual)
pkg/testing/runner_mock.go:     t.Fatalf("Expected: %+v, Got: %+v\n", argStringOption, expectCommands[0].commandArgs)
pkg/testing/tee_test.go:                t.Fatalf("Unexpected error: %s", err.Error())
pkg/util/utils_test.go:         t.Fatal("Unpexpected OS")
pkg/util/utils_test.go:         t.Fatal("Unpexpected OS")
pkg/util/utils_test.go:         t.Fatal("Unpexpected OS")

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20 (20 by maintainers)

Commits related to this issue

Most upvoted comments

@budhrg works for me.

getAddOnMetadata is not a proper helper function and should be removed. We should however use

addOnMeta, err := addon.NewAddOnMeta(testMap)
assert.NoError(t, err, "message")

IMO, the proper helper function is getTestAddonMap.

I see below in delete_test.go


	if filehelper.Exists(state.InstanceDirs.Cache) {
		t.Fatalf("Expected cache dir '%s' to be deleted", state.InstanceDirs.Cache)
	}

Which can be fixed by using https://godoc.org/github.com/stretchr/testify/assert#DirExists