Skip to content

Commit

Permalink
Clean global state in flgs tests
Browse files Browse the repository at this point in the history
Signed-off-by: Cosmin Cojocar <gcojocar@adobe.com>
  • Loading branch information
ccojocar committed Oct 18, 2023
1 parent e108c56 commit bde2619
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ import (
var _ = Describe("Cli", func() {
Context("vflag test", func() {
It("value must be empty as parameter value contains invalid character", func() {
os.Args = []string{"gosec", "-test1=-incorrect"}
os.Args = []string{"gosec", "-flag1=-incorrect"}
f := vflag.ValidatedFlag{}
flag.Var(&f, "test1", "")
flag.CommandLine.Init("test1", flag.ContinueOnError)
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
flag.Var(&f, "falg1", "")
flag.CommandLine.Init("flag1", flag.ContinueOnError)
flag.Parse()
Expect(flag.Parsed()).Should(BeTrue())
Expect(f.Value).Should(Equal(``))
})
It("value must be empty as parameter value contains invalid character without equal sign", func() {
os.Args = []string{"gosec", "-test2= -incorrect"}
f := vflag.ValidatedFlag{}
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
flag.Var(&f, "test2", "")
flag.CommandLine.Init("test2", flag.ContinueOnError)
flag.Parse()
Expand Down

0 comments on commit bde2619

Please sign in to comment.