mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
add unit test case for nodenames comparison
This commit is contained in:
parent
e30b6634c3
commit
a0786a2df5
@ -779,13 +779,21 @@ func TestServiceCache(t *testing.T) {
|
|||||||
//Test a utility functions as its not easy to unit test nodeSyncLoop directly
|
//Test a utility functions as its not easy to unit test nodeSyncLoop directly
|
||||||
func TestNodeSlicesEqualForLB(t *testing.T) {
|
func TestNodeSlicesEqualForLB(t *testing.T) {
|
||||||
numNodes := 10
|
numNodes := 10
|
||||||
nArray := make([]*v1.Node, 10)
|
nArray := make([]*v1.Node, numNodes)
|
||||||
|
mArray := make([]*v1.Node, numNodes)
|
||||||
for i := 0; i < numNodes; i++ {
|
for i := 0; i < numNodes; i++ {
|
||||||
nArray[i] = &v1.Node{}
|
nArray[i] = &v1.Node{}
|
||||||
nArray[i].Name = fmt.Sprintf("node1")
|
nArray[i].Name = fmt.Sprintf("node%d", i)
|
||||||
}
|
}
|
||||||
|
for i := 0; i < numNodes; i++ {
|
||||||
|
mArray[i] = &v1.Node{}
|
||||||
|
mArray[i].Name = fmt.Sprintf("node%d", i+1)
|
||||||
|
}
|
||||||
|
|
||||||
if !nodeSlicesEqualForLB(nArray, nArray) {
|
if !nodeSlicesEqualForLB(nArray, nArray) {
|
||||||
t.Errorf("nodeSlicesEqualForLB() Expected=true Obtained=false")
|
t.Errorf("nodeSlicesEqualForLB() Expected=true Obtained=false")
|
||||||
}
|
}
|
||||||
|
if nodeSlicesEqualForLB(nArray, mArray) {
|
||||||
|
t.Errorf("nodeSlicesEqualForLB() Expected=false Obtained=true")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user