File: filters_test.go

package info (click to toggle)
golang-github-containers-common 0.64.1%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 5,932 kB
  • sloc: makefile: 132; sh: 111
file content (46 lines) | stat: -rw-r--r-- 875 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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 {
		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())
				}
			}
		})
	}
}