github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/cloud/e2e/migrate_state_tfc_to_other_test.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package main
     5  
     6  import (
     7  	"testing"
     8  )
     9  
    10  func Test_migrate_tfc_to_other(t *testing.T) {
    11  	t.Parallel()
    12  	skipIfMissingEnvVar(t)
    13  
    14  	cases := testCases{
    15  		"migrate from cloud to local backend": {
    16  			operations: []operationSets{
    17  				{
    18  					prep: func(t *testing.T, orgName, dir string) {
    19  						wsName := "new-workspace"
    20  						tfBlock := terraformConfigCloudBackendName(orgName, wsName)
    21  						writeMainTF(t, tfBlock, dir)
    22  					},
    23  					commands: []tfCommand{
    24  						{
    25  							command:           []string{"init"},
    26  							expectedCmdOutput: `Terraform Cloud has been successfully initialized!`,
    27  						},
    28  					},
    29  				},
    30  				{
    31  					prep: func(t *testing.T, orgName, dir string) {
    32  						tfBlock := terraformConfigLocalBackend()
    33  						writeMainTF(t, tfBlock, dir)
    34  					},
    35  					commands: []tfCommand{
    36  						{
    37  							command:           []string{"init"},
    38  							expectedCmdOutput: `Migrating state from Terraform Cloud to another backend is not yet implemented.`,
    39  							expectError:       true,
    40  						},
    41  					},
    42  				},
    43  			},
    44  		},
    45  	}
    46  
    47  	testRunner(t, cases, 1)
    48  }