Skip to content

Commit

Permalink
Update LookupBool to return two bools
Browse files Browse the repository at this point in the history
Resolves: #1003 (comment)
  • Loading branch information
inancgumus committed Aug 18, 2023
1 parent 5d53ca4 commit 2797d09
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ func ConstLookup(k, v string) LookupFunc {
}

// LookupBool returns the result of Lookup as a bool.
// Returns false if the key does not exist or the value
// is not a bool.
func LookupBool(key string) bool {
// If the key does not exist or the value is not a valid bool, it returns false.
// Otherwise it returns the bool value and true.
func LookupBool(key string) (value bool, ok bool) {
v, ok := Lookup(key)
if !ok {
return false
return false, false
}
bv, err := strconv.ParseBool(v)
if err != nil {
return false
return false, true
}
return bv
return bv, true
}
4 changes: 2 additions & 2 deletions tests/frame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestFrameNoPanicWithEmbeddedIFrame(t *testing.T) {
// only surfaces when in headfull mode.
// Remove this skip once we have headfull mode in
// CI: https://github.com/grafana/xk6-browser/issues/678
if env.LookupBool(env.BrowserHeadless) {
if v, ok := env.LookupBool(env.BrowserHeadless); !ok || v {
t.Skip("skipped when in headless mode")
}

Expand Down Expand Up @@ -112,7 +112,7 @@ func TestFrameNoPanicNavigateAndClickOnPageWithIFrames(t *testing.T) {
// only surfaces when in headfull mode.
// Remove this skip once we have headfull mode in
// CI: https://github.com/grafana/xk6-browser/issues/678
if env.LookupBool(env.BrowserHeadless) {
if v, ok := env.LookupBool(env.BrowserHeadless); !ok || v {
t.Skip("skipped when in headless mode")
}

Expand Down

0 comments on commit 2797d09

Please sign in to comment.