@@ -128,6 +128,7 @@ func TestAccServer_EnableVPC(t *testing.T) {
128128 isServerPresent (tt , "scaleway_apple_silicon_server.main" ),
129129 resource .TestCheckResourceAttr ("scaleway_apple_silicon_server.main" , "name" , "TestAccServerEnableVPC" ),
130130 resource .TestCheckResourceAttr ("scaleway_apple_silicon_server.main" , "type" , "M2-M" ),
131+ resource .TestCheckResourceAttr ("scaleway_apple_silicon_server.main" , "commitment" , "duration_24h" ),
131132 // Computed
132133 resource .TestCheckResourceAttrSet ("scaleway_apple_silicon_server.main" , "ip" ),
133134 resource .TestCheckResourceAttrSet ("scaleway_apple_silicon_server.main" , "vnc_url" ),
@@ -225,6 +226,61 @@ func TestAccServer_EnableVPC(t *testing.T) {
225226 })
226227}
227228
229+ func TestAccServer_Commitment (t * testing.T ) {
230+ t .Skip ("can not delete server at the time" )
231+
232+ tt := acctest .NewTestTools (t )
233+ defer tt .Cleanup ()
234+ resource .ParallelTest (t , resource.TestCase {
235+ PreCheck : func () { acctest .PreCheck (t ) },
236+ ProviderFactories : tt .ProviderFactories ,
237+ CheckDestroy : isServerDestroyed (tt ),
238+ Steps : []resource.TestStep {
239+ {
240+ Config : `
241+
242+ resource scaleway_apple_silicon_server main {
243+ name = "TestAccServerEnableDisableVPC"
244+ type = "M2-M"
245+ }
246+ ` ,
247+ Check : resource .ComposeTestCheckFunc (
248+ isServerPresent (tt , "scaleway_apple_silicon_server.main" ),
249+ resource .TestCheckResourceAttr ("scaleway_apple_silicon_server.main" , "name" , "TestAccServerEnableDisableVPC" ),
250+ resource .TestCheckResourceAttr ("scaleway_apple_silicon_server.main" , "type" , "M2-M" ),
251+ resource .TestCheckResourceAttr ("scaleway_apple_silicon_server.main" , "commitment" , "duration_24h" ),
252+ // Computed
253+ resource .TestCheckResourceAttrSet ("scaleway_apple_silicon_server.main" , "ip" ),
254+ resource .TestCheckResourceAttrSet ("scaleway_apple_silicon_server.main" , "vnc_url" ),
255+ resource .TestCheckResourceAttrSet ("scaleway_apple_silicon_server.main" , "created_at" ),
256+ resource .TestCheckResourceAttrSet ("scaleway_apple_silicon_server.main" , "deletable_at" ),
257+ ),
258+ },
259+ {
260+ Config : `
261+
262+ resource scaleway_apple_silicon_server main {
263+ name = "TestAccServerEnableDisableVPC"
264+ type = "M2-M"
265+ commitment = "renewed_monthly"
266+ }
267+ ` ,
268+ Check : resource .ComposeTestCheckFunc (
269+ isServerPresent (tt , "scaleway_apple_silicon_server.main" ),
270+ resource .TestCheckResourceAttr ("scaleway_apple_silicon_server.main" , "name" , "TestAccServerEnableDisableVPC" ),
271+ resource .TestCheckResourceAttr ("scaleway_apple_silicon_server.main" , "type" , "M2-M" ),
272+ resource .TestCheckResourceAttr ("scaleway_apple_silicon_server.main" , "commitment" , "renewed_monthly" ),
273+ // Computed
274+ resource .TestCheckResourceAttrSet ("scaleway_apple_silicon_server.main" , "ip" ),
275+ resource .TestCheckResourceAttrSet ("scaleway_apple_silicon_server.main" , "vnc_url" ),
276+ resource .TestCheckResourceAttrSet ("scaleway_apple_silicon_server.main" , "created_at" ),
277+ resource .TestCheckResourceAttrSet ("scaleway_apple_silicon_server.main" , "deletable_at" ),
278+ ),
279+ },
280+ },
281+ })
282+ }
283+
228284func isServerPresent (tt * acctest.TestTools , n string ) resource.TestCheckFunc {
229285 return func (s * terraform.State ) error {
230286 rs , ok := s .RootModule ().Resources [n ]
0 commit comments