Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config with env #1072

Merged
merged 3 commits into from
Aug 31, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add more test
  • Loading branch information
suchen-sci committed Aug 30, 2023
commit dd02d5d2fe2f5de194dea02ac7973b932c7da1ea
21 changes: 21 additions & 0 deletions pkg/option/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,27 @@ func TestSetFlagsFromEnv(t *testing.T) {
assert.Equal(1, intFlag)
}

func TestSetFlagsFromEnvFail(t *testing.T) {
assert := assert.New(t)

reset := resetEnv()
defer reset()
os.Setenv("EASEGRESS_TEST_BOOL", "123")

var boolFlag bool
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
flags.BoolVar(&boolFlag, "test-bool", false, "test bool flag")

err := SetFlagsFromEnv("EASEGRESS", flags)
assert.Error(err)

os.Setenv("EASEGRESS_VERSION", "not-a-bool")
// options from env
opt := New()
err = opt.Parse()
assert.Error(err)
}

func TestOptionFromEnv(t *testing.T) {
assert := assert.New(t)

Expand Down
Loading