|
| 1 | +// SPDX-FileCopyrightText: 2025 OVH SAS <opensource@ovh.net> |
| 2 | +// |
| 3 | +// SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +package cmd_test |
| 6 | + |
| 7 | +import ( |
| 8 | + "net/http" |
| 9 | + |
| 10 | + "github.com/jarcoal/httpmock" |
| 11 | + "github.com/maxatome/go-testdeep/td" |
| 12 | + "github.com/ovh/ovhcloud-cli/internal/cmd" |
| 13 | +) |
| 14 | + |
| 15 | +func (ms *MockSuite) TestCloudInstanceNullImageCmd(assert, require *td.T) { |
| 16 | + httpmock.RegisterResponder(http.MethodGet, |
| 17 | + "https://eu.api.ovh.com/1.0/cloud/project/fakeProjectID/instance/fakeInstanceID", |
| 18 | + httpmock.NewStringResponder(200, ` |
| 19 | + { |
| 20 | + "id": "fakeInstanceID", |
| 21 | + "name": "TestInstance", |
| 22 | + "ipAddresses": [ |
| 23 | + { |
| 24 | + "ip": "1.2.3.4", |
| 25 | + "type": "public", |
| 26 | + "version": 4, |
| 27 | + "networkId": "bc63b98d13fbba642b2653711cc9d156ca7b404f009f7227172d37b5280a6", |
| 28 | + "gatewayIp": "1.2.3.4" |
| 29 | + }, |
| 30 | + { |
| 31 | + "ip": "2001:db8::1", |
| 32 | + "type": "public", |
| 33 | + "version": 6, |
| 34 | + "networkId": "bc63b98d13fbba642b2653711cc9d156ca7b404f009f7227172d37b5280a6", |
| 35 | + "gatewayIp": "2001:db8::ff" |
| 36 | + } |
| 37 | + ], |
| 38 | + "status": "ACTIVE", |
| 39 | + "created": "2025-09-24T17:21:31Z", |
| 40 | + "region": "GRA9", |
| 41 | + "flavor": { |
| 42 | + "id": "906e8259-0340-4856-95b5-4ea2d26fe377", |
| 43 | + "name": "b2-7", |
| 44 | + "region": "GRA9", |
| 45 | + "ram": 7, |
| 46 | + "disk": 50, |
| 47 | + "vcpus": 2, |
| 48 | + "type": "ovh.ssd.eg", |
| 49 | + "osType": "linux", |
| 50 | + "inboundBandwidth": 250, |
| 51 | + "outboundBandwidth": 250, |
| 52 | + "available": true, |
| 53 | + "planCodes": { |
| 54 | + "monthly": "b2-7.monthly.postpaid", |
| 55 | + "hourly": "b2-7.consumption", |
| 56 | + "license": null |
| 57 | + }, |
| 58 | + "capabilities": [ |
| 59 | + { |
| 60 | + "name": "resize", |
| 61 | + "enabled": true |
| 62 | + }, |
| 63 | + { |
| 64 | + "name": "snapshot", |
| 65 | + "enabled": true |
| 66 | + }, |
| 67 | + { |
| 68 | + "name": "volume", |
| 69 | + "enabled": true |
| 70 | + }, |
| 71 | + { |
| 72 | + "name": "failoverip", |
| 73 | + "enabled": true |
| 74 | + } |
| 75 | + ], |
| 76 | + "quota": 791 |
| 77 | + }, |
| 78 | + "image": null, |
| 79 | + "sshKey": null, |
| 80 | + "monthlyBilling": null, |
| 81 | + "planCode": "b2-7.consumption", |
| 82 | + "licensePlanCode": null, |
| 83 | + "operationIds": [], |
| 84 | + "currentMonthOutgoingTraffic": null, |
| 85 | + "rescuePassword": null, |
| 86 | + "availabilityZone": null |
| 87 | + }`, |
| 88 | + ), |
| 89 | + ) |
| 90 | + |
| 91 | + out, err := cmd.Execute("cloud", "instance", "get", "fakeInstanceID", "--cloud-project", "fakeProjectID") |
| 92 | + |
| 93 | + require.CmpNoError(err) |
| 94 | + assert.Cmp(cleanWhitespacesHelper(out), ` |
| 95 | + # 🚀 Instance fakeInstanceID |
| 96 | +
|
| 97 | + *TestInstance* |
| 98 | +
|
| 99 | + ## General information |
| 100 | +
|
| 101 | + **Region**: GRA9 |
| 102 | + **Availability zone**: |
| 103 | + **Status**: ACTIVE |
| 104 | + **Creation date**: 2025-09-24T17:21:31Z |
| 105 | +
|
| 106 | + IP addresses: |
| 107 | +
|
| 108 | + IP | Type | Gateway IP |
| 109 | + ------------------------|------------------------|------------------------ |
| 110 | + 1.2.3.4 | public | 1.2.3.4 |
| 111 | + 2001:db8::1 | public | 2001:db8::ff |
| 112 | +
|
| 113 | + ## Flavor details |
| 114 | +
|
| 115 | + **Name**: b2-7 |
| 116 | + **Operating system**: linux |
| 117 | + **Number of disks**: 50 |
| 118 | + **RAM**: 7 Mio |
| 119 | + **vCPUs**: 2 |
| 120 | + **Max inbound bandwidth**: 250Mbit/s |
| 121 | + **Max outbound bandwidth**: 250Mbit/s |
| 122 | +
|
| 123 | + 💡 Use option --json or --yaml to get the raw output with all information |
| 124 | +
|
| 125 | +`) |
| 126 | +} |
0 commit comments