terraform/builtin/providers/nomad/provider_test.go

45 lines
1.1 KiB
Go

package nomad
import (
"os"
"testing"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)
// How to run the acceptance tests for this provider:
//
// - Obtain an official Nomad release from https://nomadproject.io
// and extract the "nomad" binary
//
// - Run the following to start the Nomad agent in development mode:
// nomad agent -dev
//
// - Run the Terraform acceptance tests as usual:
// make testacc TEST=./builtin/providers/nomad
//
// The tests expect to be run in a fresh, empty Nomad server.
func TestProvider(t *testing.T) {
if err := Provider().(*schema.Provider).InternalValidate(); err != nil {
t.Fatalf("err: %s", err)
}
}
var testProvider *schema.Provider
var testProviders map[string]terraform.ResourceProvider
func init() {
testProvider = Provider().(*schema.Provider)
testProviders = map[string]terraform.ResourceProvider{
"nomad": testProvider,
}
}
func testAccPreCheck(t *testing.T) {
if v := os.Getenv("NOMAD_ADDR"); v == "" {
os.Setenv("NOMAD_ADDR", "http://127.0.0.1:4646")
}
}