func TestAddPublicIP(t *testing.T) { assert := assert.New(t) client := NewMockClient() client.On("Post", "http://localhost/v2/servers/test/va1testserver01/publicIPAddresses", mock.Anything, mock.Anything).Return(nil) service := server.New(client) name := "va1testserver01" ip := server.PublicIP{} ip.Ports = []server.Port{server.Port{Protocol: "TCP", Port: 8080}} resp, err := service.AddPublicIP(name, ip) assert.Nil(err) assert.Equal("status", resp.Rel) client.AssertExpectations(t) }
func TestUpdatePublicIP(t *testing.T) { assert := assert.New(t) client := NewMockClient() client.On("Put", "http://localhost/v2/servers/test/va1testserver01/publicIPAddresses/10.0.0.1", mock.Anything, mock.Anything).Return(nil) service := server.New(client) addr := "10.0.0.1" name := "va1testserver01" ip := server.PublicIP{} ip.InternalIP = addr ip.Ports = []server.Port{server.Port{Protocol: "TCP", Port: 443}} resp, err := service.UpdatePublicIP(name, addr, ip) assert.Nil(err) assert.Equal("status", resp.Rel) client.AssertExpectations(t) }