Skip to content

Commit

Permalink
Remove reflect from flag_test
Browse files Browse the repository at this point in the history
  • Loading branch information
dearchap committed Apr 29, 2021
1 parent 50c71ed commit 7cd7ff7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions flag_test.go
Expand Up @@ -123,8 +123,13 @@ func TestFlagsFromEnv(t *testing.T) {
for i, test := range flagTests {
defer resetEnv(os.Environ())
os.Clearenv()
envVarSlice := reflect.Indirect(reflect.ValueOf(test.flag)).FieldByName("EnvVars").Slice(0, 1)
_ = os.Setenv(envVarSlice.Index(0).String(), test.input)

f, ok := test.flag.(DocGenerationFlag)
if !ok {
t.Errorf("flag %v needs to implement DocGenerationFlag to retrieve env vars", test.flag)
}
envVarSlice := f.GetEnvVars()
_ = os.Setenv(envVarSlice[0], test.input)

a := App{
Flags: []Flag{test.flag},
Expand Down

0 comments on commit 7cd7ff7

Please sign in to comment.