Skip to content

Commit

Permalink
correct fragment location
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Siwiec <[email protected]>
  • Loading branch information
rizzza committed Jun 29, 2023
1 parent dd35093 commit 5904f41
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
37 changes: 21 additions & 16 deletions pkg/lbapi/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,25 @@ func TestGetLoadBalancer(t *testing.T) {
"loadBalancer": {
"id": "loadbal-randovalue",
"name": "some lb",
"IPAddresses": [
{
"id": "ipamipa-randovalue",
"ip": "192.168.1.42",
"reserved": false
},
{
"id": "ipamipa-randovalue2",
"ip": "192.168.1.1",
"reserved": true
}
],
"ports": {
"edges": [
{
"node": {
"name": "porty",
"id": "loadprt-randovalue",
"number": 80,
"nodeID": "loadbal-randovalue",
"IPAddresses": [
{
"id": "ipamipa-randovalue",
"ip": "192.168.1.42",
"reserved": false
}
]
"number": 80
}
}
]
Expand All @@ -59,17 +63,18 @@ func TestGetLoadBalancer(t *testing.T) {

assert.Equal(t, "loadbal-randovalue", lb.LoadBalancer.ID)
assert.Equal(t, "some lb", lb.LoadBalancer.Name)

require.Len(t, lb.LoadBalancer.Ports.Edges, 1)
assert.Equal(t, "loadprt-randovalue", lb.LoadBalancer.Ports.Edges[0].Node.ID)
assert.Equal(t, "porty", lb.LoadBalancer.Ports.Edges[0].Node.Name)
assert.Equal(t, int64(80), lb.LoadBalancer.Ports.Edges[0].Node.Number)
assert.Empty(t, lb.LoadBalancer.Ports.Edges[0].Node.Pools)

require.Len(t, lb.LoadBalancer.Ports.Edges[0].Node.IPAddresses, 1)
assert.Equal(t, "ipamipa-randovalue", lb.LoadBalancer.Ports.Edges[0].Node.IPAddresses[0].ID)
assert.Equal(t, "192.168.1.42", lb.LoadBalancer.Ports.Edges[0].Node.IPAddresses[0].IP)
assert.False(t, lb.LoadBalancer.Ports.Edges[0].Node.IPAddresses[0].Reserved)
require.Len(t, lb.LoadBalancer.IPAddresses, 2)
assert.Equal(t, "ipamipa-randovalue", lb.LoadBalancer.IPAddresses[0].ID)
assert.Equal(t, "192.168.1.42", lb.LoadBalancer.IPAddresses[0].IP)
assert.False(t, lb.LoadBalancer.IPAddresses[0].Reserved)

assert.Equal(t, "ipamipa-randovalue2", lb.LoadBalancer.IPAddresses[1].ID)
assert.Equal(t, "192.168.1.1", lb.LoadBalancer.IPAddresses[1].IP)
assert.True(t, lb.LoadBalancer.IPAddresses[1].Reserved)
})
}

Expand Down
19 changes: 9 additions & 10 deletions pkg/lbapi/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ type Pool struct {
}

type PortNode struct {
ID string
Name string
Number int64
IPAddressableFragment `graphql:"... on IPAddressable"`
Pools []Pool
ID string
Name string
Number int64
Pools []Pool
}

type PortEdges struct {
Expand All @@ -40,9 +39,10 @@ type Ports struct {
}

type LoadBalancer struct {
ID string
Name string
Ports Ports
ID string
Name string
IPAddressableFragment `graphql:"... on IPAddressable"`
Ports Ports
}

type GetLoadBalancer struct {
Expand All @@ -56,7 +56,6 @@ type IPAddress struct {
}

type IPAddressableFragment struct {
NodeID string `graphql:"nodeID: id"` // alias ID to nodeID
IPAddresses []IPAddress
}

Expand All @@ -65,12 +64,12 @@ type IPAddressableFragment struct {
// LoadBalancer struct {
// ID string
// Name string
// IPAddressableFragment
// Ports struct {
// Edges []struct {
// Node struct {
// Name string
// Number int64
// IPAddressableFragment
// Pools []struct {
// Name string
// Protocol string
Expand Down

0 comments on commit 5904f41

Please sign in to comment.