package nomad import ( "errors" "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{ { 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{ { Config: testResourceJob_initialConfig, Check: testResourceJob_initialCheck, }, // This should successfully cause the job to be recreated, // testing the Exists function. { 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{ { Config: testResourceJob_noDestroy, Check: testResourceJob_initialCheck, }, // Destroy with our setting set { Destroy: true, Config: testResourceJob_noDestroy, Check: testResourceJob_checkExists, }, // Re-apply without the setting set { 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{ { Config: testResourceJob_initialConfig, Check: testResourceJob_initialCheck, }, // Change our ID { Config: testResourceJob_updateConfig, Check: testResourceJob_updateCheck, }, }, }) } func TestResourceJob_parameterizedJob(t *testing.T) { r.Test(t, r.TestCase{ Providers: testProviders, PreCheck: func() { testAccPreCheck(t) }, Steps: []r.TestStep{ { Config: testResourceJob_parameterizedJob, Check: testResourceJob_initialCheck, }, }, }) } var testResourceJob_initialConfig = ` resource "nomad_job" "test" { jobspec = <