Skip to content

Commit ff848b7

Browse files
fix unit tests (#828)
1 parent 5c816a6 commit ff848b7

File tree

10 files changed

+67
-10
lines changed

10 files changed

+67
-10
lines changed

mysql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ type MySQLUpdateOptions struct {
427427
ClusterSize int `json:"cluster_size,omitempty"`
428428
Version string `json:"version,omitempty"`
429429
EngineConfig *MySQLDatabaseEngineConfig `json:"engine_config,omitempty"`
430-
PrivateNetwork *DatabasePrivateNetwork `json:"private_network,omitempty"`
430+
PrivateNetwork **DatabasePrivateNetwork `json:"private_network,omitempty"`
431431
}
432432

433433
// MySQLDatabaseBackup is information for interacting with a backup for the existing MySQL Database

test/unit/fixtures/vpc_get.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
]
2828
}
2929
],
30+
"databases": [
31+
{
32+
"id": 123,
33+
"ipv4_range": "10.0.0.4/32",
34+
"ipv6_range": null
35+
}
36+
],
3037
"updated": "2023-09-11T00:00:00"
3138
}
3239
],

test/unit/fixtures/vpc_list.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434
]
3535
}
3636
],
37+
"databases": [
38+
{
39+
"id": 123,
40+
"ipv4_range": "10.0.0.4/32",
41+
"ipv6_range": null
42+
}
43+
],
3744
"updated": "2023-09-11T00:00:00"
3845
}
3946
],

test/unit/fixtures/vpc_subnet_create.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
}
99
],
1010
"linodes": [],
11+
"databases": [],
1112
"created": "2025-01-01T12:00:00",
1213
"updated": "2025-01-01T12:00:00"
1314
}

test/unit/fixtures/vpc_subnet_get.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
]
2525
}
2626
],
27+
"databases": [
28+
{
29+
"id": 123,
30+
"ipv4_range": "10.0.0.4/32",
31+
"ipv6_range": null
32+
}
33+
],
2734
"created": "2025-01-01T10:00:00",
2835
"updated": "2025-01-02T10:00:00"
2936
}

test/unit/fixtures/vpc_subnets_list.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,22 @@
2626
}
2727
]
2828
}
29-
]
29+
],
30+
"databases": []
3031
},
3132
{
3233
"id": 124,
3334
"label": "Subnet B",
3435
"ipv4": "192.168.4.0/24",
3536
"ipv6": [],
3637
"linodes": [],
38+
"databases": [
39+
{
40+
"id": 123,
41+
"ipv4_range": "10.0.0.4/32",
42+
"ipv6_range": null
43+
}
44+
],
3745
"updated": "2023-09-11T00:00:00"
3846
}
3947
],

test/unit/mysql_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,13 @@ func TestDatabaseMySQL_Update(t *testing.T) {
102102
ConnectTimeout: linodego.Pointer(20),
103103
},
104104
},
105-
PrivateNetwork: &linodego.DatabasePrivateNetwork{
106-
VPCID: 1234,
107-
SubnetID: 5678,
108-
PublicAccess: true,
109-
},
105+
PrivateNetwork: linodego.DoublePointer(
106+
linodego.DatabasePrivateNetwork{
107+
VPCID: 1234,
108+
SubnetID: 5678,
109+
PublicAccess: true,
110+
},
111+
),
110112
}
111113

112114
base.MockPut("databases/mysql/instances/123", fixtureData)

test/unit/vpc_subnets_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ func TestVPCSubnet_Get(t *testing.T) {
7070
assert.Equal(t, 422, subnet.Linodes[0].Interfaces[1].ID)
7171
assert.False(t, subnet.Linodes[0].Interfaces[1].Active, "Expected interface to be inactive")
7272
assert.Nil(t, subnet.Linodes[0].Interfaces[1].ConfigID)
73+
74+
assert.Equal(t, 123, subnet.Databases[0].ID)
75+
assert.Equal(t, "10.0.0.4/32", *subnet.Databases[0].IPv4Range)
76+
assert.Nil(t, subnet.Databases[0].IPv6Range)
7377
}
7478

7579
func TestVPCSubnets_List(t *testing.T) {
@@ -112,6 +116,10 @@ func TestVPCSubnets_List(t *testing.T) {
112116
assert.Equal(t, "192.168.4.0/24", subnet.IPv4, "Expected second subnet IPv4 to match")
113117
assert.Empty(t, subnet.IPv6, 0, "Expected second subnet to not support IPv6")
114118
assert.Empty(t, subnet.Linodes, 0, "Expected second subnet to not have Linodes")
119+
120+
assert.Equal(t, 123, subnet.Databases[0].ID)
121+
assert.Equal(t, "10.0.0.4/32", *subnet.Databases[0].IPv4Range)
122+
assert.Nil(t, subnet.Databases[0].IPv6Range)
115123
}
116124

117125
func TestVPCSubnet_Update(t *testing.T) {

test/unit/vpc_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ func TestVPC_Get(t *testing.T) {
8989
assert.Equal(t, true, vpc.Subnets[0].Linodes[0].Interfaces[0].Active)
9090
assert.Equal(t, 4567, *vpc.Subnets[0].Linodes[0].Interfaces[0].ConfigID)
9191
assert.Equal(t, 421, vpc.Subnets[0].Linodes[0].Interfaces[0].ID)
92+
93+
assert.Equal(t, 123, vpc.Subnets[0].Databases[0].ID)
94+
assert.Equal(t, "10.0.0.4/32", *vpc.Subnets[0].Databases[0].IPv4Range)
95+
assert.Nil(t, vpc.Subnets[0].Databases[0].IPv6Range)
9296
}
9397

9498
func TestVPC_List(t *testing.T) {
@@ -127,6 +131,10 @@ func TestVPC_List(t *testing.T) {
127131
assert.Equal(t, true, vpc.Subnets[0].Linodes[0].Interfaces[0].Active)
128132
assert.Equal(t, 4567, *vpc.Subnets[0].Linodes[0].Interfaces[0].ConfigID)
129133
assert.Equal(t, 421, vpc.Subnets[0].Linodes[0].Interfaces[0].ID)
134+
135+
assert.Equal(t, 123, vpc.Subnets[0].Databases[0].ID)
136+
assert.Equal(t, "10.0.0.4/32", *vpc.Subnets[0].Databases[0].IPv4Range)
137+
assert.Nil(t, vpc.Subnets[0].Databases[0].IPv6Range)
130138
}
131139

132140
func TestVPC_Update(t *testing.T) {

vpc_subnet.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ type VPCSubnetLinode struct {
2222
Interfaces []VPCSubnetLinodeInterface `json:"interfaces"`
2323
}
2424

25+
// VPCSubnetDatabase represents a Linode currently assigned to a VPC subnet.
26+
type VPCSubnetDatabase struct {
27+
ID int `json:"id"`
28+
IPv4Range *string `json:"ipv4_range"`
29+
IPv6Range *string `json:"ipv6_range"`
30+
}
31+
2532
type VPCSubnet struct {
2633
ID int `json:"id"`
2734
Label string `json:"label"`
@@ -30,9 +37,11 @@ type VPCSubnet struct {
3037
// NOTE: IPv6 VPCs may not currently be available to all users.
3138
IPv6 []VPCIPv6Range `json:"ipv6"`
3239

33-
Linodes []VPCSubnetLinode `json:"linodes"`
34-
Created *time.Time `json:"-"`
35-
Updated *time.Time `json:"-"`
40+
Linodes []VPCSubnetLinode `json:"linodes"`
41+
Databases []VPCSubnetDatabase `json:"databases"`
42+
43+
Created *time.Time `json:"-"`
44+
Updated *time.Time `json:"-"`
3645
}
3746

3847
type VPCSubnetCreateOptions struct {

0 commit comments

Comments
 (0)