Skip to content

Commit

Permalink
Reran fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
ezilber-akamai committed Jul 1, 2024
1 parent 228475f commit ecb0744
Show file tree
Hide file tree
Showing 18 changed files with 3,611 additions and 2,656 deletions.
4 changes: 2 additions & 2 deletions instance_snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ func (c *Client) GetInstanceBackups(ctx context.Context, linodeID int) (*Instanc
// EnableInstanceBackups Enables backups for the specified Linode.
func (c *Client) EnableInstanceBackups(ctx context.Context, linodeID int) error {
e := formatAPIPath("linode/instances/%d/backups/enable", linodeID)
_, err := doPOSTRequest[InstanceBackup](ctx, c, e, []any{})
_, err := doPOSTRequest[InstanceBackup, any](ctx, c, e)
return err
}

// CancelInstanceBackups Cancels backups for the specified Linode.
func (c *Client) CancelInstanceBackups(ctx context.Context, linodeID int) error {
e := formatAPIPath("linode/instances/%d/backups/cancel", linodeID)
_, err := doPOSTRequest[InstanceBackup](ctx, c, e, []any{})
_, err := doPOSTRequest[InstanceBackup, any](ctx, c, e)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func (c *Client) DeleteInstance(ctx context.Context, linodeID int) error {
// BootInstance will boot a Linode instance
// A configID of 0 will cause Linode to choose the last/best config
func (c *Client) BootInstance(ctx context.Context, linodeID int, configID int) error {
var opts map[string]int
opts := make(map[string]int)

if configID != 0 {
opts = map[string]int{"config_id": configID}
Expand All @@ -334,7 +334,7 @@ func (c *Client) CloneInstance(ctx context.Context, linodeID int, opts InstanceC
// RebootInstance reboots a Linode instance
// A configID of 0 will cause Linode to choose the last/best config
func (c *Client) RebootInstance(ctx context.Context, linodeID int, configID int) error {
var opts map[string]int
opts := make(map[string]int)

if configID != 0 {
opts = map[string]int{"config_id": configID}
Expand Down
17 changes: 13 additions & 4 deletions request_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"net/url"
"reflect"
"strconv"
)

Expand Down Expand Up @@ -130,12 +131,11 @@ func doPOSTRequest[T, O any](

req := client.R(ctx).SetResult(&resultType)

if numOpts > 0 {
if numOpts > 0 && !isNil(options[0]) {
body, err := json.Marshal(options[0])
if err != nil {
return nil, err
}

req.SetBody(string(body))
}

Expand Down Expand Up @@ -165,12 +165,11 @@ func doPUTRequest[T, O any](

req := client.R(ctx).SetResult(&resultType)

if numOpts > 0 {
if numOpts > 0 && !isNil(options[0]) {
body, err := json.Marshal(options[0])
if err != nil {
return nil, err
}

req.SetBody(string(body))
}

Expand Down Expand Up @@ -207,3 +206,13 @@ func formatAPIPath(format string, args ...any) string {

return fmt.Sprintf(format, escapedArgs...)
}

func isNil(i interface{}) bool {
if i == nil {
return true
}

// Check for nil pointers
v := reflect.ValueOf(i)
return v.Kind() == reflect.Ptr && v.IsNil()
}
947 changes: 532 additions & 415 deletions test/integration/fixtures/TestInstanceBackups_List.yaml

Large diffs are not rendered by default.

564 changes: 340 additions & 224 deletions test/integration/fixtures/TestInstance_Clone.yaml

Large diffs are not rendered by default.

383 changes: 224 additions & 159 deletions test/integration/fixtures/TestInstance_CreateUnderFirewall.yaml

Large diffs are not rendered by default.

539 changes: 338 additions & 201 deletions test/integration/fixtures/TestInstance_Disk_ListMultiple_Primary.yaml

Large diffs are not rendered by default.

539 changes: 302 additions & 237 deletions test/integration/fixtures/TestInstance_Disk_ListMultiple_Secondary.yaml

Large diffs are not rendered by default.

422 changes: 244 additions & 178 deletions test/integration/fixtures/TestInstance_Disk_ResetPassword.yaml

Large diffs are not rendered by default.

372 changes: 218 additions & 154 deletions test/integration/fixtures/TestInstance_Disk_Resize.yaml

Large diffs are not rendered by default.

251 changes: 129 additions & 122 deletions test/integration/fixtures/TestInstance_Disks_List.yaml

Large diffs are not rendered by default.

411 changes: 238 additions & 173 deletions test/integration/fixtures/TestInstance_Rebuild.yaml

Large diffs are not rendered by default.

413 changes: 159 additions & 254 deletions test/integration/fixtures/TestInstance_Resize.yaml

Large diffs are not rendered by default.

359 changes: 211 additions & 148 deletions test/integration/fixtures/TestInstance_Volumes_List.yaml

Large diffs are not rendered by default.

372 changes: 218 additions & 154 deletions test/integration/fixtures/TestInstance_withMetadata.yaml

Large diffs are not rendered by default.

394 changes: 301 additions & 93 deletions test/integration/fixtures/TestInstance_withPG.yaml

Large diffs are not rendered by default.

274 changes: 139 additions & 135 deletions test/integration/fixtures/TestInstances_List.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/integration/instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func TestInstance_Rebuild(t *testing.T) {
}

rebuildOpts := linodego.InstanceRebuildOptions{
Image: "linode/alpine3.15",
Image: "linode/alpine3.19",
Metadata: &linodego.InstanceMetadataOptions{
UserData: base64.StdEncoding.EncodeToString([]byte("cool")),
},
Expand Down

0 comments on commit ecb0744

Please sign in to comment.