package nomad import ( "fmt" "strings" "testing" r "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" "github.com/hashicorp/nomad/api" ) func TestResourceJob_basic(t *testing.T) { r.Test(t, r.TestCase{ Providers: testProviders, PreCheck: func() { testAccPreCheck(t) }, Steps: []r.TestStep{ r.TestStep{ Config: testResourceJob_initialConfig, Check: testResourceJob_initialCheck, }, }, CheckDestroy: testResourceJob_checkDestroy("foo"), }) } func TestResourceJob_refresh(t *testing.T) { r.Test(t, r.TestCase{ Providers: testProviders, PreCheck: func() { testAccPreCheck(t) }, Steps: []r.TestStep{ r.TestStep{ Config: testResourceJob_initialConfig, Check: testResourceJob_initialCheck, }, // This should successfully cause the job to be recreated, // testing the Exists function. r.TestStep{ PreConfig: testResourceJob_deregister(t, "foo"), Config: testResourceJob_initialConfig, }, }, }) } func TestResourceJob_disableDestroyDeregister(t *testing.T) { r.Test(t, r.TestCase{ Providers: testProviders, PreCheck: func() { testAccPreCheck(t) }, Steps: []r.TestStep{ r.TestStep{ Config: testResourceJob_noDestroy, Check: testResourceJob_initialCheck, }, // Destroy with our setting set r.TestStep{ Destroy: true, Config: testResourceJob_noDestroy, Check: testResourceJob_checkExists, }, // Re-apply without the setting set r.TestStep{ Config: testResourceJob_initialConfig, Check: testResourceJob_checkExists, }, }, }) } func TestResourceJob_idChange(t *testing.T) { r.Test(t, r.TestCase{ Providers: testProviders, PreCheck: func() { testAccPreCheck(t) }, Steps: []r.TestStep{ r.TestStep{ Config: testResourceJob_initialConfig, Check: testResourceJob_initialCheck, }, // Change our ID r.TestStep{ Config: testResourceJob_updateConfig, Check: testResourceJob_updateCheck, }, }, }) } var testResourceJob_initialConfig = ` resource "nomad_job" "test" { jobspec = <