Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests(vpc): fix postgres version #4365

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func Test_GetPrivateNetwork(t *testing.T) {
createNIC(),
createLB(),
attachLB(),
createRdbInstance(),
createRdbInstance("RDB", "PostgreSQL"),
),
Cmd: "scw vpc private-network get {{ .PN.ID }}",
Check: core.TestCheckGolden(),
Expand Down
22 changes: 17 additions & 5 deletions internal/namespaces/vpc/v2/helper_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package vpc_test

import (
"fmt"

"github.com/scaleway/scaleway-cli/v2/core"
rdbAPI "github.com/scaleway/scaleway-sdk-go/api/rdb/v1"
)

func createInstance() core.BeforeFunc {
Expand Down Expand Up @@ -56,11 +59,20 @@ func deleteLB() core.AfterFunc {
return core.ExecAfterCmd("scw lb lb delete {{ .LB.ID }}")
}

func createRdbInstance() core.BeforeFunc {
return core.ExecStoreBeforeCmd(
"RDB",
"scw rdb instance create node-type=DB-DEV-S is-ha-cluster=false name=cli-test engine=PostgreSQL-12 user-name=foobar password={4xdl*#QOoP+&3XRkGA)] init-endpoints.0.private-network.private-network-id={{ .PN.ID }} init-endpoints.0.private-network.service-ip=192.168.0.1/24 --wait",
)
func createRdbInstance(metaKey, engineName string) core.BeforeFunc {
return func(ctx *core.BeforeFuncCtx) error {
api := rdbAPI.NewAPI(ctx.Client)
engine, err := api.FetchLatestEngineVersion(engineName)
if err != nil {
return err
}
cmd := fmt.Sprintf(
"scw rdb instance create node-type=DB-DEV-S is-ha-cluster=false name=cli-test engine=%s user-name=foobar password={4xdl*#QOoP+&3XRkGA)] init-endpoints.0.private-network.private-network-id={{ .PN.ID }} init-endpoints.0.private-network.service-ip=192.168.0.1/24 --wait",
engine.Name,
)

return core.ExecStoreBeforeCmd(metaKey, cmd)(ctx)
}
}

func detachRdbInstance() core.AfterFunc {
Expand Down
Loading
Loading