Documentation ¶
Index ¶
- Variables
- func AccTestsEnabled(envVarName string) bool
- func CheckCloudAPITestsEnabled(t *testing.T)
- func CheckCloudInstanceTestsEnabled(t *testing.T)
- func CheckEnterpriseTestsEnabled(t *testing.T, semverConstraintOptional ...string)
- func CheckEnvVarsSet(t *testing.T, envVars ...string)
- func CheckOSSTestsEnabled(t *testing.T, semverConstraintOptional ...string)
- func IsUnitTest(t *testing.T)
- func TestAccExample(t *testing.T, path string) string
- func TestAccExampleWithReplace(t *testing.T, path string, replaceMap map[string]string) string
- func WithoutResource(t *testing.T, tfCode string, resourceNames ...string) string
Constants ¶
This section is empty.
Variables ¶
var ( // ProtoV5ProviderFactories is a static map containing the grafana provider instance // It is used to configure the provider in acceptance tests ProtoV5ProviderFactories = map[string]func() (tfprotov5.ProviderServer, error){ "grafana": func() (tfprotov5.ProviderServer, error) { ctx := context.Background() server, err := provider.MakeProviderServer(ctx, "testacc") if err != nil { return nil, err } schemaResp, err := server.GetProviderSchema(ctx, nil) if err != nil { return nil, fmt.Errorf("failed to get provider schema: %v", err) } fields := map[string]tftypes.Value{} for _, v := range schemaResp.Provider.Block.Attributes { fields[v.Name] = tftypes.NewValue(v.Type, nil) } testValue := tftypes.NewValue(schemaResp.Provider.ValueType(), fields) testDynamicValue, err := tfprotov5.NewDynamicValue(schemaResp.Provider.ValueType(), testValue) if err != nil { return nil, err } configureResp, err := server.ConfigureProvider(context.Background(), &tfprotov5.ConfigureProviderRequest{Config: &testDynamicValue}) if err != nil || len(configureResp.Diagnostics) > 0 { if err == nil { err = fmt.Errorf("provider configuration failed: %v", configureResp.Diagnostics) } return nil, fmt.Errorf("failed to configure provider: %v", err) } return server, nil }, } // Provider is the "main" provider instance // // This Provider can be used in testing code for API calls without requiring // the use of saving and referencing specific ProviderFactories instances. // // It is configured from the main provider package when the test suite is initialized // but it is used in tests of every package Provider *schema.Provider )
Functions ¶
func AccTestsEnabled ¶
func CheckCloudAPITestsEnabled ¶
CheckCloudTestsEnabled checks if the cloud tests are enabled. This should be the first line of any test that tests Cloud API features
func CheckCloudInstanceTestsEnabled ¶
CheckCloudInstanceTestsEnabled checks if tests that run on cloud instances are enabled. This should be the first line of any test that tests Grafana Cloud Pro features
func CheckEnterpriseTestsEnabled ¶
CheckEnterpriseTestsEnabled checks if the enterprise tests are enabled. This should be the first line of any test that tests Grafana Enterprise features
func CheckEnvVarsSet ¶
func CheckOSSTestsEnabled ¶
CheckOSSTestsEnabled checks if the OSS acceptance tests are enabled. This should be the first line of any test that uses Grafana OSS features only
func IsUnitTest ¶
func TestAccExample ¶
TestAccExample returns an example config from the examples directory. Examples are used for both documentation and acceptance tests.
func TestAccExampleWithReplace ¶
TestAccExampleWithReplace works like testAccExample, but replaces strings in the example.
Types ¶
This section is empty.