diff --git a/Makefile b/Makefile index fa499d5d..d7ebe46d 100644 --- a/Makefile +++ b/Makefile @@ -40,10 +40,10 @@ cleanup-kind: rm $(TEST_KUBECONFIG) test: $(EMBEDDED_MANIFESTS_TARGET) tidy fmt vet - go test ./... -coverprofile cover.out + go test ./... -coverprofile cover.out --tags=unit e2e: $(EMBEDDED_MANIFESTS_TARGET) tidy fmt vet - TEST_KUBECONFIG=$(TEST_KUBECONFIG) go test ./cmd/flux/... -coverprofile cover.out --tags=e2e -parallel=1 + TEST_KUBECONFIG=$(TEST_KUBECONFIG) go test ./cmd/flux/... -coverprofile e2e.cover.out --tags=e2e -v -failfast test-with-kind: setup-envtest make setup-kind diff --git a/cmd/flux/get.go b/cmd/flux/get.go index d1745b39..5aca72ab 100644 --- a/cmd/flux/get.go +++ b/cmd/flux/get.go @@ -177,7 +177,7 @@ func (get getCommand) run(cmd *cobra.Command, args []string) error { return err } - utils.PrintTable(os.Stdout, header, rows) + utils.PrintTable(cmd.OutOrStderr(), header, rows) if getAll { fmt.Println() diff --git a/cmd/flux/helmrelease_test.go b/cmd/flux/helmrelease_test.go new file mode 100644 index 00000000..716bcaba --- /dev/null +++ b/cmd/flux/helmrelease_test.go @@ -0,0 +1,57 @@ +// +build e2e + +package main + +import "testing" + +func TestHelmReleaseFromGit(t *testing.T) { + cases := []struct { + args string + goldenFile string + }{ + { + "create source git thrfg --url=https://github.com/stefanprodan/podinfo --branch=main --tag=6.0.0", + "testdata/helmrelease/create_source_git.golden", + }, + { + "create helmrelease thrfg --source=GitRepository/thrfg --chart=./charts/podinfo", + "testdata/helmrelease/create_helmrelease_from_git.golden", + }, + { + "get helmrelease thrfg", + "testdata/helmrelease/get_helmrelease_from_git.golden", + }, + { + "reconcile helmrelease thrfg --with-source", + "testdata/helmrelease/reconcile_helmrelease_from_git.golden", + }, + { + "suspend helmrelease thrfg", + "testdata/helmrelease/suspend_helmrelease_from_git.golden", + }, + { + "resume helmrelease thrfg", + "testdata/helmrelease/resume_helmrelease_from_git.golden", + }, + { + "delete helmrelease thrfg --silent", + "testdata/helmrelease/delete_helmrelease_from_git.golden", + }, + } + + namespace := "thrfg" + del, err := setupTestNamespace(namespace) + if err != nil { + t.Fatal(err) + } + defer del() + + for _, tc := range cases { + cmd := cmdTestCase{ + args: tc.args + " -n=" + namespace, + goldenFile: tc.goldenFile, + testClusterMode: ExistingClusterMode, + } + cmd.runTestCmd(t) + } +} diff --git a/cmd/flux/install_test.go b/cmd/flux/install_test.go deleted file mode 100644 index 35d532f3..00000000 --- a/cmd/flux/install_test.go +++ /dev/null @@ -1,54 +0,0 @@ -// +build e2e - -package main - -import ( - "testing" - "time" -) - -func TestInstallNoArgs(t *testing.T) { - cmd := cmdTestCase{ - args: "install", - wantError: false, - testClusterMode: ExistingClusterMode, - goldenFile: "testdata/install/install_no_args.golden", - } - cmd.runTestCmd(t) - - testUninstallSilent(t) - time.Sleep(30 * time.Second) -} - -func TestInstallExtraComponents(t *testing.T) { - cmd := cmdTestCase{ - args: "install --components-extra=image-reflector-controller,image-automation-controller", - wantError: false, - testClusterMode: ExistingClusterMode, - goldenFile: "testdata/install/install_extra_components.golden", - } - cmd.runTestCmd(t) - - testUninstallSilentForExtraComponents(t) - time.Sleep(30 * time.Second) -} - -func testUninstallSilent(t *testing.T) { - cmd := cmdTestCase{ - args: "uninstall -s", - wantError: false, - testClusterMode: ExistingClusterMode, - goldenFile: "testdata/uninstall/uninstall.golden", - } - cmd.runTestCmd(t) -} - -func testUninstallSilentForExtraComponents(t *testing.T) { - cmd := cmdTestCase{ - args: "uninstall -s", - wantError: false, - testClusterMode: ExistingClusterMode, - goldenFile: "testdata/uninstall/uninstall_extra_components.golden", - } - cmd.runTestCmd(t) -} diff --git a/cmd/flux/kustomization_test.go b/cmd/flux/kustomization_test.go new file mode 100644 index 00000000..92c14a6f --- /dev/null +++ b/cmd/flux/kustomization_test.go @@ -0,0 +1,57 @@ +// +build e2e + +package main + +import "testing" + +func TestKustomizationFromGit(t *testing.T) { + cases := []struct { + args string + goldenFile string + }{ + { + "create source git tkfg --url=https://github.com/stefanprodan/podinfo --branch=main --tag=6.0.0", + "testdata/kustomization/create_source_git.golden", + }, + { + "create kustomization tkfg --source=tkfg --path=./deploy/overlays/dev --prune=true --interval=5m --validation=client --health-check=Deployment/frontend.dev --health-check=Deployment/backend.dev --health-check-timeout=3m", + "testdata/kustomization/create_kustomization_from_git.golden", + }, + { + "get kustomization tkfg", + "testdata/kustomization/get_kustomization_from_git.golden", + }, + { + "reconcile kustomization tkfg --with-source", + "testdata/kustomization/reconcile_kustomization_from_git.golden", + }, + { + "suspend kustomization tkfg", + "testdata/kustomization/suspend_kustomization_from_git.golden", + }, + { + "resume kustomization tkfg", + "testdata/kustomization/resume_kustomization_from_git.golden", + }, + { + "delete kustomization tkfg --silent", + "testdata/kustomization/delete_kustomization_from_git.golden", + }, + } + + namespace := "tkfg" + del, err := setupTestNamespace(namespace) + if err != nil { + t.Fatal(err) + } + defer del() + + for _, tc := range cases { + cmd := cmdTestCase{ + args: tc.args + " -n=" + namespace, + goldenFile: tc.goldenFile, + testClusterMode: ExistingClusterMode, + } + cmd.runTestCmd(t) + } +} diff --git a/cmd/flux/main_e2e_test.go b/cmd/flux/main_e2e_test.go new file mode 100644 index 00000000..23f06f04 --- /dev/null +++ b/cmd/flux/main_e2e_test.go @@ -0,0 +1,59 @@ +// +build e2e + +package main + +import ( + "context" + "fmt" + "os" + "testing" + + "github.com/fluxcd/flux2/internal/utils" +) + +func TestMain(m *testing.M) { + // Ensure tests print consistent timestamps regardless of timezone + os.Setenv("TZ", "UTC") + + // Install Flux + km, err := NewTestEnvKubeManager(ExistingClusterMode) + if err != nil { + panic(fmt.Errorf("error creating kube manager: '%w'", err)) + } + rootCtx.kubeManager = km + output, err := executeCommand("install --components-extra=image-reflector-controller,image-automation-controller") + if err != nil { + panic(fmt.Errorf("install falied: %s error:'%w'", output, err)) + } + + // Run tests + code := m.Run() + + // Uninstall Flux + output, err = executeCommand("uninstall -s --keep-namespace") + if err != nil { + panic(fmt.Errorf("uninstall falied: %s error:'%w'", output, err)) + } + + // Delete namespace and wait for finalisation + kubectlArgs := []string{"delete", "namespace", "flux-system"} + _, err = utils.ExecKubectlCommand(context.TODO(), utils.ModeStderrOS, rootArgs.kubeconfig, rootArgs.kubecontext, kubectlArgs...) + if err != nil { + panic(fmt.Errorf("delete namespace error:'%w'", err)) + } + + os.Exit(code) +} + +func setupTestNamespace(namespace string) (func(), error) { + kubectlArgs := []string{"create", "namespace", namespace} + _, err := utils.ExecKubectlCommand(context.TODO(), utils.ModeStderrOS, rootArgs.kubeconfig, rootArgs.kubecontext, kubectlArgs...) + if err != nil { + return nil, err + } + + return func() { + kubectlArgs := []string{"delete", "namespace", namespace} + utils.ExecKubectlCommand(context.TODO(), utils.ModeCapture, rootArgs.kubeconfig, rootArgs.kubecontext, kubectlArgs...) + }, nil +} diff --git a/cmd/flux/main_test.go b/cmd/flux/main_test.go index 3a4b9762..c7cd3627 100644 --- a/cmd/flux/main_test.go +++ b/cmd/flux/main_test.go @@ -23,12 +23,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/envtest" ) -func TestMain(m *testing.M) { - // Ensure tests print consistent timestamps regardless of timezone - os.Setenv("TZ", "UTC") - os.Exit(m.Run()) -} - func readYamlObjects(objectFile string) ([]client.Object, error) { obj, err := os.ReadFile(objectFile) if err != nil { @@ -245,11 +239,3 @@ func executeCommand(cmd string) (string, error) { return result, err } - -func TestVersion(t *testing.T) { - cmd := cmdTestCase{ - args: "--version", - goldenValue: "flux version 0.0.0-dev.0\n", - } - cmd.runTestCmd(t) -} diff --git a/cmd/flux/main_unit_test.go b/cmd/flux/main_unit_test.go new file mode 100644 index 00000000..1a1a69a9 --- /dev/null +++ b/cmd/flux/main_unit_test.go @@ -0,0 +1,14 @@ +// +build unit + +package main + +import ( + "os" + "testing" +) + +func TestMain(m *testing.M) { + // Ensure tests print consistent timestamps regardless of timezone + os.Setenv("TZ", "UTC") + os.Exit(m.Run()) +} diff --git a/cmd/flux/testdata/helmrelease/create_helmrelease_from_git.golden b/cmd/flux/testdata/helmrelease/create_helmrelease_from_git.golden new file mode 100644 index 00000000..d5f35515 --- /dev/null +++ b/cmd/flux/testdata/helmrelease/create_helmrelease_from_git.golden @@ -0,0 +1,6 @@ +✚ generating HelmRelease +► applying HelmRelease +✔ HelmRelease created +◎ waiting for HelmRelease reconciliation +✔ HelmRelease thrfg is ready +✔ applied revision 6.0.0 diff --git a/cmd/flux/testdata/helmrelease/create_source_git.golden b/cmd/flux/testdata/helmrelease/create_source_git.golden new file mode 100644 index 00000000..e7db754b --- /dev/null +++ b/cmd/flux/testdata/helmrelease/create_source_git.golden @@ -0,0 +1,6 @@ +✚ generating GitRepository source +► applying GitRepository source +✔ GitRepository source created +◎ waiting for GitRepository source reconciliation +✔ GitRepository source reconciliation completed +✔ fetched revision: 6.0.0/627d5c4bb67b77185f37e31d734b085019ff2951 diff --git a/cmd/flux/testdata/helmrelease/delete_helmrelease_from_git.golden b/cmd/flux/testdata/helmrelease/delete_helmrelease_from_git.golden new file mode 100644 index 00000000..6f8c2000 --- /dev/null +++ b/cmd/flux/testdata/helmrelease/delete_helmrelease_from_git.golden @@ -0,0 +1,2 @@ +► deleting helmreleases thrfg in thrfg namespace +✔ helmreleases deleted diff --git a/cmd/flux/testdata/helmrelease/get_helmrelease_from_git.golden b/cmd/flux/testdata/helmrelease/get_helmrelease_from_git.golden new file mode 100644 index 00000000..1cfeacc3 --- /dev/null +++ b/cmd/flux/testdata/helmrelease/get_helmrelease_from_git.golden @@ -0,0 +1,2 @@ +NAME READY MESSAGE REVISION SUSPENDED +thrfg True Release reconciliation succeeded 6.0.0 False diff --git a/cmd/flux/testdata/helmrelease/reconcile_helmrelease_from_git.golden b/cmd/flux/testdata/helmrelease/reconcile_helmrelease_from_git.golden new file mode 100644 index 00000000..b8234099 --- /dev/null +++ b/cmd/flux/testdata/helmrelease/reconcile_helmrelease_from_git.golden @@ -0,0 +1,10 @@ +► annotating GitRepository thrfg in thrfg namespace +✔ GitRepository annotated +◎ waiting for GitRepository reconciliation +✔ GitRepository reconciliation completed +✔ fetched revision 6.0.0/627d5c4bb67b77185f37e31d734b085019ff2951 +► annotating HelmRelease thrfg in thrfg namespace +✔ HelmRelease annotated +◎ waiting for HelmRelease reconciliation +✔ HelmRelease reconciliation completed +✔ applied revision 6.0.0 diff --git a/cmd/flux/testdata/helmrelease/resume_helmrelease_from_git.golden b/cmd/flux/testdata/helmrelease/resume_helmrelease_from_git.golden new file mode 100644 index 00000000..cf9f0cd1 --- /dev/null +++ b/cmd/flux/testdata/helmrelease/resume_helmrelease_from_git.golden @@ -0,0 +1,5 @@ +► resuming helmreleases thrfg in thrfg namespace +✔ helmreleases resumed +◎ waiting for HelmRelease reconciliation +✔ HelmRelease reconciliation completed +✔ applied revision 6.0.0 diff --git a/cmd/flux/testdata/helmrelease/suspend_helmrelease_from_git.golden b/cmd/flux/testdata/helmrelease/suspend_helmrelease_from_git.golden new file mode 100644 index 00000000..ece07ad3 --- /dev/null +++ b/cmd/flux/testdata/helmrelease/suspend_helmrelease_from_git.golden @@ -0,0 +1,2 @@ +► suspending helmreleases thrfg in thrfg namespace +✔ helmreleases suspended diff --git a/cmd/flux/testdata/install/install_extra_components.golden b/cmd/flux/testdata/install/install_extra_components.golden deleted file mode 100644 index c11f58d3..00000000 --- a/cmd/flux/testdata/install/install_extra_components.golden +++ /dev/null @@ -1,11 +0,0 @@ -✚ generating manifests -✔ manifests build completed -► installing components in flux-system namespace -◎ verifying installation -✔ helm-controller: deployment ready -✔ image-automation-controller: deployment ready -✔ image-reflector-controller: deployment ready -✔ kustomize-controller: deployment ready -✔ notification-controller: deployment ready -✔ source-controller: deployment ready -✔ install finished diff --git a/cmd/flux/testdata/install/install_no_args.golden b/cmd/flux/testdata/install/install_no_args.golden deleted file mode 100644 index 8958465f..00000000 --- a/cmd/flux/testdata/install/install_no_args.golden +++ /dev/null @@ -1,9 +0,0 @@ -✚ generating manifests -✔ manifests build completed -► installing components in flux-system namespace -◎ verifying installation -✔ helm-controller: deployment ready -✔ kustomize-controller: deployment ready -✔ notification-controller: deployment ready -✔ source-controller: deployment ready -✔ install finished diff --git a/cmd/flux/testdata/kustomization/create_kustomization_from_git.golden b/cmd/flux/testdata/kustomization/create_kustomization_from_git.golden new file mode 100644 index 00000000..82fa5938 --- /dev/null +++ b/cmd/flux/testdata/kustomization/create_kustomization_from_git.golden @@ -0,0 +1,6 @@ +✚ generating Kustomization +► applying Kustomization +✔ Kustomization created +◎ waiting for Kustomization reconciliation +✔ Kustomization tkfg is ready +✔ applied revision 6.0.0/627d5c4bb67b77185f37e31d734b085019ff2951 diff --git a/cmd/flux/testdata/kustomization/create_source_git.golden b/cmd/flux/testdata/kustomization/create_source_git.golden new file mode 100644 index 00000000..e7db754b --- /dev/null +++ b/cmd/flux/testdata/kustomization/create_source_git.golden @@ -0,0 +1,6 @@ +✚ generating GitRepository source +► applying GitRepository source +✔ GitRepository source created +◎ waiting for GitRepository source reconciliation +✔ GitRepository source reconciliation completed +✔ fetched revision: 6.0.0/627d5c4bb67b77185f37e31d734b085019ff2951 diff --git a/cmd/flux/testdata/kustomization/delete_kustomization_from_git.golden b/cmd/flux/testdata/kustomization/delete_kustomization_from_git.golden new file mode 100644 index 00000000..278fb6db --- /dev/null +++ b/cmd/flux/testdata/kustomization/delete_kustomization_from_git.golden @@ -0,0 +1,2 @@ +► deleting kustomizations tkfg in tkfg namespace +✔ kustomizations deleted diff --git a/cmd/flux/testdata/kustomization/get_kustomization_from_git.golden b/cmd/flux/testdata/kustomization/get_kustomization_from_git.golden new file mode 100644 index 00000000..3c21df33 --- /dev/null +++ b/cmd/flux/testdata/kustomization/get_kustomization_from_git.golden @@ -0,0 +1,2 @@ +NAME READY MESSAGE REVISION SUSPENDED +tkfg True Applied revision: 6.0.0/627d5c4bb67b77185f37e31d734b085019ff2951 6.0.0/627d5c4bb67b77185f37e31d734b085019ff2951 False diff --git a/cmd/flux/testdata/kustomization/reconcile_kustomization_from_git.golden b/cmd/flux/testdata/kustomization/reconcile_kustomization_from_git.golden new file mode 100644 index 00000000..0f2743d2 --- /dev/null +++ b/cmd/flux/testdata/kustomization/reconcile_kustomization_from_git.golden @@ -0,0 +1,10 @@ +► annotating GitRepository tkfg in tkfg namespace +✔ GitRepository annotated +◎ waiting for GitRepository reconciliation +✔ GitRepository reconciliation completed +✔ fetched revision 6.0.0/627d5c4bb67b77185f37e31d734b085019ff2951 +► annotating Kustomization tkfg in tkfg namespace +✔ Kustomization annotated +◎ waiting for Kustomization reconciliation +✔ Kustomization reconciliation completed +✔ applied revision 6.0.0/627d5c4bb67b77185f37e31d734b085019ff2951 diff --git a/cmd/flux/testdata/kustomization/resume_kustomization_from_git.golden b/cmd/flux/testdata/kustomization/resume_kustomization_from_git.golden new file mode 100644 index 00000000..c6f66d23 --- /dev/null +++ b/cmd/flux/testdata/kustomization/resume_kustomization_from_git.golden @@ -0,0 +1,5 @@ +► resuming kustomizations tkfg in tkfg namespace +✔ kustomizations resumed +◎ waiting for Kustomization reconciliation +✔ Kustomization reconciliation completed +✔ applied revision 6.0.0/627d5c4bb67b77185f37e31d734b085019ff2951 diff --git a/cmd/flux/testdata/kustomization/suspend_kustomization_from_git.golden b/cmd/flux/testdata/kustomization/suspend_kustomization_from_git.golden new file mode 100644 index 00000000..5e593e6a --- /dev/null +++ b/cmd/flux/testdata/kustomization/suspend_kustomization_from_git.golden @@ -0,0 +1,2 @@ +► suspending kustomizations tkfg in tkfg namespace +✔ kustomizations suspended diff --git a/cmd/flux/testdata/uninstall/uninstall.golden b/cmd/flux/testdata/uninstall/uninstall.golden deleted file mode 100644 index e75944ed..00000000 --- a/cmd/flux/testdata/uninstall/uninstall.golden +++ /dev/null @@ -1,31 +0,0 @@ -► deleting components in flux-system namespace -✔ Deployment/flux-system/helm-controller deleted -✔ Deployment/flux-system/kustomize-controller deleted -✔ Deployment/flux-system/notification-controller deleted -✔ Deployment/flux-system/source-controller deleted -✔ Service/flux-system/notification-controller deleted -✔ Service/flux-system/source-controller deleted -✔ Service/flux-system/webhook-receiver deleted -✔ NetworkPolicy/flux-system/allow-egress deleted -✔ NetworkPolicy/flux-system/allow-scraping deleted -✔ NetworkPolicy/flux-system/allow-webhooks deleted -✔ ServiceAccount/flux-system/helm-controller deleted -✔ ServiceAccount/flux-system/kustomize-controller deleted -✔ ServiceAccount/flux-system/notification-controller deleted -✔ ServiceAccount/flux-system/source-controller deleted -✔ ClusterRole/crd-controller-flux-system deleted -✔ ClusterRoleBinding/cluster-reconciler-flux-system deleted -✔ ClusterRoleBinding/crd-controller-flux-system deleted -► deleting toolkit.fluxcd.io finalizers in all namespaces -► deleting toolkit.fluxcd.io custom resource definitions -✔ CustomResourceDefinition/alerts.notification.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/buckets.source.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/gitrepositories.source.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/helmcharts.source.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/helmreleases.helm.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/helmrepositories.source.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/kustomizations.kustomize.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/providers.notification.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/receivers.notification.toolkit.fluxcd.io deleted -✔ Namespace/flux-system deleted -✔ uninstall finished diff --git a/cmd/flux/testdata/uninstall/uninstall_extra_components.golden b/cmd/flux/testdata/uninstall/uninstall_extra_components.golden deleted file mode 100644 index f81c6cf8..00000000 --- a/cmd/flux/testdata/uninstall/uninstall_extra_components.golden +++ /dev/null @@ -1,38 +0,0 @@ -► deleting components in flux-system namespace -✔ Deployment/flux-system/helm-controller deleted -✔ Deployment/flux-system/image-automation-controller deleted -✔ Deployment/flux-system/image-reflector-controller deleted -✔ Deployment/flux-system/kustomize-controller deleted -✔ Deployment/flux-system/notification-controller deleted -✔ Deployment/flux-system/source-controller deleted -✔ Service/flux-system/notification-controller deleted -✔ Service/flux-system/source-controller deleted -✔ Service/flux-system/webhook-receiver deleted -✔ NetworkPolicy/flux-system/allow-egress deleted -✔ NetworkPolicy/flux-system/allow-scraping deleted -✔ NetworkPolicy/flux-system/allow-webhooks deleted -✔ ServiceAccount/flux-system/helm-controller deleted -✔ ServiceAccount/flux-system/image-automation-controller deleted -✔ ServiceAccount/flux-system/image-reflector-controller deleted -✔ ServiceAccount/flux-system/kustomize-controller deleted -✔ ServiceAccount/flux-system/notification-controller deleted -✔ ServiceAccount/flux-system/source-controller deleted -✔ ClusterRole/crd-controller-flux-system deleted -✔ ClusterRoleBinding/cluster-reconciler-flux-system deleted -✔ ClusterRoleBinding/crd-controller-flux-system deleted -► deleting toolkit.fluxcd.io finalizers in all namespaces -► deleting toolkit.fluxcd.io custom resource definitions -✔ CustomResourceDefinition/alerts.notification.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/buckets.source.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/gitrepositories.source.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/helmcharts.source.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/helmreleases.helm.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/helmrepositories.source.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/imagepolicies.image.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/imagerepositories.image.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/imageupdateautomations.image.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/kustomizations.kustomize.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/providers.notification.toolkit.fluxcd.io deleted -✔ CustomResourceDefinition/receivers.notification.toolkit.fluxcd.io deleted -✔ Namespace/flux-system deleted -✔ uninstall finished diff --git a/cmd/flux/trace_test.go b/cmd/flux/trace_test.go index 83847d23..c0b538e3 100644 --- a/cmd/flux/trace_test.go +++ b/cmd/flux/trace_test.go @@ -1,4 +1,4 @@ -// +build !e2e +// +build unit package main diff --git a/cmd/flux/version_test.go b/cmd/flux/version_test.go new file mode 100644 index 00000000..94419bc0 --- /dev/null +++ b/cmd/flux/version_test.go @@ -0,0 +1,15 @@ +// +build unit + +package main + +import ( + "testing" +) + +func TestVersion(t *testing.T) { + cmd := cmdTestCase{ + args: "--version", + goldenValue: "flux version 0.0.0-dev.0\n", + } + cmd.runTestCmd(t) +}