Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions opts/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ func (opts *ListOpts) Set(value string) error {
}

// Delete removes the specified element from the slice.
//
// Deprecated: this method is no longer used and will be removed in the next release.
func (opts *ListOpts) Delete(key string) {
for i, k := range *opts.values {
if k == key {
Expand Down
17 changes: 6 additions & 11 deletions opts/opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,11 @@ func TestListOptsWithoutValidator(t *testing.T) {
if o.Get("baz") {
t.Error(`o.Get("baz") == true`)
}
o.Delete("foo")
if o.String() != "[bar bar]" {
t.Errorf("%s != [bar bar]", o.String())
if listOpts := o.GetSlice(); len(listOpts) != 3 || listOpts[0] != "foo" || listOpts[1] != "bar" || listOpts[2] != "bar" {
t.Errorf("Expected [[foo bar bar]], got [%v]", listOpts)
}
if listOpts := o.GetSlice(); len(listOpts) != 2 || listOpts[0] != "bar" || listOpts[1] != "bar" {
t.Errorf("Expected [[bar bar]], got [%v]", listOpts)
}
if mapListOpts := o.GetMap(); len(mapListOpts) != 1 {
t.Errorf("Expected [map[bar:{}]], got [%v]", mapListOpts)
if mapListOpts := o.GetMap(); len(mapListOpts) != 2 {
t.Errorf("Expected [map[bar:{} foo:{}]], got [%v]", mapListOpts)
}
}

Expand Down Expand Up @@ -182,9 +178,8 @@ func TestListOptsWithValidator(t *testing.T) {
if o.Get("baz") {
t.Error(`o.Get("baz") == true`)
}
o.Delete("valid-option2=2")
if o.String() != "" {
t.Errorf(`%s != ""`, o.String())
if expected := "[valid-option2=2]"; o.String() != expected {
t.Errorf(`%s != %q`, o.String(), expected)
}
}

Expand Down
Loading