-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
there was some eerily similar code in c/common and in podman for creating filter functions for various types. Move some of it here and add support for the label!= filter in libnetwork only. Libimage already supports it. after this merges, will file a PR with the fix for containers within podman as well see containers/podman#14182 Signed-off-by: Charlie Doern <[email protected]>
- Loading branch information
Showing
4 changed files
with
67 additions
and
4 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
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,47 @@ | ||
package util | ||
|
||
import "testing" | ||
|
||
func TestGenerateFilterFunc(t *testing.T) { | ||
testValues := []string{ | ||
"", | ||
"test", | ||
"", | ||
} | ||
type args struct { | ||
keys []string | ||
labels []string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want bool | ||
}{ | ||
{ | ||
name: "Match when all filters the same as labels", | ||
args: args{ | ||
keys: []string{"label", "label", "label"}, | ||
labels: testValues, | ||
}, | ||
want: true, | ||
}, | ||
{ | ||
name: "Match with inverse", | ||
args: args{ | ||
keys: []string{"label", "label", "label!"}, | ||
labels: testValues, | ||
}, | ||
want: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
for _, entry := range tt.args.keys { | ||
if _, err := createFilterFuncs(entry, tt.args.labels); err != nil { | ||
t.Errorf("createPruneFilterFuncs() failed on %s with entry %s: %s", tt.name, entry, err.Error()) | ||
} | ||
} | ||
}) | ||
} | ||
} |
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