-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: make config options be consistent with the cli style (#22)
* refactor: make config options be consistent with the cli style * refactor: remove Config struct * refactor: postpone config process to run Signed-off-by: Timon Wong <[email protected]> * revert some changes Signed-off-by: Timon Wong <[email protected]> * chore: improve coverage Signed-off-by: Timon Wong <[email protected]> * chore: fix lint Signed-off-by: Timon Wong <[email protected]> * chore: Add a codecov file Signed-off-by: Timon Wong <[email protected]> Signed-off-by: Timon Wong <[email protected]> Co-authored-by: Timon Wong <[email protected]>
- Loading branch information
Showing
12 changed files
with
201 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
coverage: | ||
range: 70..90 # green if 90+, red if 70- | ||
status: | ||
patch: | ||
# coverage status for pull request diff | ||
default: | ||
threshold: 0.5% # allow a little drop | ||
project: | ||
# coverage status for whole project | ||
default: | ||
target: auto # use coverage of base commit as target | ||
threshold: 0.5% # allow a little drop | ||
|
||
ignore: | ||
- "plugin/**" | ||
- "cmd/**" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package sets | ||
|
||
import ( | ||
"flag" | ||
"io" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestString(t *testing.T) { | ||
t.Parallel() | ||
|
||
set := NewString("logr", "logr", "klog") | ||
assert.Equal(t, []string{"klog", "logr"}, set.List()) | ||
assert.Equal(t, "klog,logr", set.String()) | ||
assert.True(t, set.Has("logr")) | ||
assert.True(t, set.Has("klog")) | ||
assert.False(t, set.Has("zap")) | ||
} | ||
|
||
func TestString_Flag(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
flagValue string | ||
want []string | ||
}{ | ||
{ | ||
name: "empty", | ||
flagValue: "", | ||
want: nil, | ||
}, | ||
{ | ||
name: "klog", | ||
flagValue: "klog", | ||
want: []string{"klog"}, | ||
}, | ||
{ | ||
name: "klog-and-logr", | ||
flagValue: "logr,klog", | ||
want: []string{"klog", "logr"}, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
tc := tc | ||
t.Run(tc.name, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
f := StringSet{} | ||
fs := flag.NewFlagSet("test", flag.ContinueOnError) | ||
fs.SetOutput(io.Discard) | ||
fs.Var(&f, "set", "") | ||
|
||
err := fs.Parse([]string{"-set=" + tc.flagValue}) | ||
require.NoError(t, err) | ||
assert.Equal(t, tc.want, f.List()) | ||
}) | ||
} | ||
} |
Oops, something went wrong.