Skip to content

Commit

Permalink
Use proper test network prefixes in privatenetwork tests
Browse files Browse the repository at this point in the history
  • Loading branch information
norrland committed Sep 3, 2024
1 parent 35ec433 commit 07b3e67
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ func ExamplePrivateNetworkService_CreateSegment() {
Datacenter: "dc-fbg1",
Name: "kvm-segment",
Platform: "kvm",
IPv4Subnet: "192.168.0.0/24",
IPv4Subnet: "192.0.2.0/24",
}

segment, _ := client.PrivateNetworks.CreateSegment(context.Background(), params)
Expand Down
38 changes: 19 additions & 19 deletions privatenetworks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestPrivateNetworksCreate(t *testing.T) {
c := &mockClient{body: `{ "response": { "privatenetwork":
{ "id": "pn-123ab", "name": "mynetwork", "ipv6aggregate": "fe00:123::/48"}}}`}
{ "id": "pn-123ab", "name": "mynetwork", "ipv6aggregate": "2001:db8::/48"}}}`}
n := PrivateNetworkService{client: c}

networkname := "mynetwork"
Expand All @@ -20,7 +20,7 @@ func TestPrivateNetworksCreate(t *testing.T) {
assert.Equal(t, "privatenetwork/create", c.lastPath, "path used is correct")
assert.Equal(t, "pn-123ab", net.ID, "ID is correct")
assert.Equal(t, "mynetwork", net.Name, "Name is correct")
assert.Equal(t, "fe00:123::/48", net.IPv6Aggregate, "IPv6Aggregate is correct")
assert.Equal(t, "2001:db8::/48", net.IPv6Aggregate, "IPv6Aggregate is correct")
}

func TestPrivateNetworksDestroy(t *testing.T) {
Expand All @@ -37,7 +37,7 @@ func TestPrivateNetworksDetails(t *testing.T) {
c := &mockClient{body: `{ "response": { "privatenetwork": {
"id": "pn-123ab",
"name": "mynetwork",
"ipv6aggregate": "fe00:123::/48"
"ipv6aggregate": "2001:db8::/48"
} } }`}
n := PrivateNetworkService{client: c}

Expand All @@ -47,18 +47,18 @@ func TestPrivateNetworksDetails(t *testing.T) {
assert.Equal(t, "privatenetwork/details", c.lastPath, "path used is correct")
assert.Equal(t, "mynetwork", net.Name, "Name is correct")
assert.Equal(t, "pn-123ab", net.ID, "ID is correct")
assert.Equal(t, "fe00:123::/48", net.IPv6Aggregate, "IPv6Aggregate is correct")
assert.Equal(t, "2001:db8::/48", net.IPv6Aggregate, "IPv6Aggregate is correct")
}

func TestPrivateNetworksList(t *testing.T) {
c := &mockClient{body: `{ "response": { "privatenetworks": [{
"id": "pn-123ab",
"name": "mynetwork",
"ipv6aggregate": "fe00:123::/48"
"ipv6aggregate": "2001:db8:1::/48"
}, {
"id": "pn-456cd",
"name": "othernet",
"ipv6aggregate": "fe00:456::/48" } ] } }`}
"ipv6aggregate": "2001:db8:2::/48" } ] } }`}

n := PrivateNetworkService{client: c}

Expand All @@ -68,10 +68,10 @@ func TestPrivateNetworksList(t *testing.T) {
assert.Equal(t, "privatenetwork/list", c.lastPath, "path used is correct")
assert.Equal(t, "mynetwork", (*net)[0].Name, "Name is correct")
assert.Equal(t, "pn-123ab", (*net)[0].ID, "ID is correct")
assert.Equal(t, "fe00:123::/48", (*net)[0].IPv6Aggregate, "IPv6Aggregate is correct")
assert.Equal(t, "2001:db8:1::/48", (*net)[0].IPv6Aggregate, "IPv6Aggregate is correct")
assert.Equal(t, "othernet", (*net)[1].Name, "Name is correct")
assert.Equal(t, "pn-456cd", (*net)[1].ID, "ID is correct")
assert.Equal(t, "fe00:456::/48", (*net)[1].IPv6Aggregate, "IPv6Aggregate is correct")
assert.Equal(t, "2001:db8:2::/48", (*net)[1].IPv6Aggregate, "IPv6Aggregate is correct")
}

func TestPrivateNetworksEdit(t *testing.T) {
Expand Down Expand Up @@ -114,16 +114,16 @@ func TestPrivateNetworksEstimatedcost(t *testing.T) {
func TestPrivateNetworkSegmentsCreate(t *testing.T) {
c := &mockClient{body: `{ "response": { "privatenetworksegment":
{ "id": "266979ab-1e05-4fbc-b9e0-577f31c0d2e9",
"name": "mysegment", "ipv6subnet": "fe00:123:0:/64",
"ipv4subnet": "10.0.0.0/24", "datacenter": "dc-fbg1",
"name": "mysegment", "ipv6subnet": "2001:db8:0::/64",
"ipv4subnet": "192.0.2.0/24", "datacenter": "dc-fbg1",
"platform": "kvm"}}}`}
n := PrivateNetworkService{client: c}

params := CreatePrivateNetworkSegmentParams{
Name: "mysegment",
Platform: "kvm",
Datacenter: "dc-fbg1",
IPv4Subnet: "10.0.0.0/24",
IPv4Subnet: "192.0.2.0/24",
}

segment, _ := n.CreateSegment(context.Background(), params)
Expand All @@ -132,8 +132,8 @@ func TestPrivateNetworkSegmentsCreate(t *testing.T) {
assert.Equal(t, "privatenetwork/createsegment", c.lastPath, "path used is correct")
assert.Equal(t, "266979ab-1e05-4fbc-b9e0-577f31c0d2e9", segment.ID, "ID is correct")
assert.Equal(t, "mysegment", segment.Name, "Name is correct")
assert.Equal(t, "fe00:123:0:/64", segment.IPv6Subnet, "IPv6Subnet is correct")
assert.Equal(t, "10.0.0.0/24", segment.IPv4Subnet, "IPv4Subnet is correct")
assert.Equal(t, "2001:db8:0::/64", segment.IPv6Subnet, "IPv6Subnet is correct")
assert.Equal(t, "192.0.2.0/24", segment.IPv4Subnet, "IPv4Subnet is correct")
}

func TestPrivateNetworkSegmentsDestroy(t *testing.T) {
Expand All @@ -153,15 +153,15 @@ func TestPrivateNetworkSegmentsList(t *testing.T) {
"name": "mysegment",
"platform": "kvm",
"datacenter": "dc-fbg1",
"ipv4subnet": "10.0.0.0/24",
"ipv6subnet": "fe00:123:0:/64"
"ipv4subnet": "192.0.2.0/24",
"ipv6subnet": "2001:db8:0::/64"
}, {
"id": "fb34a19a-392a-43ec-ab3f-0c5b73ad5678",
"name": "othersegment",
"platform": "kvm",
"datacenter": "dc-fbg1",
"ipv4subnet": "10.0.0.0/24",
"ipv6subnet": "fe00:456:1:/64" } ] } }
"ipv4subnet": "192.0.2.0/24",
"ipv6subnet": "2001:db8:1::/64" } ] } }
`}

n := PrivateNetworkService{client: c}
Expand All @@ -172,11 +172,11 @@ func TestPrivateNetworkSegmentsList(t *testing.T) {
assert.Equal(t, "privatenetwork/listsegments", c.lastPath, "path used is correct")
assert.Equal(t, "mysegment", (*segments)[0].Name, "Name is correct")
assert.Equal(t, "fb34a19a-392a-43ec-ab3f-0c5b73ad1234", (*segments)[0].ID, "ID is correct")
assert.Equal(t, "fe00:123:0:/64", (*segments)[0].IPv6Subnet, "IPv6Aggregate is correct")
assert.Equal(t, "2001:db8:0::/64", (*segments)[0].IPv6Subnet, "IPv6Aggregate is correct")
assert.Equal(t, "othersegment", (*segments)[1].Name, "Name is correct")
assert.Equal(t, "fb34a19a-392a-43ec-ab3f-0c5b73ad5678", (*segments)[1].ID, "ID is correct")
assert.Equal(t, "kvm", (*segments)[1].Platform, "Platform is correct")
assert.Equal(t, "fe00:456:1:/64", (*segments)[1].IPv6Subnet, "IPv6Aggregate is correct")
assert.Equal(t, "2001:db8:1::/64", (*segments)[1].IPv6Subnet, "IPv6Aggregate is correct")
}

func TestPrivateNetworkSegmentsEdit(t *testing.T) {
Expand Down

0 comments on commit 07b3e67

Please sign in to comment.