github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/chef/provider_test.go (about) 1 package chef 2 3 import ( 4 "os" 5 "testing" 6 7 "github.com/hashicorp/terraform/helper/schema" 8 "github.com/hashicorp/terraform/terraform" 9 ) 10 11 // To run these acceptance tests, you will need access to a Chef server. 12 // An easy way to get one is to sign up for a hosted Chef server account 13 // at https://manage.chef.io/signup , after which your base URL will 14 // be something like https://api.opscode.com/organizations/example/ . 15 // You will also need to create a "client" and write its private key to 16 // a file somewhere. 17 // 18 // You can then set the following environment variables to make these 19 // tests work: 20 // CHEF_SERVER_URL to the base URL as described above. 21 // CHEF_CLIENT_NAME to the name of the client object you created. 22 // CHEF_KEY_MATERIAL the key file contents. 23 // 24 // You will probably need to edit the global permissions on your Chef 25 // Server account to allow this client (or all clients, if you're lazy) 26 // to have both List and Create access on all types of object: 27 // https://manage.chef.io/organizations/yourorg/global_permissions 28 // 29 // With all of that done, you can run like this: 30 // make testacc TEST=./builtin/providers/chef 31 32 var testAccProviders map[string]terraform.ResourceProvider 33 var testAccProvider *schema.Provider 34 35 func init() { 36 testAccProvider = Provider().(*schema.Provider) 37 testAccProviders = map[string]terraform.ResourceProvider{ 38 "chef": testAccProvider, 39 } 40 } 41 42 func TestProvider(t *testing.T) { 43 if err := Provider().(*schema.Provider).InternalValidate(); err != nil { 44 t.Fatalf("err: %s", err) 45 } 46 } 47 48 func TestProvider_impl(t *testing.T) { 49 var _ terraform.ResourceProvider = Provider() 50 } 51 52 func testAccPreCheck(t *testing.T) { 53 if v := os.Getenv("CHEF_SERVER_URL"); v == "" { 54 t.Fatal("CHEF_SERVER_URL must be set for acceptance tests") 55 } 56 if v := os.Getenv("CHEF_CLIENT_NAME"); v == "" { 57 t.Fatal("CHEF_CLIENT_NAME must be set for acceptance tests") 58 } 59 if v := os.Getenv("CHEF_KEY_MATERIAL"); v == "" { 60 t.Fatal("CHEF_KEY_MATERIAL must be set for acceptance tests") 61 } 62 }