mirror of
https://github.com/securego/gosec.git
synced 2024-11-05 11:35:51 +00:00
Clean global state in flgs tests
Signed-off-by: Cosmin Cojocar <gcojocar@adobe.com>
This commit is contained in:
parent
e108c56933
commit
bde26196d0
1 changed files with 5 additions and 3 deletions
|
@ -13,10 +13,11 @@ 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(``))
|
||||
|
@ -24,6 +25,7 @@ var _ = Describe("Cli", func() {
|
|||
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()
|
||||
|
|
Loading…
Reference in a new issue