Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmocanu-ionos committed May 20, 2024
1 parent 2d92115 commit d6acad0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
15 changes: 15 additions & 0 deletions internal/utils/mocks/ClientService.go

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

12 changes: 11 additions & 1 deletion ionoscloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ var (
Name: &testVar,
},
}
nats = &sdkgo.NatGateways{
Items: &[]sdkgo.NatGateway{*nat},
}
dcs = &sdkgo.Datacenters{
Items: &[]sdkgo.Datacenter{*dc},
}
Expand Down Expand Up @@ -362,9 +365,10 @@ func TestPreCreateCheckDataCenterIdErr(t *testing.T) {
driver.DatacenterId = datacenterId
clientMock.EXPECT().GetDatacenter(driver.DatacenterId).Return(dc, nil)
clientMock.EXPECT().GetLocationById("us", "ewr").Return(location, nil)
clientMock.EXPECT().GetImageById(defaultImageAlias).Return(&sdkgo.Image{}, fmt.Errorf("no image found with this id"))
clientMock.EXPECT().GetImageById(defaultImageAlias).Return(nil, fmt.Errorf("no image found with this id"))
clientMock.EXPECT().GetImages().Return(&images, nil)
clientMock.EXPECT().GetLans(driver.DatacenterId).Return(&lans, nil)
clientMock.EXPECT().GetNats(driver.DatacenterId).Return(nats, nil)
err := driver.PreCreateCheck()
assert.NoError(t, err)
}
Expand Down Expand Up @@ -410,6 +414,7 @@ func TestPreCreateLans(t *testing.T) {
clientMock.EXPECT().GetLocationById("us", "ewr").Return(location, nil)
clientMock.EXPECT().GetImageById(defaultImageAlias).Return(&sdkgo.Image{}, fmt.Errorf("no image found with this id"))
clientMock.EXPECT().GetImages().Return(&images, nil)
clientMock.EXPECT().GetNats(driver.DatacenterId).Return(nats, nil)
err := driver.PreCreateCheck()
assert.True(t, reflect.DeepEqual(driver.AdditionalLansIds, []int{lanId1Int}))
assert.NoError(t, err)
Expand Down Expand Up @@ -505,6 +510,7 @@ func TestCreateLanProvided(t *testing.T) {
clientMock.EXPECT().GetDatacenter(*dc.Id).Return(dc, nil),
clientMock.EXPECT().GetLocationById("us", "ewr").Return(location, nil),
clientMock.EXPECT().GetImageById(imageAlias).Return(&sdkgo.Image{Id: sdkgo.ToPtr(testImageIdVar)}, nil),
clientMock.EXPECT().GetNats(*dc.Id).Return(nats, nil),

clientMock.EXPECT().GetLocationById("us", "ewr").Return(location, nil),
clientMock.EXPECT().GetImageById(imageAlias).Return(&sdkgo.Image{Id: sdkgo.ToPtr(testImageIdVar)}, nil),
Expand Down Expand Up @@ -587,6 +593,7 @@ func TestCreatePropertiesSet(t *testing.T) {
clientMock.EXPECT().GetDatacenter(*dc.Id).Return(dc, nil),
clientMock.EXPECT().GetLocationById("us", "ewr").Return(location, nil),
clientMock.EXPECT().GetImageById(imageAlias).Return(&sdkgo.Image{Id: sdkgo.ToPtr(testImageIdVar)}, nil),
clientMock.EXPECT().GetNats(*dc.Id).Return(nats, nil),

clientMock.EXPECT().GetLocationById("us", "ewr").Return(location, nil),
clientMock.EXPECT().GetImageById(imageAlias).Return(&sdkgo.Image{Id: sdkgo.ToPtr(testImageIdVar)}, nil),
Expand Down Expand Up @@ -674,6 +681,7 @@ func TestCreateCubePropertiesSet(t *testing.T) {
clientMock.EXPECT().GetDatacenter(*dc.Id).Return(dc, nil),
clientMock.EXPECT().GetLocationById("us", "ewr").Return(location, nil),
clientMock.EXPECT().GetImageById(imageAlias).Return(&sdkgo.Image{Id: sdkgo.ToPtr(testImageIdVar)}, nil),
clientMock.EXPECT().GetNats(*dc.Id).Return(nats, nil),

clientMock.EXPECT().GetLocationById("us", "ewr").Return(location, nil),
clientMock.EXPECT().GetImageById(imageAlias).Return(&sdkgo.Image{Id: sdkgo.ToPtr(testImageIdVar)}, nil),
Expand Down Expand Up @@ -746,6 +754,7 @@ func TestCreateNatPublicIps(t *testing.T) {
clientMock.EXPECT().GetDatacenter(*dc.Id).Return(dc, nil),
clientMock.EXPECT().GetLocationById("us", "ewr").Return(location, nil),
clientMock.EXPECT().GetImageById(imageAlias).Return(&sdkgo.Image{Id: sdkgo.ToPtr(testImageIdVar)}, nil),
clientMock.EXPECT().GetNats(*dc.Id).Return(nats, nil),

clientMock.EXPECT().GetLocationById("us", "ewr").Return(location, nil),
clientMock.EXPECT().GetImageById(imageAlias).Return(&sdkgo.Image{Id: sdkgo.ToPtr(testImageIdVar)}, nil),
Expand Down Expand Up @@ -821,6 +830,7 @@ func TestCreateNat(t *testing.T) {
clientMock.EXPECT().GetDatacenter(*dc.Id).Return(dc, nil),
clientMock.EXPECT().GetLocationById("us", "ewr").Return(location, nil),
clientMock.EXPECT().GetImageById(imageAlias).Return(&sdkgo.Image{Id: sdkgo.ToPtr(testImageIdVar)}, nil),
clientMock.EXPECT().GetNats(*dc.Id).Return(nats, nil),

clientMock.EXPECT().GetLocationById("us", "ewr").Return(location, nil),
clientMock.EXPECT().GetImageById(imageAlias).Return(&sdkgo.Image{Id: sdkgo.ToPtr(testImageIdVar)}, nil),
Expand Down

0 comments on commit d6acad0

Please sign in to comment.