@@ -1552,6 +1552,69 @@ prompts.
15521552
15531553}
15541554
1555+ func TestInit_cloudConfigColorTokensProcessed (t * testing.T ) {
1556+ // This test verifies that when the error
1557+ // diagnostic detail contains color formatting tokens like [bold] and
1558+ // [reset], they are properly processed
1559+ // by the diagnostic formatter and do not appear as literal text in the
1560+ // output.
1561+ td := t .TempDir ()
1562+ testCopyDir (t , testFixturePath ("init-cloud-no-workspaces" ), td )
1563+ t .Chdir (td )
1564+
1565+ ui := cli .NewMockUi ()
1566+ view , done := testView (t )
1567+ c := & InitCommand {
1568+ Meta : Meta {
1569+ Ui : ui ,
1570+ View : view ,
1571+ },
1572+ }
1573+
1574+ args := []string {}
1575+ code := c .Run (args )
1576+ if code == 0 {
1577+ t .Fatalf ("expected error, got success\n %s" , done (t ).Stdout ())
1578+ }
1579+
1580+ gotStderr := done (t ).Stderr ()
1581+
1582+ expected := `
1583+ Error: failed to create backend alias to target "". The hostname is not in the correct format.
1584+
1585+
1586+ Error: Invalid workspaces configuration
1587+
1588+ on main.tf line 7, in terraform:
1589+ 7: cloud {
1590+
1591+ Missing workspace mapping strategy. Either workspace "tags" or "name" is
1592+ required.
1593+
1594+ The 'workspaces' block configures how Terraform CLI maps its workspaces for
1595+ this single
1596+ configuration to workspaces within an HCP Terraform or Terraform Enterprise
1597+ organization. Two strategies are available:
1598+
1599+ tags - A set of tags used to select remote HCP Terraform or Terraform
1600+ Enterprise workspaces to be used for this single
1601+ configuration. New workspaces will automatically be tagged with these tag
1602+ values. Generally, this
1603+ is the primary and recommended strategy to use. This option conflicts with
1604+ "name".
1605+
1606+ name - The name of a single HCP Terraform or Terraform Enterprise workspace
1607+ to be used with this configuration.
1608+ When configured, only the specified workspace can be used. This option
1609+ conflicts with "tags"
1610+ and with the TF_WORKSPACE environment variable.
1611+ `
1612+
1613+ if diff := cmp .Diff (gotStderr , expected ); diff != "" {
1614+ t .Errorf ("unexpected output (-got +expected):\n %s" , diff )
1615+ }
1616+ }
1617+
15551618// make sure inputFalse stops execution on migrate
15561619func TestInit_inputFalse (t * testing.T ) {
15571620 td := t .TempDir ()
0 commit comments