Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/.snapshots/** text eol=lf
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/UpCloudLtd/upcloud-go-api/v4 v4.8.0
github.com/adrg/xdg v0.3.2
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
github.com/bradleyjkemp/cupaloy/v2 v2.7.0
github.com/gemalto/flume v0.12.0
github.com/jedib0t/go-pretty/v6 v6.0.5
github.com/m7shapan/cidr v0.0.0-20200427124835-7eba0889a5d2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/bradleyjkemp/cupaloy/v2 v2.7.0 h1:AT0vOjO68RcLyenLCHOGZzSNiuto7ziqzq6Q1/3xzMQ=
github.com/bradleyjkemp/cupaloy/v2 v2.7.0/go.mod h1:bm7JXdkRd4BHJk9HpwqAI8BoAY1lps46Enkdqw6aRX0=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
Expand Down
45 changes: 45 additions & 0 deletions internal/commands/server/.snapshots/TestServerHumanOutput
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

Common
UUID: 0077fa3d-32db-4b09-9f5f-30d9e9afb565
Hostname: server1.example.com
Title: server1.example.com
Plan: 1xCPU-2GB
Zone: fi-hel1
State: started
Simple Backup: 0100,dailies
Licence: 0
Metadata: True
Timezone: UTC
Host ID: 7653311107
Tags: DEV,Ubuntu

Storage: (Flags: B = bootdisk, P = part of plan)

UUID Title Type Address Size (GiB) Flags
────────────────────────────────────── ───────────────────────────────── ────── ────────── ──────────── ───────
012580a1-32a1-466e-a323-689ca16f2d43 Storage for server1.example.com disk virtio:0 20 P

NICs: (Flags: S = source IP filtering, B = bootable)

# Type IP Address MAC Address Network Flags
─── ───────── ──────────────────────────────────────────────────── ─────────────────── ────────────────────────────────────── ───────
1 public IPv4: 94.237.0.207 de:ff:ff:ff:66:89 037fcf2a-6745-45dd-867e-f9479ea8c044
2 utility IPv4: 10.6.3.95 (f) de:ff:ff:ff:ed:85 03000000-0000-4000-8045-000000000000
3 public IPv6: xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx de:ff:ff:ff:cc:20 03c93fd8-cc60-4849-91b8-6e404b228e2a

Firewall Rules:

# Direction Action Src IPAddress Dest IPAddress Src Port Dest Port Protocol
─── ─────────── ──────── ─────────────── ──────────────── ────────── ─────────── ───────────────
1 in accept Any Any Any Any IPv4/tcp
2 out drop 10.10.10.0 → 10.20.20.0 0 → Any IPv4/udp/icmp
10.10.10.99 1024


Remote Access
Type: vnc
Host: fi-hel1.vnc.upcloud.com
Port: 3000
Password: aabbccdd


49 changes: 2 additions & 47 deletions internal/commands/server/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/UpCloudLtd/upcloud-cli/internal/config"
smock "github.com/UpCloudLtd/upcloud-cli/internal/mock"
"github.com/UpCloudLtd/upcloud-cli/internal/mockexecute"
"github.com/bradleyjkemp/cupaloy/v2"

"github.com/UpCloudLtd/upcloud-go-api/v4/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/v4/upcloud/request"
Expand Down Expand Up @@ -148,52 +149,6 @@ func TestServerHumanOutput(t *testing.T) {
},
}

expected := `
Common
UUID: 0077fa3d-32db-4b09-9f5f-30d9e9afb565
Hostname: server1.example.com
Title: server1.example.com
Plan: 1xCPU-2GB
Zone: fi-hel1
State: started
Simple Backup: 0100,dailies
Licence: 0
Metadata: True
Timezone: UTC
Host ID: 7653311107
Tags: DEV,Ubuntu

Storage: (Flags: B = bootdisk, P = part of plan)

UUID Title Type Address Size (GiB) Flags
────────────────────────────────────── ───────────────────────────────── ────── ────────── ──────────── ───────
012580a1-32a1-466e-a323-689ca16f2d43 Storage for server1.example.com disk virtio:0 20 P

NICs: (Flags: S = source IP filtering, B = bootable)

# Type IP Address MAC Address Network Flags
─── ───────── ──────────────────────────────────────────────────── ─────────────────── ────────────────────────────────────── ───────
1 public IPv4: 94.237.0.207 de:ff:ff:ff:66:89 037fcf2a-6745-45dd-867e-f9479ea8c044
2 utility IPv4: 10.6.3.95 (f) de:ff:ff:ff:ed:85 03000000-0000-4000-8045-000000000000
3 public IPv6: xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx de:ff:ff:ff:cc:20 03c93fd8-cc60-4849-91b8-6e404b228e2a

Firewall Rules:

# Direction Action Src IPAddress Dest IPAddress Src Port Dest Port Protocol
─── ─────────── ──────── ─────────────── ──────────────── ────────── ─────────── ───────────────
1 in accept Any Any Any Any IPv4/tcp
2 out drop 10.10.10.0 → 10.20.20.0 0 → Any IPv4/udp/icmp
10.10.10.99 1024


Remote Access
Type: vnc
Host: fi-hel1.vnc.upcloud.com
Port: 3000
Password: aabbccdd

`

mService := smock.Service{}
mService.On("GetServers").Return(&upcloud.Servers{Servers: []upcloud.Server{srv.Server}}, nil)
mService.On("GetServerDetails", &request.GetServerDetailsRequest{UUID: uuid}).Return(srv, nil)
Expand All @@ -213,5 +168,5 @@ func TestServerHumanOutput(t *testing.T) {
output, err := mockexecute.MockExecute(command, &mService, conf)

assert.NoError(t, err)
assert.Equal(t, expected, output)
cupaloy.SnapshotT(t, output)
}