Skip to content

Commit 6ac31fd

Browse files
cxdyzliang-akamai
andauthored
fix: update MigratingTo field to accept int or null (#736)
* fix: MigratingTo field to accept int or null The Linode API returns either an Integer or `null` for this field. * Bump test image version * Update the test fixture for MigrateTo * Update the test fixture for InstanceGet test case * Update the test fixture for list instances test * Remove unnecessary override as the availability has been expanded * fix unit test fixtures * Fix unit test --------- Co-authored-by: Zhiwei Liang <[email protected]> Co-authored-by: Zhiwei Liang <[email protected]>
1 parent ea79a00 commit 6ac31fd

File tree

8 files changed

+1010
-756
lines changed

8 files changed

+1010
-756
lines changed

instances.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ type InstancePlacementGroup struct {
151151
Label string `json:"label"`
152152
PlacementGroupType PlacementGroupType `json:"placement_group_type"`
153153
PlacementGroupPolicy PlacementGroupPolicy `json:"placement_group_policy"`
154-
MigratingTo string `json:"migrating_to"` // read-only
154+
MigratingTo *int `json:"migrating_to"` // read-only
155155
}
156156

157157
// InstanceMetadataOptions specifies various Instance creation fields

test/integration/fixtures/TestInstance_Get.yaml

Lines changed: 238 additions & 208 deletions
Large diffs are not rendered by default.

test/integration/fixtures/TestInstance_MigrateToPG.yaml

Lines changed: 446 additions & 221 deletions
Large diffs are not rendered by default.

test/integration/fixtures/TestInstances_List.yaml

Lines changed: 317 additions & 318 deletions
Large diffs are not rendered by default.

test/integration/instances_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ func TestInstances_List_smoke(t *testing.T) {
1919
client, instance, _, teardown, err := setupInstanceWithoutDisks(
2020
t,
2121
"fixtures/TestInstances_List", true,
22-
func(client *linodego.Client, options *linodego.InstanceCreateOptions) {
23-
options.Region = "eu-west" // Override for metadata availability
24-
},
2522
)
2623

2724
defer teardown()
@@ -262,7 +259,7 @@ func TestInstance_MigrateToPG(t *testing.T) {
262259
RootPass: randPassword(),
263260
Region: regions[0],
264261
Type: "g6-nanode-1",
265-
Image: "linode/debian10",
262+
Image: "linode/debian12",
266263
Booted: linodego.Pointer(true),
267264
PlacementGroup: &linodego.InstanceCreatePlacementGroupOptions{
268265
ID: pgOutbound.ID,

test/unit/fixtures/instance_get.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"last_successful": "2018-01-01T00:01:01"
1616
},
1717
"placement_group": {
18-
"migrating_to": "2468"
18+
"migrating_to": 2468
1919
}
2020
}
2121

test/unit/fixtures/linodes_list.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"placement_group": {
3333
"id": 528,
3434
"label": "PG_Miami_failover",
35-
"migrating_to": "2468",
35+
"migrating_to": 2468,
3636
"placement_group_policy": "strict",
3737
"placement_group_type": "anti-affinity:local"
3838
},

test/unit/instance_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/linode/linodego"
1111

1212
"github.com/stretchr/testify/assert"
13+
"github.com/stretchr/testify/require"
1314
)
1415

1516
func TestInstances_List(t *testing.T) {
@@ -41,7 +42,8 @@ func TestInstances_List(t *testing.T) {
4142
assert.Equal(t, "us-east", linode.Region)
4243
assert.Equal(t, 4096, linode.Specs.Memory)
4344
assert.Equal(t, "2018-01-01 00:01:01 +0000 UTC", linode.Backups.LastSuccessful.String())
44-
assert.Equal(t, "2468", linode.PlacementGroup.MigratingTo)
45+
require.NotNil(t, linode.PlacementGroup.MigratingTo)
46+
assert.Equal(t, 2468, *linode.PlacementGroup.MigratingTo)
4547
}
4648

4749
func TestInstance_Get(t *testing.T) {
@@ -72,7 +74,8 @@ func TestInstance_Get(t *testing.T) {
7274
assert.Equal(t, "us-east", instance.Region)
7375
assert.Equal(t, 4096, instance.Specs.Memory)
7476
assert.Equal(t, "2018-01-01 00:01:01 +0000 UTC", instance.Backups.LastSuccessful.String())
75-
assert.Equal(t, "2468", instance.PlacementGroup.MigratingTo)
77+
require.NotNil(t, instance.PlacementGroup.MigratingTo)
78+
assert.Equal(t, 2468, *instance.PlacementGroup.MigratingTo)
7679
}
7780

7881
func TestInstance_Migrate(t *testing.T) {

0 commit comments

Comments
 (0)