Skip to content

Commit

Permalink
fix(cmd): fixed root_test.
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Nov 6, 2023
1 parent df3d709 commit 4f06684
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package cmd_test

import (
"context"
"runtime"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand All @@ -27,7 +28,7 @@ import (
commonoptions "github.com/falcosecurity/falcoctl/pkg/options"
)

var usage = `
var usage_linux = `

Check warning on line 31 in cmd/root_test.go

View workflow job for this annotation

GitHub Actions / Lint golang files

var-naming: don't use underscores in Go names; var usage_linux should be usageLinux (revive)
__ _ _ _
/ _| __ _| | ___ ___ ___| |_| |
| |_ / _ | |/ __/ _ \ / __| __| |
Expand All @@ -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
Expand All @@ -58,6 +60,44 @@ Flags:
Use "falcoctl [command] --help" for more information about a command.
`

var usage_others = `

Check warning on line 63 in cmd/root_test.go

View workflow job for this annotation

GitHub Actions / Lint golang files

var-naming: don't use underscores in Go names; var usage_others should be usageOthers (revive)
__ _ _ _
/ _| __ _| | ___ ___ ___| |_| |
| |_ / _ | |/ __/ _ \ / __| __| |
| _| (_| | | (_| (_) | (__| |_| |
|_| \__,_|_|\___\___/ \___|\__|_|
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
Expand Down Expand Up @@ -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()))
})
})

Expand All @@ -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()))
})
})

Expand All @@ -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()))
})
})

Expand Down

0 comments on commit 4f06684

Please sign in to comment.