Commit ef9baf31 authored by nolancon's avatar nolancon

Update unit tests for TopologyHints - Topology Manager Policies

parent e82fa41f
...@@ -23,27 +23,25 @@ import ( ...@@ -23,27 +23,25 @@ import (
func TestCanAdmitPodResult1(t *testing.T) { func TestCanAdmitPodResult1(t *testing.T) {
tcases := []struct { tcases := []struct {
name string name string
affinity bool admit bool
expected bool expected bool
}{ }{
{ {
name: "Affinity is set to false in topology hints", name: "Affinity is set to false in topology hints",
affinity: false, admit: false,
expected: true, expected: true,
}, },
{ {
name: "Affinity is set to true in topology hints", name: "Affinity is set to true in topology hints",
affinity: true, admit: true,
expected: true, expected: true,
}, },
} }
for _, tc := range tcases { for _, tc := range tcases {
policy := NewPreferredPolicy() policy := NewPreferredPolicy()
hints := TopologyHints{ admit := tc.admit
Affinity: tc.affinity, result := policy.CanAdmitPodResult(admit)
}
result := policy.CanAdmitPodResult(hints)
if result.Admit != tc.expected { if result.Admit != tc.expected {
t.Errorf("Expected Admit field in result to be %t, got %t", tc.expected, result.Admit) t.Errorf("Expected Admit field in result to be %t, got %t", tc.expected, result.Admit)
......
...@@ -23,27 +23,25 @@ import ( ...@@ -23,27 +23,25 @@ import (
func TestCanAdmitPodResult(t *testing.T) { func TestCanAdmitPodResult(t *testing.T) {
tcases := []struct { tcases := []struct {
name string name string
affinity bool admit bool
expected bool expected bool
}{ }{
{ {
name: "Affinity is set to false in topology hints", name: "Affinity is set to false in topology hints",
affinity: false, admit: false,
expected: false, expected: false,
}, },
{ {
name: "Affinity is set to true in topology hints", name: "Affinity is set to true in topology hints",
affinity: true, admit: true,
expected: true, expected: true,
}, },
} }
for _, tc := range tcases { for _, tc := range tcases {
policy := NewStrictPolicy() policy := NewStrictPolicy()
hints := TopologyHints{ admit := tc.admit
Affinity: tc.affinity, result := policy.CanAdmitPodResult(admit)
}
result := policy.CanAdmitPodResult(hints)
if result.Admit != tc.expected { if result.Admit != tc.expected {
t.Errorf("Expected Admit field in result to be %t, got %t", tc.expected, result.Admit) t.Errorf("Expected Admit field in result to be %t, got %t", tc.expected, result.Admit)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment