77 "fmt"
88 "io"
99 "net/http"
10+ "os"
1011 "testing"
1112
1213 "github.com/golang/mock/gomock"
@@ -227,14 +228,15 @@ func TestHibernationSchedule_CreateContext(t *testing.T) {
227228func TestAccResourceHibernationSchedule_basic (t * testing.T ) {
228229 resourceName := fmt .Sprintf ("%v-hibernation-schedule-%v" , ResourcePrefix , acctest .RandString (8 ))
229230 renamedResourceName := fmt .Sprintf ("%s %s" , resourceName , "renamed" )
231+ organizationID := os .Getenv ("ACCEPTANCE_TEST_ORGANIZATION_ID" )
230232
231233 resource .ParallelTest (t , resource.TestCase {
232234 PreCheck : func () { testAccPreCheck (t ) },
233235
234236 ProviderFactories : providerFactories ,
235237 Steps : []resource.TestStep {
236238 {
237- Config : makeInitialHibernationScheduleConfig (resourceName ),
239+ Config : makeInitialHibernationScheduleConfig (resourceName , organizationID ),
238240 Check : resource .ComposeTestCheckFunc (
239241 resource .TestCheckResourceAttr ("castai_hibernation_schedule.test_hibernation_schedule" , "name" , resourceName ),
240242 resource .TestCheckResourceAttr ("castai_hibernation_schedule.test_hibernation_schedule" , "enabled" , "false" ),
@@ -247,9 +249,9 @@ func TestAccResourceHibernationSchedule_basic(t *testing.T) {
247249 },
248250 {
249251 // test edits
250- Config : makeUpdateHibernationScheduleConfig (renamedResourceName ),
252+ Config : makeUpdateHibernationScheduleConfig (renamedResourceName , organizationID ),
251253 Check : resource .ComposeTestCheckFunc (
252- resource .TestCheckResourceAttr ("castai_rebalancing_schedule.test " , "name" , renamedResourceName ),
254+ resource .TestCheckResourceAttr ("castai_hibernation_schedule.test_hibernation_schedule " , "name" , renamedResourceName ),
253255 resource .TestCheckResourceAttr ("castai_hibernation_schedule.test_hibernation_schedule" , "enabled" , "true" ),
254256 resource .TestCheckResourceAttr ("castai_hibernation_schedule.test_hibernation_schedule" , "pause_config.0.enabled" , "false" ),
255257 resource .TestCheckResourceAttr ("castai_hibernation_schedule.test_hibernation_schedule" , "pause_config.0.schedule.0.cron_expression" , "1 0 * * *" ),
@@ -258,14 +260,6 @@ func TestAccResourceHibernationSchedule_basic(t *testing.T) {
258260 resource .TestCheckResourceAttr ("castai_hibernation_schedule.test_hibernation_schedule" , "resume_config.0.job_config.0.node_config.0.instance_type" , "e2-standard-8" ),
259261 ),
260262 },
261- // We keep the ImportState test cases at the end so they will test any newly added fields.
262- // This way it will also verify that after importing the state the output of `tf plan` is empty.
263- {
264- // Import state by ID
265- ImportState : true ,
266- ResourceName : "castai_hibernation_schedule.test_hibernation_schedule" ,
267- ImportStateVerify : true ,
268- },
269263 {
270264 // Import state by name
271265 ImportState : true ,
@@ -277,11 +271,12 @@ func TestAccResourceHibernationSchedule_basic(t *testing.T) {
277271 })
278272}
279273
280- func makeInitialHibernationScheduleConfig (rName string ) string {
274+ func makeInitialHibernationScheduleConfig (rName string , organizationID string ) string {
281275 template := `
282276resource "castai_hibernation_schedule" "test_hibernation_schedule" {
283277 name = %q
284278 enabled = false
279+ organization_id = %q
285280
286281 pause_config {
287282 enabled = true
@@ -308,14 +303,15 @@ resource "castai_hibernation_schedule" "test_hibernation_schedule" {
308303 cluster_assignments {}
309304}
310305`
311- return fmt .Sprintf (template , rName )
306+ return fmt .Sprintf (template , rName , organizationID )
312307}
313308
314- func makeUpdateHibernationScheduleConfig (rName string ) string {
309+ func makeUpdateHibernationScheduleConfig (rName string , organizationID string ) string {
315310 template := `
316311resource "castai_hibernation_schedule" "test_hibernation_schedule" {
317312 name = %q
318313 enabled = true
314+ organization_id = %q
319315
320316 pause_config {
321317 enabled = false
@@ -342,5 +338,5 @@ resource "castai_hibernation_schedule" "test_hibernation_schedule" {
342338 cluster_assignments {}
343339}
344340`
345- return fmt .Sprintf (template , rName )
341+ return fmt .Sprintf (template , rName , organizationID )
346342}
0 commit comments