Refactor the test to use one single node
@@ -84,52 +84,40 @@ func Test_getSeccompLocalhostProfile(t *testing.T) {
t.Parallel()
tests := []struct {
name string
- nodes *corev1.NodeList
+ node *corev1.Node
want string
}{
{
name: "Should return local seccomp profile for cri-o runtime",
- nodes: &corev1.NodeList{
- Items: []corev1.Node{
- {
+ node: &corev1.Node{
Status: corev1.NodeStatus{
NodeInfo: corev1.NodeSystemInfo{
ContainerRuntimeVersion: "cri-o://1.2.3",
},
},
},
- },
- },
want: path.Join("localhost", bindata.LocalSeccompProfilePath),
},
{
name: "Should return local seccomp profile for docker runtime",
- nodes: &corev1.NodeList{
- Items: []corev1.Node{
- {
+ node: &corev1.Node{
Status: corev1.NodeStatus{
NodeInfo: corev1.NodeSystemInfo{
ContainerRuntimeVersion: "docker://1.2.3",
},
},
},
- },
- },
want: bindata.LocalSeccompProfilePath,
},
{
name: "Should return local seccomp profile for containerd runtime",
- nodes: &corev1.NodeList{
- Items: []corev1.Node{
- {
+ node: &corev1.Node{
Status: corev1.NodeStatus{
NodeInfo: corev1.NodeSystemInfo{
ContainerRuntimeVersion: "containerd://1.2.3",
},
},
},
- },
- },
want: bindata.LocalSeccompProfilePath,
},
}
@@ -137,7 +125,7 @@ func Test_getSeccompLocalhostProfile(t *testing.T) {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
- got := getSeccompLocalhostProfile(tt.nodes)
+ got := getSeccompLocalhostProfile(tt.node)
require.Equal(t, tt.want, got)
})
}
