@@ -69,6 +69,7 @@ func TestAccScalewayFunctionCron_Basic(t *testing.T) {
6969 }
7070
7171 resource scaleway_function_cron main {
72+ name = "tf-tests-cron-basic"
7273 function_id = scaleway_function.main.id
7374 schedule = "0 0 * * *"
7475 args = jsonencode({})
@@ -77,6 +78,73 @@ func TestAccScalewayFunctionCron_Basic(t *testing.T) {
7778 Check : resource .ComposeTestCheckFunc (
7879 testAccCheckScalewayFunctionCronExists (tt , "scaleway_function_cron.main" ),
7980 resource .TestCheckResourceAttr ("scaleway_function_cron.main" , "schedule" , "0 0 * * *" ),
81+ resource .TestCheckResourceAttr ("scaleway_function_cron.main" , "name" , "tf-tests-cron-basic" ),
82+ ),
83+ },
84+ },
85+ })
86+ }
87+
88+ func TestAccScalewayFunctionCron_NameUpdate (t * testing.T ) {
89+ tt := NewTestTools (t )
90+ defer tt .Cleanup ()
91+
92+ resource .ParallelTest (t , resource.TestCase {
93+ PreCheck : func () { testAccPreCheck (t ) },
94+ ProviderFactories : tt .ProviderFactories ,
95+ CheckDestroy : testAccCheckScalewayFunctionCronDestroy (tt ),
96+ Steps : []resource.TestStep {
97+ {
98+ Config : `
99+ resource scaleway_function_namespace main {
100+ name = "tf-tests-function-cron-name-update"
101+ }
102+
103+ resource scaleway_function main {
104+ name = "tf-tests-function-cron-name-update"
105+ namespace_id = scaleway_function_namespace.main.id
106+ runtime = "node14"
107+ privacy = "private"
108+ handler = "handler.handle"
109+ }
110+
111+ resource scaleway_function_cron main {
112+ name = "tf-tests-function-cron-name-update"
113+ function_id = scaleway_function.main.id
114+ schedule = "0 0 * * *"
115+ args = jsonencode({})
116+ }
117+ ` ,
118+ Check : resource .ComposeTestCheckFunc (
119+ testAccCheckScalewayFunctionCronExists (tt , "scaleway_function_cron.main" ),
120+ resource .TestCheckResourceAttr ("scaleway_function_cron.main" , "schedule" , "0 0 * * *" ),
121+ resource .TestCheckResourceAttr ("scaleway_function_cron.main" , "name" , "tf-tests-function-cron-name-update" ),
122+ ),
123+ },
124+ {
125+ Config : `
126+ resource scaleway_function_namespace main {
127+ name = "tf-tests-function-cron-name-update"
128+ }
129+
130+ resource scaleway_function main {
131+ name = "tf-tests-function-cron-name-update"
132+ namespace_id = scaleway_function_namespace.main.id
133+ runtime = "node14"
134+ privacy = "private"
135+ handler = "handler.handle"
136+ }
137+
138+ resource scaleway_function_cron main {
139+ name = "name-changed"
140+ function_id = scaleway_function.main.id
141+ schedule = "0 0 * * *"
142+ args = jsonencode({test = "scw"})
143+ }
144+ ` ,
145+ Check : resource .ComposeTestCheckFunc (
146+ testAccCheckScalewayFunctionCronExists (tt , "scaleway_function_cron.main" ),
147+ resource .TestCheckResourceAttr ("scaleway_function_cron.main" , "name" , "name-changed" ),
80148 ),
81149 },
82150 },
@@ -107,6 +175,7 @@ func TestAccScalewayFunctionCron_WithArgs(t *testing.T) {
107175 }
108176
109177 resource scaleway_function_cron main {
178+ name = "tf-tests-cron-with-args"
110179 function_id = scaleway_function.main.id
111180 schedule = "0 0 * * *"
112181 args = jsonencode({test = "scw"})
@@ -116,6 +185,7 @@ func TestAccScalewayFunctionCron_WithArgs(t *testing.T) {
116185 testAccCheckScalewayFunctionCronExists (tt , "scaleway_function_cron.main" ),
117186 resource .TestCheckResourceAttr ("scaleway_function_cron.main" , "schedule" , "0 0 * * *" ),
118187 resource .TestCheckResourceAttr ("scaleway_function_cron.main" , "args" , "{\" test\" :\" scw\" }" ),
188+ resource .TestCheckResourceAttr ("scaleway_function_cron.main" , "name" , "tf-tests-cron-with-args" ),
119189 ),
120190 },
121191 },
0 commit comments