github.com/databricks/cli@v0.203.0/bundle/deploy/terraform/load_test.go (about)

     1  package terraform
     2  
     3  import (
     4  	"context"
     5  	"os/exec"
     6  	"testing"
     7  
     8  	"github.com/databricks/cli/bundle"
     9  	"github.com/databricks/cli/bundle/config"
    10  	"github.com/stretchr/testify/require"
    11  )
    12  
    13  func TestLoadWithNoState(t *testing.T) {
    14  	_, err := exec.LookPath("terraform")
    15  	if err != nil {
    16  		t.Skipf("cannot find terraform binary: %s", err)
    17  	}
    18  
    19  	b := &bundle.Bundle{
    20  		Config: config.Root{
    21  			Path: t.TempDir(),
    22  			Bundle: config.Bundle{
    23  				Environment: "whatever",
    24  				Terraform: &config.Terraform{
    25  					ExecPath: "terraform",
    26  				},
    27  			},
    28  		},
    29  	}
    30  
    31  	t.Setenv("DATABRICKS_HOST", "https://x")
    32  	t.Setenv("DATABRICKS_TOKEN", "foobar")
    33  	b.WorkspaceClient()
    34  
    35  	err = bundle.Apply(context.Background(), b, bundle.Seq(
    36  		Initialize(),
    37  		Load(),
    38  	))
    39  
    40  	require.ErrorContains(t, err, "Did you forget to run 'databricks bundle deploy'")
    41  }