github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/grafana/provider_test.go (about) 1 package grafana 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 a Grafana server. 12 // Grafana can be downloaded here: http://grafana.org/download/ 13 // 14 // The tests will need an API key to authenticate with the server. To create 15 // one, use the menu for one of your installation's organizations (The 16 // "Main Org." is fine if you've just done a fresh installation to run these 17 // tests) to reach the "API Keys" admin page. 18 // 19 // Giving the API key the Admin role is the easiest way to ensure enough 20 // access is granted to run all of the tests. 21 // 22 // Once you've created the API key, set the GRAFANA_URL and GRAFANA_AUTH 23 // environment variables to the Grafana base URL and the API key respectively, 24 // and then run: 25 // make testacc TEST=./builtin/providers/grafana 26 27 var testAccProviders map[string]terraform.ResourceProvider 28 var testAccProvider *schema.Provider 29 30 func init() { 31 testAccProvider = Provider().(*schema.Provider) 32 testAccProviders = map[string]terraform.ResourceProvider{ 33 "grafana": testAccProvider, 34 } 35 } 36 37 func TestProvider(t *testing.T) { 38 if err := Provider().(*schema.Provider).InternalValidate(); err != nil { 39 t.Fatalf("err: %s", err) 40 } 41 } 42 43 func TestProvider_impl(t *testing.T) { 44 var _ terraform.ResourceProvider = Provider() 45 } 46 47 func testAccPreCheck(t *testing.T) { 48 if v := os.Getenv("GRAFANA_URL"); v == "" { 49 t.Fatal("GRAFANA_URL must be set for acceptance tests") 50 } 51 if v := os.Getenv("GRAFANA_AUTH"); v == "" { 52 t.Fatal("GRAFANA_AUTH must be set for acceptance tests") 53 } 54 }