Skip to content

Commit

Permalink
fix: lint issues
Browse files Browse the repository at this point in the history
Signed-off-by: Ayush Rangwala <ayush.rangwala@gmail.com>
  • Loading branch information
aayushrangwala committed Nov 21, 2023
1 parent 90fc801 commit 937c467
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/manifoldco/promptui v0.9.0
github.com/olekukonko/tablewriter v0.0.5
github.com/packethost/packngo v0.30.0
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.17.0
Expand Down
5 changes: 1 addition & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ github.com/packethost/packngo v0.30.0 h1:JVeTwbXXETsLTDQncUbYwIFpkOp/xevXrffM2Hr
github.com/packethost/packngo v0.30.0/go.mod h1:BT/XcdwLVmeMtGPbovnxCpnI1s9ylSE1cs/7pq007NE=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down Expand Up @@ -257,8 +258,6 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -412,8 +411,6 @@ golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
14 changes: 8 additions & 6 deletions test/e2e/gateways/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func TestGateways_Create(t *testing.T) {

device := helper.SetupProjectAndDevice(t, &projectId, &deviceId)
t.Cleanup(func() {
if err := helper.CleanupProjectAndDevice(deviceId, projectId); err != nil {
if err := helper.CleanupProjectAndDevice(deviceId, projectId); err != nil &&
!strings.Contains(err.Error(), "Not Found") {
t.Error(err)
}
})
Expand All @@ -37,7 +38,8 @@ func TestGateways_Create(t *testing.T) {

vlan, err := helper.CreateTestVLAN(projectId)
t.Cleanup(func() {
if err := helper.CleanTestVlan(vlan.GetId()); err != nil {
if err := helper.CleanTestVlan(vlan.GetId()); err != nil &&
!strings.Contains(err.Error(), "Not Found") {
t.Error(err)
}
})
Expand Down Expand Up @@ -100,18 +102,18 @@ func TestGateways_Create(t *testing.T) {

func assertGatewaysCmdOutput(t *testing.T, out, gatewayId, metro, vxlan string) {
if !strings.Contains(out, gatewayId) {
t.Errorf("cmd output should contain ID of the gateway: %s", gatewayId)
t.Errorf("cmd output should contain ID of the gateway: [%s] \n output:\n%s", gatewayId, out)
}

if !strings.Contains(out, metro) {
t.Errorf("cmd output should contain metro same as device: %s", metro)
t.Errorf("cmd output should contain metro same as device: [%s] \n output:\n%s", metro, out)
}

if !strings.Contains(out, vxlan) {
t.Errorf("cmd output should contain vxlan, gateway is attached with: %s", vxlan)
t.Errorf("cmd output should contain vxlan, gateway is attached with: [%s] \n output:\n%s", vxlan, out)
}

if !strings.Contains(out, "ready") {
t.Errorf("cmd output should contain 'ready' state of the gateway")
t.Errorf("cmd output should contain 'ready' state of the gateway, output:\n%s", out)
}
}
8 changes: 5 additions & 3 deletions test/e2e/gateways/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ func TestGateways_Delete(t *testing.T) {
}()
device := helper.SetupProjectAndDevice(t, &projectId, &deviceId)
t.Cleanup(func() {
if err := helper.CleanupProjectAndDevice(deviceId, projectId); err != nil {
if err := helper.CleanupProjectAndDevice(deviceId, projectId); err != nil &&
!strings.Contains(err.Error(), "Not Found") {
t.Error(err)
}
})
Expand All @@ -41,8 +42,9 @@ func TestGateways_Delete(t *testing.T) {

vlan, err := helper.CreateTestVLAN(projectId)
t.Cleanup(func() {
if err := helper.CleanTestVlan(vlan.GetId()); err != nil {
t.Error(err)
if err := helper.CleanTestVlan(vlan.GetId()); err != nil &&
!strings.Contains(err.Error(), "Not Found") {
t.Error("Error while cleaning up vLan", err)
}
})
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions test/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

openapiclient "github.com/equinix-labs/metal-go/metal/v1"
"github.com/pkg/errors"
)

func TestClient() *openapiclient.APIClient {
Expand Down Expand Up @@ -159,7 +160,7 @@ func WaitForAttachVlanToPort(portId string, attach bool) error {
case <-ticker.C:
port, err := GetPortById(portId)
if err != nil {
return err
return errors.Wrapf(err, "Error while fetching the port using ID: %s", portId)
}

vlans := port.GetVirtualNetworks()
Expand Down Expand Up @@ -327,7 +328,7 @@ func SetupProjectAndDevice(t *testing.T, projectId, deviceId *string) *openapicl
return nil
}
if !active {
t.Fatal("Timeout while waiting for device: %s to be active", *deviceId)
t.Fatalf("Timeout while waiting for device: %s to be active", *deviceId)
return nil
}

Expand All @@ -337,7 +338,7 @@ func SetupProjectAndDevice(t *testing.T, projectId, deviceId *string) *openapicl
return nil
}
if len(device.NetworkPorts) < 3 {
t.Fatal("All 3 ports doesnot exist for the created device: %s", device.GetId())
t.Fatalf("All 3 ports doesnot exist for the created device: %s", device.GetId())
return nil
}

Expand Down

0 comments on commit 937c467

Please sign in to comment.