Created
May 2, 2020 22:17
-
-
Save dcaponi/7d4fa1bc202997595ca0080adafd7aa7 to your computer and use it in GitHub Desktop.
tf provider test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package onelogin | |
import ( | |
"errors" | |
"os" | |
"testing" | |
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" | |
"github.com/hashicorp/terraform-plugin-sdk/terraform" | |
) | |
var testAccProviders map[string]terraform.ResourceProvider | |
var testAccProvider *schema.Provider | |
func init() { | |
testAccProvider = Provider().(*schema.Provider) | |
testAccProviders = map[string]terraform.ResourceProvider{ | |
"onelogin": testAccProvider, | |
} | |
} | |
// TestProvider checks the validity of a provider and stops further testing | |
// if a problem is found | |
func TestProvider(t *testing.T) { | |
if err := Provider().(*schema.Provider).InternalValidate(); err != nil { | |
t.Fatalf("err: %s", err) | |
} | |
} | |
// TestAccPreCheck performs a check to ensure requisite credentials are in | |
// the environment and stops further testing if a problem is found | |
func TestAccPreCheck(t *testing.T) { | |
err := accPreCheck() | |
if err != nil { | |
t.Fatalf("%v", err) | |
} | |
} | |
func accPreCheck() error { | |
if v := os.Getenv("ONELOGIN_OAPI_URL"); v == "" { | |
return errors.New("ONELOGIN_OAPI_URL must be set for acceptance tests") | |
} | |
if v := os.Getenv("ONELOGIN_CLIENT_ID"); v == "" { | |
return errors.New("ONELOGIN_CLIENT_ID must be set for acceptance tests") | |
} | |
if v := os.Getenv("ONELOGIN_CLIENT_SECRET"); v == "" { | |
return errors.New("ONELOGIN_CLIENT_SECRET must be set for acceptance tests") | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment