File: labels_test.go

package info (click to toggle)
docker.io 28.5.2%2Bdfsg3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 68,176 kB
  • sloc: sh: 5,867; makefile: 863; ansic: 184; python: 162; asm: 159
file content (60 lines) | stat: -rw-r--r-- 971 bytes parent folder | download
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package netlabel

import (
	"testing"

	"gotest.tools/v3/assert"
)

func TestGetIfname(t *testing.T) {
	testcases := []struct {
		name      string
		opts      map[string]interface{}
		expIfname string
	}{
		{
			name:      "nil opts",
			opts:      nil,
			expIfname: "",
		},
		{
			name:      "no ifname",
			opts:      map[string]interface{}{},
			expIfname: "",
		},
		{
			name: "ifname set",
			opts: map[string]interface{}{
				Ifname: "foobar",
			},
			expIfname: "foobar",
		},
		{
			name: "ifname set to empty string",
			opts: map[string]interface{}{
				Ifname: "",
			},
			expIfname: "",
		},
		{
			name: "ifname set to nil",
			opts: map[string]interface{}{
				Ifname: nil,
			},
			expIfname: "",
		},
		{
			name: "ifname set to int",
			opts: map[string]interface{}{
				Ifname: 42,
			},
			expIfname: "",
		},
	}

	for _, tc := range testcases {
		t.Run(tc.name, func(t *testing.T) {
			assert.Equal(t, tc.expIfname, GetIfname(tc.opts))
		})
	}
}