Skip to content

Commit

Permalink
Fix IP address testing
Browse files Browse the repository at this point in the history
  • Loading branch information
gfenn-newbury committed Dec 21, 2021
1 parent 76cb280 commit b5029f4
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions client/ip_address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,28 @@ import (
"github.com/stretchr/testify/assert"
)

func CreateIpAddressTestObjects() (*IPAddress, error) {
c := NewClient(GetCredentialsFromEnvVar())
ipaddr := new(IPAddress)
ipaddr.Address = "192.168.88.1/24"
ipaddr.Interface = "bridge"
ipaddr.Network = "192.168.88.0"
ipaddr.Disabled = "yes"
res, err := c.CreateIPAddress(ipaddr)
if err != nil {
return nil, err
}
return res, nil
}

func TestGetIpAddress(t *testing.T) {
c := NewClient(GetCredentialsFromEnvVar())
res, err := c.GetIPAddress("*4")
ipaddr, err := CreateIpAddressTestObjects()
assert.Nil(t, err, "expecting nil error")
res, err := c.GetIPAddress(ipaddr.ID)
assert.Nil(t, err, "expecting nil error")
assert.NotNil(t, res, "expecting non-nil result")
assert.Equal(t, res.Address, ipaddr.Address)
}

func TestCreateIpAddress(t *testing.T) {
Expand All @@ -26,7 +43,8 @@ func TestCreateIpAddress(t *testing.T) {

func TestDeleteIpAddress(t *testing.T) {
c := NewClient(GetCredentialsFromEnvVar())
id := "*60"
err := c.DeleteIPAddress(id)
ipaddr, err := CreateIpAddressTestObjects()
assert.Nil(t, err, "expecting a nil error")
err = c.DeleteIPAddress(ipaddr.ID)
assert.Nil(t, err, "Expecting a nil error")
}

0 comments on commit b5029f4

Please sign in to comment.