Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Mendoza committed Apr 11, 2024
1 parent 6091e5e commit 2e7b80a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 52 deletions.
1 change: 0 additions & 1 deletion cloud/scope/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type LinodeInstanceClient interface {
ListInstances(ctx context.Context, opts *linodego.ListOptions) ([]linodego.Instance, error)
CreateInstance(ctx context.Context, opts linodego.InstanceCreateOptions) (*linodego.Instance, error)
BootInstance(ctx context.Context, linodeID int, configID int) error
ListInstanceDisks(ctx context.Context, linodeID int, opts *linodego.ListOptions) ([]linodego.InstanceDisk, error)
CreateInstanceDisk(ctx context.Context, linodeID int, opts linodego.InstanceDiskCreateOptions) (*linodego.InstanceDisk, error)
GetInstance(ctx context.Context, linodeID int) (*linodego.Instance, error)
DeleteInstance(ctx context.Context, linodeID int) error
Expand Down
39 changes: 18 additions & 21 deletions controller/linodemachine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ var _ = Describe("create", Label("machine", "create"), func() {
}
linodeMachine = infrav1alpha1.LinodeMachine{
ObjectMeta: metav1.ObjectMeta{
Name: "mock",
Namespace: "default",
UID: "12345",
Name: "mock",
Namespace: "default",
UID: "12345",
Annotations: make(map[string]string),
},
Spec: infrav1alpha1.LinodeMachineSpec{
InstanceID: ptr.To(0),
Expand Down Expand Up @@ -255,21 +256,21 @@ var _ = Describe("create", Label("machine", "create"), func() {
IPv4: []*net.IP{ptr.To(net.IPv4(192, 168, 0, 2))},
Status: linodego.InstanceOffline,
}, nil)
createEtcdDisk := mockLinodeClient.EXPECT().
CreateInstanceDisk(ctx, 123, gomock.Any()).
After(createInst).
Return(&linodego.InstanceDisk{ID: 101}, nil)
getType := mockLinodeClient.EXPECT().
GetType(ctx, gomock.Any()).
After(createInst).
After(createEtcdDisk).
Return(&linodego.LinodeType{Disk: 20000}, nil)
createRootDisk := mockLinodeClient.EXPECT().
CreateInstanceDisk(ctx, 123, gomock.Any()).
After(getType).
Return(&linodego.InstanceDisk{ID: 100}, nil)
createEtcdDisk := mockLinodeClient.EXPECT().
CreateInstanceDisk(ctx, 123, gomock.Any()).
After(createRootDisk).
Return(&linodego.InstanceDisk{ID: 101}, nil)
createInstConfig := mockLinodeClient.EXPECT().
CreateInstanceConfig(ctx, 123, gomock.Any()).
After(createEtcdDisk).
After(createRootDisk).
Return(nil, nil)
bootInst := mockLinodeClient.EXPECT().
BootInstance(ctx, 123, 0).
Expand Down Expand Up @@ -352,13 +353,9 @@ var _ = Describe("create", Label("machine", "create"), func() {
IPv4: []*net.IP{ptr.To(net.IPv4(192, 168, 0, 2))},
Status: linodego.InstanceOffline,
}, nil)
getType := mockLinodeClient.EXPECT().
GetType(ctx, gomock.Any()).
After(createInst).
Return(&linodego.LinodeType{Disk: 20000}, nil)
mockLinodeClient.EXPECT().
CreateInstanceDisk(ctx, 123, gomock.Any()).
After(getType).
After(createInst).
Return(nil, errors.New("failed to create"))

mScope := scope.MachineScope{
Expand Down Expand Up @@ -392,21 +389,21 @@ var _ = Describe("create", Label("machine", "create"), func() {
GetImage(ctx, gomock.Any()).
After(getRegion).
Return(&linodego.Image{Capabilities: []string{"cloud-init"}}, nil)
getType = mockLinodeClient.EXPECT().
GetType(ctx, gomock.Any()).
createEtcdDisk := mockLinodeClient.EXPECT().
CreateInstanceDisk(ctx, 123, gomock.Any()).
After(getImage).
Return(&linodego.InstanceDisk{ID: 101}, nil)
getType := mockLinodeClient.EXPECT().
GetType(ctx, gomock.Any()).
After(createEtcdDisk).
Return(&linodego.LinodeType{Disk: 20000}, nil)
createRootDisk := mockLinodeClient.EXPECT().
CreateInstanceDisk(ctx, 123, gomock.Any()).
After(getType).
Return(&linodego.InstanceDisk{ID: 100}, nil)
createEtcdDisk := mockLinodeClient.EXPECT().
CreateInstanceDisk(ctx, 123, gomock.Any()).
After(createRootDisk).
Return(&linodego.InstanceDisk{ID: 101}, nil)
createInstConfig := mockLinodeClient.EXPECT().
CreateInstanceConfig(ctx, 123, gomock.Any()).
After(createEtcdDisk).
After(createRootDisk).
Return(nil, nil)
bootInst := mockLinodeClient.EXPECT().
BootInstance(ctx, 123, 0).
Expand Down
30 changes: 0 additions & 30 deletions mock/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2e7b80a

Please sign in to comment.