Skip to content

Commit

Permalink
update link and integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
bwJuniper committed Oct 22, 2024
1 parent c7df916 commit 828d76b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
22 changes: 11 additions & 11 deletions apstra/freeform_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ func (o *FreeformLink) UnmarshalJSON(bytes []byte) error {
o.Data.Speed = raw.Speed
o.Data.Label = raw.Label
o.Data.AggregateLinkId = raw.AggregateLinkId
o.Data.Endpoints[0] = FreeformEndpoint{
o.Data.Endpoints[0] = FreeformEthernetEndpoint{
SystemId: raw.Endpoints[0].System.Id,
Interface: FreeformInterface{
Id: raw.Endpoints[0].Interface.Id,
Data: raw.Endpoints[0].Interface.Data,
},
}
o.Data.Endpoints[1] = FreeformEndpoint{
o.Data.Endpoints[1] = FreeformEthernetEndpoint{
SystemId: raw.Endpoints[1].System.Id,
Interface: FreeformInterface{
Id: raw.Endpoints[1].Interface.Id,
Expand All @@ -79,7 +79,7 @@ type FreeformLinkData struct {
Label string
Speed LogicalDevicePortSpeed
Tags []string
Endpoints [2]FreeformEndpoint
Endpoints [2]FreeformEthernetEndpoint
}

var _ json.Marshaler = new(FreeformInterfaceData)
Expand Down Expand Up @@ -193,16 +193,16 @@ func (o *FreeformInterface) UnmarshalJSON(bytes []byte) error {
}

var (
_ json.Marshaler = new(FreeformEndpoint)
_ json.Unmarshaler = new(FreeformEndpoint)
_ json.Marshaler = new(FreeformEthernetEndpoint)
_ json.Unmarshaler = new(FreeformEthernetEndpoint)
)

type FreeformEndpoint struct {
type FreeformEthernetEndpoint struct {
SystemId ObjectId
Interface FreeformInterface
}

func (o *FreeformEndpoint) UnmarshalJSON(bytes []byte) error {
func (o *FreeformEthernetEndpoint) UnmarshalJSON(bytes []byte) error {
var raw struct {
System struct {
Id ObjectId `json:"id"`
Expand All @@ -216,7 +216,7 @@ func (o *FreeformEndpoint) UnmarshalJSON(bytes []byte) error {
return json.Unmarshal(bytes, &raw)
}

func (o FreeformEndpoint) MarshalJSON() ([]byte, error) {
func (o FreeformEthernetEndpoint) MarshalJSON() ([]byte, error) {
var raw struct {
System *struct {
Id ObjectId `json:"id"`
Expand Down Expand Up @@ -251,9 +251,9 @@ func (o FreeformEndpoint) MarshalJSON() ([]byte, error) {
}

type FreeformLinkRequest struct {
Label string `json:"label"`
Tags []string `json:"tags"`
Endpoints [2]FreeformEndpoint `json:"endpoints"`
Label string `json:"label"`
Tags []string `json:"tags"`
Endpoints [2]FreeformEthernetEndpoint `json:"endpoints"`
}

func (o *FreeformClient) CreateLink(ctx context.Context, in *FreeformLinkRequest) (ObjectId, error) {
Expand Down
38 changes: 19 additions & 19 deletions apstra/freeform_link_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestCRUDFFLink(t *testing.T) {
clients, err := getTestClients(ctx, t)
require.NoError(t, err)

compareEndPoint := func(t testing.TB, req, resp *FreeformEndpoint) {
compareEndPoint := func(t testing.TB, req, resp *FreeformEthernetEndpoint) {
t.Helper()

require.Equal(t, req.SystemId, resp.SystemId, "system id ")
Expand Down Expand Up @@ -75,7 +75,7 @@ func TestCRUDFFLink(t *testing.T) {
steps: []FreeformLinkRequest{
{
Label: randString(6, "hex"),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{
IfName: toPtr("ge-0/0/0"),
TransformationId: toPtr(1),
Expand All @@ -89,7 +89,7 @@ func TestCRUDFFLink(t *testing.T) {
{
Label: randString(6, "hex"),
Tags: randStrings(rand.Intn(3)+2, 6),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{
IfName: toPtr("ge-0/0/1"),
TransformationId: toPtr(2),
Expand All @@ -108,7 +108,7 @@ func TestCRUDFFLink(t *testing.T) {
},
{
Label: randString(6, "hex"),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{
IfName: toPtr("ge-0/0/2"),
TransformationId: toPtr(1),
Expand All @@ -126,7 +126,7 @@ func TestCRUDFFLink(t *testing.T) {
{
Label: randString(6, "hex"),
Tags: randStrings(rand.Intn(3)+2, 6),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{
IfName: toPtr("ge-0/0/3"),
TransformationId: toPtr(2),
Expand All @@ -145,7 +145,7 @@ func TestCRUDFFLink(t *testing.T) {
},
{
Label: randString(6, "hex"),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{
IfName: toPtr("ge-0/0/4"),
TransformationId: toPtr(1),
Expand All @@ -159,7 +159,7 @@ func TestCRUDFFLink(t *testing.T) {
{
Label: randString(6, "hex"),
Tags: randStrings(rand.Intn(3)+2, 6),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{
IfName: toPtr("ge-0/0/5"),
TransformationId: toPtr(2),
Expand All @@ -182,7 +182,7 @@ func TestCRUDFFLink(t *testing.T) {
steps: []FreeformLinkRequest{
{
Label: randString(6, "hex"),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{
IfName: toPtr("ge-0/0/6"),
TransformationId: toPtr(1),
Expand All @@ -193,7 +193,7 @@ func TestCRUDFFLink(t *testing.T) {
{
Label: randString(6, "hex"),
Tags: randStrings(rand.Intn(3)+2, 6),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{
IfName: toPtr("ge-0/0/7"),
TransformationId: toPtr(2),
Expand All @@ -210,7 +210,7 @@ func TestCRUDFFLink(t *testing.T) {
},
{
Label: randString(6, "hex"),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{
IfName: toPtr("ge-0/0/8"),
TransformationId: toPtr(1),
Expand All @@ -225,7 +225,7 @@ func TestCRUDFFLink(t *testing.T) {
{
Label: randString(6, "hex"),
Tags: randStrings(rand.Intn(3)+2, 6),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{
IfName: toPtr("ge-0/0/9"),
TransformationId: toPtr(2),
Expand All @@ -242,7 +242,7 @@ func TestCRUDFFLink(t *testing.T) {
},
{
Label: randString(6, "hex"),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{
IfName: toPtr("ge-0/0/10"),
TransformationId: toPtr(1),
Expand All @@ -253,7 +253,7 @@ func TestCRUDFFLink(t *testing.T) {
{
Label: randString(6, "hex"),
Tags: randStrings(rand.Intn(3)+2, 6),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: intSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{
IfName: toPtr("ge-0/0/11"),
TransformationId: toPtr(2),
Expand All @@ -274,15 +274,15 @@ func TestCRUDFFLink(t *testing.T) {
steps: []FreeformLinkRequest{
{
Label: randString(6, "hex"),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: extSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{}}},
{SystemId: extSysIds[1], Interface: FreeformInterface{Data: &FreeformInterfaceData{}}},
},
},
{
Label: randString(6, "hex"),
Tags: randStrings(rand.Intn(3)+2, 6),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: extSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{
Ipv4Address: &net.IPNet{IP: net.ParseIP("10.0.0.3"), Mask: net.CIDRMask(24, 32)},
Ipv6Address: &net.IPNet{IP: net.ParseIP("2001:db8::3"), Mask: net.CIDRMask(64, 128)},
Expand All @@ -297,7 +297,7 @@ func TestCRUDFFLink(t *testing.T) {
},
{
Label: randString(6, "hex"),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: extSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{}}},
{SystemId: extSysIds[1], Interface: FreeformInterface{Data: &FreeformInterfaceData{}}},
},
Expand All @@ -309,7 +309,7 @@ func TestCRUDFFLink(t *testing.T) {
{
Label: randString(6, "hex"),
Tags: randStrings(rand.Intn(3)+2, 6),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: extSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{
Ipv4Address: &net.IPNet{IP: net.ParseIP("10.1.0.1"), Mask: net.CIDRMask(24, 32)},
Ipv6Address: &net.IPNet{IP: net.ParseIP("2001:db8:1::1"), Mask: net.CIDRMask(64, 128)},
Expand All @@ -324,15 +324,15 @@ func TestCRUDFFLink(t *testing.T) {
},
{
Label: randString(6, "hex"),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: extSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{}}},
{SystemId: extSysIds[1], Interface: FreeformInterface{Data: &FreeformInterfaceData{}}},
},
},
{
Label: randString(6, "hex"),
Tags: randStrings(rand.Intn(3)+2, 6),
Endpoints: [2]FreeformEndpoint{
Endpoints: [2]FreeformEthernetEndpoint{
{SystemId: extSysIds[0], Interface: FreeformInterface{Data: &FreeformInterfaceData{
Ipv4Address: &net.IPNet{IP: net.ParseIP("10.1.0.2"), Mask: net.CIDRMask(24, 32)},
Ipv6Address: &net.IPNet{IP: net.ParseIP("2001:db8:1::2"), Mask: net.CIDRMask(64, 128)},
Expand Down

0 comments on commit 828d76b

Please sign in to comment.