Created
October 5, 2021 18:11
-
-
Save karuppiah7890/129f99d4a46ddc4dd6f0b57441f30e0c to your computer and use it in GitHub Desktop.
Sample failing test in `TestMachineScope_PublicIPSpecs` test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestMachineScope_PublicIPSpecs(t *testing.T) { | |
tests := []struct { | |
name string | |
machineScope MachineScope | |
want []azure.PublicIPSpec | |
}{ | |
{ | |
name: "returns nil if AllocatePublicIP is false", | |
machineScope: MachineScope{ | |
AzureMachine: &infrav1.AzureMachine{ | |
ObjectMeta: metav1.ObjectMeta{ | |
Name: "machine-name", | |
}, | |
Spec: infrav1.AzureMachineSpec{ | |
AllocatePublicIP: false, | |
}, | |
}, | |
}, | |
want: nil, | |
}, | |
{ | |
name: "appends to PublicIPSpec for node if AllocatePublicIP is true", | |
machineScope: MachineScope{ | |
AzureMachine: &infrav1.AzureMachine{ | |
ObjectMeta: metav1.ObjectMeta{ | |
Name: "macine-name", | |
}, | |
Spec: infrav1.AzureMachineSpec{ | |
AllocatePublicIP: true, | |
}, | |
}, | |
}, | |
want: []azure.PublicIPSpec{ | |
{ | |
Name: "pip-machine-name", | |
}, | |
}, | |
}, | |
} | |
for _, tt := range tests { | |
t.Run(tt.name, func(t *testing.T) { | |
t.Parallel() | |
if got := tt.machineScope.PublicIPSpecs(); !reflect.DeepEqual(got, tt.want) { | |
t.Errorf("PublicIPSpecs() = %v, want %v", got, tt.want) | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment