Update unit tests for TopologyHints - Topology Manager Policies
This commit is contained in:
		@@ -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 (
 | 
				
			|||||||
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)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user