Skip to content

Commit 40edd8c

Browse files
authored
tests(lb): set explicit ipam ip (#4920)
1 parent e0f433b commit 40edd8c

File tree

4 files changed

+179
-290
lines changed

4 files changed

+179
-290
lines changed

internal/namespaces/lb/v1/custom_private_network_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@ import (
55
"time"
66

77
"github.com/scaleway/scaleway-cli/v2/core"
8+
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/ipam/v1"
89
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/lb/v1"
910
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/vpc/v2"
1011
)
1112

1213
func Test_ListLBPrivateNetwork(t *testing.T) {
1314
cmds := lb.GetCommands()
1415
cmds.Merge(vpc.GetCommands())
16+
cmds.Merge(ipam.GetCommands())
1517

1618
t.Run("Simple", core.Test(&core.TestConfig{
1719
Commands: cmds,
1820
BeforeFunc: core.BeforeFuncCombine(
1921
createLB(),
2022
createPN(),
23+
createIPAMIP(),
2124
attachPN(),
2225
),
2326
Cmd: "scw lb private-network list {{ .LB.ID }}",
@@ -32,6 +35,7 @@ func Test_ListLBPrivateNetwork(t *testing.T) {
3235
return nil
3336
},
3437
),
38+
deleteIPAMIP(),
3539
deletePN(),
3640
deleteLBFlexibleIP(),
3741
),

internal/namespaces/lb/v1/helper_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func deletePN() core.AfterFunc {
171171

172172
func attachPN() core.BeforeFunc {
173173
return core.ExecBeforeCmd(
174-
"scw lb private-network attach {{ .LB.ID }} private-network-id={{ .PN.ID }}",
174+
"scw lb private-network attach {{ .LB.ID }} private-network-id={{ .PN.ID }} ipam-ids.0={{ .IPAMIP.ID }}",
175175
)
176176
}
177177

@@ -187,3 +187,14 @@ func createIP() core.BeforeFunc {
187187
"scw lb ip create is-ipv6=true",
188188
)
189189
}
190+
191+
func createIPAMIP() core.BeforeFunc {
192+
return core.ExecStoreBeforeCmd(
193+
"IPAMIP",
194+
"scw ipam ip create source.private-network-id={{ .PN.ID }}",
195+
)
196+
}
197+
198+
func deleteIPAMIP() core.AfterFunc {
199+
return core.ExecAfterCmd("scw ipam ip delete {{ .IPAMIP.ID }}")
200+
}

0 commit comments

Comments
 (0)