Skip to content

Commit

Permalink
Remove redundant machine initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
shysank committed Oct 28, 2020
1 parent e628a69 commit 2c8630f
Showing 1 changed file with 32 additions and 46 deletions.
78 changes: 32 additions & 46 deletions cloud/services/disks/disks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,43 +129,24 @@ func TestDeleteDisk(t *testing.T) {

func TestDiskSpecs(t *testing.T) {
testcases := []struct {
name string
azureMachine *infrav1.AzureMachine
expectedDisks []azure.DiskSpec
name string
azureMachineModifyFunc func(*infrav1.AzureMachine)
expectedDisks []azure.DiskSpec
}{
{
name: "only os disk",
azureMachine: &infrav1.AzureMachine{
ObjectMeta: metav1.ObjectMeta{
Name: "my-azure-machine",
},
Spec: infrav1.AzureMachineSpec{
OSDisk: infrav1.OSDisk{
DiskSizeGB: 30,
OSType: "Linux",
},
},
},
name: "only os disk",
azureMachineModifyFunc: func(m *infrav1.AzureMachine) {},
expectedDisks: []azure.DiskSpec{
{
Name: "my-azure-machine_OSDisk",
},
},
}, {
name: "os and data disks",
azureMachine: &infrav1.AzureMachine{
ObjectMeta: metav1.ObjectMeta{
Name: "my-azure-machine",
},
Spec: infrav1.AzureMachineSpec{
OSDisk: infrav1.OSDisk{
DiskSizeGB: 30,
OSType: "Linux",
},
DataDisks: []infrav1.DataDisk{{
NameSuffix: "etcddisk",
}},
},
azureMachineModifyFunc: func(m *infrav1.AzureMachine) {
m.Spec.DataDisks = []infrav1.DataDisk{{
NameSuffix: "etcddisk",
}}
},
expectedDisks: []azure.DiskSpec{
{
Expand All @@ -177,23 +158,14 @@ func TestDiskSpecs(t *testing.T) {
},
}, {
name: "os and multiple data disks",
azureMachine: &infrav1.AzureMachine{
ObjectMeta: metav1.ObjectMeta{
Name: "my-azure-machine",
},
Spec: infrav1.AzureMachineSpec{
OSDisk: infrav1.OSDisk{
DiskSizeGB: 30,
OSType: "Linux",
azureMachineModifyFunc: func(m *infrav1.AzureMachine) {
m.Spec.DataDisks = []infrav1.DataDisk{
{
NameSuffix: "etcddisk",
},
DataDisks: []infrav1.DataDisk{
{
NameSuffix: "etcddisk",
},
{
NameSuffix: "otherdisk",
}},
},
{
NameSuffix: "otherdisk",
}}
},
expectedDisks: []azure.DiskSpec{
{
Expand Down Expand Up @@ -231,11 +203,25 @@ func TestDiskSpecs(t *testing.T) {
Name: "my-machine",
},
}

azureMachine := &infrav1.AzureMachine{
ObjectMeta: metav1.ObjectMeta{
Name: "my-azure-machine",
},
Spec: infrav1.AzureMachineSpec{
OSDisk: infrav1.OSDisk{
DiskSizeGB: 30,
OSType: "Linux",
},
},
}
tc.azureMachineModifyFunc(azureMachine)

initObjects := []runtime.Object{
cluster,
machine,
azureCluster,
tc.azureMachine,
azureMachine,
}
client := fake.NewFakeClientWithScheme(scheme, initObjects...)
clusterScope, err := scope.NewClusterScope(scope.ClusterScopeParams{
Expand All @@ -251,7 +237,7 @@ func TestDiskSpecs(t *testing.T) {
Client: client,
ClusterScope: clusterScope,
Machine: machine,
AzureMachine: tc.azureMachine,
AzureMachine: azureMachine,
})
g.Expect(err).NotTo(HaveOccurred())

Expand Down

0 comments on commit 2c8630f

Please sign in to comment.