Skip to content

Commit fa4ff95

Browse files
committed
Add another test about uncorrect verb
1 parent 47022ac commit fa4ff95

File tree

4 files changed

+1885
-1843
lines changed

4 files changed

+1885
-1843
lines changed

internal/services/instance/action_server_action.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import (
1313
"github.com/scaleway/scaleway-sdk-go/scw"
1414
)
1515

16-
var _ action.Action = (*ServerAction)(nil)
16+
var (
17+
_ action.Action = (*ServerAction)(nil)
18+
_ action.ActionWithConfigure = (*ServerAction)(nil)
19+
)
1720

1821
type ServerAction struct {
1922
instanceAPI *instance.API
@@ -38,7 +41,7 @@ func (a *ServerAction) Configure(ctx context.Context, req action.ConfigureReques
3841
}
3942

4043
func (a *ServerAction) Metadata(ctx context.Context, req action.MetadataRequest, resp *action.MetadataResponse) {
41-
resp.TypeName = req.ProviderTypeName + "_instance_server_reboot"
44+
resp.TypeName = req.ProviderTypeName + "_instance_server_action"
4245
}
4346

4447
type ServerActionModel struct {
@@ -71,15 +74,15 @@ func (a *ServerAction) Schema(ctx context.Context, req action.SchemaRequest, res
7174
},
7275
"server_id": schema.StringAttribute{
7376
Required: true,
74-
Description: "Server id to reboot",
77+
Description: "Server id to send the action to",
7578
},
7679
"zone": schema.StringAttribute{
7780
Optional: true,
78-
Description: "Zone of server to reboot",
81+
Description: "Zone of server to send the action to",
7982
},
8083
"wait": schema.BoolAttribute{
8184
Optional: true,
82-
Description: "Wait for server to finish reboot",
85+
Description: "Wait for server to finish action",
8386
},
8487
},
8588
}

internal/services/instance/action_server_action_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,39 @@ func TestAccActionServerReboot_Basic(t *testing.T) {
4242
},
4343
})
4444
}
45+
46+
func TestAccActionServerAction_UncorrectVerb(t *testing.T) {
47+
tt := acctest.NewTestTools(t)
48+
defer tt.Cleanup()
49+
50+
resource.ParallelTest(t, resource.TestCase{
51+
PreCheck: func() { acctest.PreCheck(t) },
52+
ProtoV6ProviderFactories: tt.ProviderFactories,
53+
Steps: []resource.TestStep{
54+
{
55+
Config: `
56+
resource "scaleway_instance_server" "main" {
57+
name = "test-terraform-datasource-private-nic"
58+
type = "DEV1-S"
59+
image = "ubuntu_jammy"
60+
61+
lifecycle {
62+
action_trigger {
63+
events = [after_create]
64+
actions = [action.scaleway_instance_server_action.main]
65+
}
66+
}
67+
}
68+
69+
action "scaleway_instance_server_action" "main" {
70+
config {
71+
action = "incorrectVerb"
72+
server_id = scaleway_instance_server.main.id
73+
}
74+
}
75+
`,
76+
Check: resource.ComposeTestCheckFunc(),
77+
},
78+
},
79+
})
80+
}

internal/services/instance/testdata/action-server-action-uncorrect-verb.cassette.yaml

Lines changed: 1840 additions & 0 deletions
Large diffs are not rendered by default.

internal/services/instance/testdata/action-server-reboot-basic.cassette.yaml

Lines changed: 1 addition & 1838 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)