mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-05 20:40:16 -08:00
test(flag): enhance TestCustomFlagGroups to include environment variable support
- Added a test case to verify the behavior of the `TRIVY_FOO` environment variable in the `TestCustomFlagGroups` function. - Ensured that the flag system correctly retrieves values from both environment variables and custom flags. - Improved test coverage for the flag handling functionality.
This commit is contained in:
@@ -90,7 +90,14 @@ func TestCustomFlagGroups(t *testing.T) {
|
||||
testOpts := extractTestOptions(t, opts)
|
||||
assert.Equal(t, "default-value", testOpts.Foo)
|
||||
|
||||
// Test
|
||||
// Test with environment variable
|
||||
t.Setenv("TRIVY_FOO", "env-value")
|
||||
opts, err = flags.ToOptions(nil)
|
||||
require.NoError(t, err)
|
||||
testOpts = extractTestOptions(t, opts)
|
||||
assert.Equal(t, "env-value", testOpts.Foo)
|
||||
|
||||
// Test with flag
|
||||
viper.Set(foo.ConfigName, "custom-value")
|
||||
opts, err = flags.ToOptions(nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user