From 4f06684b1e7139caa45a289fd4c6bf73aa87f235 Mon Sep 17 00:00:00 2001 From: Federico Di Pierro Date: Mon, 6 Nov 2023 09:23:46 +0100 Subject: [PATCH] fix(cmd): fixed root_test. Signed-off-by: Federico Di Pierro --- cmd/root_test.go | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/cmd/root_test.go b/cmd/root_test.go index d95cbd5f3..529d2c833 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -17,6 +17,7 @@ package cmd_test import ( "context" + "runtime" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -27,7 +28,7 @@ import ( commonoptions "github.com/falcosecurity/falcoctl/pkg/options" ) -var usage = ` +var usage_linux = ` __ _ _ _ / _| __ _| | ___ ___ ___| |_| | | |_ / _ | |/ __/ _ \ / __| __| | @@ -43,6 +44,7 @@ Usage: Available Commands: artifact Interact with Falco artifacts completion Generate the autocompletion script for the specified shell + driver Interact with falcosecurity driver help Help about any command index Interact with index registry Interact with OCI registries @@ -58,6 +60,44 @@ Flags: Use "falcoctl [command] --help" for more information about a command. ` +var usage_others = ` + __ _ _ _ + / _| __ _| | ___ ___ ___| |_| | + | |_ / _ | |/ __/ _ \ / __| __| | + | _| (_| | | (_| (_) | (__| |_| | + |_| \__,_|_|\___\___/ \___|\__|_| + + +The official CLI tool for working with Falco and its ecosystem components + +Usage: + falcoctl [command] + +Available Commands: + artifact Interact with Falco artifacts + completion Generate the autocompletion script for the specified shell + help Help about any command + index Interact with index + registry Interact with OCI registries + tls Generate and install TLS material for Falco + version Print the falcoctl version information + +Flags: + --config string config file to be used for falcoctl (default "/etc/falcoctl/falcoctl.yaml") + -h, --help help for falcoctl + --log-format string Set formatting for logs (color, text, json) (default "color") + --log-level string Set level for logs (info, warn, debug, trace) (default "info") + +Use "falcoctl [command] --help" for more information about a command. +` + +func getUsage() string { + if runtime.GOOS == "linux" { + return usage_linux + } + return usage_others +} + var _ = Describe("Root", func() { var ( rootCmd *cobra.Command @@ -93,7 +133,7 @@ var _ = Describe("Root", func() { It("Should print the usage message", func() { Expect(err).ShouldNot(HaveOccurred()) - Expect(string(outputBuf.Contents())).Should(Equal(usage)) + Expect(string(outputBuf.Contents())).Should(Equal(getUsage())) }) }) @@ -105,7 +145,7 @@ var _ = Describe("Root", func() { It("Should print the usage message", func() { Expect(err).ShouldNot(HaveOccurred()) - Expect(string(outputBuf.Contents())).Should(Equal(usage)) + Expect(string(outputBuf.Contents())).Should(Equal(getUsage())) }) }) @@ -117,7 +157,7 @@ var _ = Describe("Root", func() { It("Should print the usage message", func() { Expect(err).ShouldNot(HaveOccurred()) - Expect(string(outputBuf.Contents())).Should(Equal(usage)) + Expect(string(outputBuf.Contents())).Should(Equal(getUsage())) }) })