github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/builtin/providers/mysql/provider_test.go (about)

     1  package mysql
     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 MySQL server.
    12  // Amazon RDS is one way to get a MySQL server. If you use RDS, you can
    13  // use the root account credentials you specified when creating an RDS
    14  // instance to get the access necessary to run these tests. (the tests
    15  // assume full access to the server.)
    16  //
    17  // Set the MYSQL_ENDPOINT and MYSQL_USERNAME environment variables before
    18  // running the tests. If the given user has a password then you will also need
    19  // to set MYSQL_PASSWORD.
    20  //
    21  // The tests assume a reasonably-vanilla MySQL configuration. In particular,
    22  // they assume that the "utf8" character set is available and that
    23  // "utf8_bin" is a valid collation that isn't the default for that character
    24  // set.
    25  //
    26  // You can run the tests like this:
    27  //    make testacc TEST=./builtin/providers/mysql
    28  
    29  var testAccProviders map[string]terraform.ResourceProvider
    30  var testAccProvider *schema.Provider
    31  
    32  func init() {
    33  	testAccProvider = Provider().(*schema.Provider)
    34  	testAccProviders = map[string]terraform.ResourceProvider{
    35  		"mysql": testAccProvider,
    36  	}
    37  }
    38  
    39  func TestProvider(t *testing.T) {
    40  	if err := Provider().(*schema.Provider).InternalValidate(); err != nil {
    41  		t.Fatalf("err: %s", err)
    42  	}
    43  }
    44  
    45  func TestProvider_impl(t *testing.T) {
    46  	var _ terraform.ResourceProvider = Provider()
    47  }
    48  
    49  func testAccPreCheck(t *testing.T) {
    50  	for _, name := range []string{"MYSQL_ENDPOINT", "MYSQL_USERNAME"} {
    51  		if v := os.Getenv(name); v == "" {
    52  			t.Fatal("MYSQL_ENDPOINT, MYSQL_USERNAME and optionally MYSQL_PASSWORD must be set for acceptance tests")
    53  		}
    54  	}
    55  }