github.com/spirius/terraform@v0.10.0-beta2.0.20170714185654-87b2c0cf8fea/command/state_mv_test.go (about)

     1  package command
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  	"testing"
     7  
     8  	"github.com/hashicorp/terraform/helper/copy"
     9  	"github.com/hashicorp/terraform/terraform"
    10  	"github.com/mitchellh/cli"
    11  )
    12  
    13  func TestStateMv(t *testing.T) {
    14  	state := &terraform.State{
    15  		Modules: []*terraform.ModuleState{
    16  			&terraform.ModuleState{
    17  				Path: []string{"root"},
    18  				Resources: map[string]*terraform.ResourceState{
    19  					"test_instance.foo": &terraform.ResourceState{
    20  						Type: "test_instance",
    21  						Primary: &terraform.InstanceState{
    22  							ID: "bar",
    23  							Attributes: map[string]string{
    24  								"foo": "value",
    25  								"bar": "value",
    26  							},
    27  						},
    28  					},
    29  
    30  					"test_instance.baz": &terraform.ResourceState{
    31  						Type: "test_instance",
    32  						Primary: &terraform.InstanceState{
    33  							ID: "foo",
    34  							Attributes: map[string]string{
    35  								"foo": "value",
    36  								"bar": "value",
    37  							},
    38  						},
    39  					},
    40  				},
    41  			},
    42  		},
    43  	}
    44  
    45  	statePath := testStateFile(t, state)
    46  
    47  	p := testProvider()
    48  	ui := new(cli.MockUi)
    49  	c := &StateMvCommand{
    50  		Meta: Meta{
    51  			testingOverrides: metaOverridesForProvider(p),
    52  			Ui:               ui,
    53  		},
    54  	}
    55  
    56  	args := []string{
    57  		"-state", statePath,
    58  		"test_instance.foo",
    59  		"test_instance.bar",
    60  	}
    61  	if code := c.Run(args); code != 0 {
    62  		t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
    63  	}
    64  
    65  	// Test it is correct
    66  	testStateOutput(t, statePath, testStateMvOutput)
    67  
    68  	// Test we have backups
    69  	backups := testStateBackups(t, filepath.Dir(statePath))
    70  	if len(backups) != 1 {
    71  		t.Fatalf("bad: %#v", backups)
    72  	}
    73  	testStateOutput(t, backups[0], testStateMvOutputOriginal)
    74  }
    75  
    76  // don't modify backend state is we supply a -state flag
    77  func TestStateMv_explicitWithBackend(t *testing.T) {
    78  	td := tempDir(t)
    79  	copy.CopyDir(testFixturePath("init-backend"), td)
    80  	defer os.RemoveAll(td)
    81  	defer testChdir(t, td)()
    82  
    83  	backupPath := filepath.Join(td, "backup")
    84  
    85  	state := &terraform.State{
    86  		Modules: []*terraform.ModuleState{
    87  			&terraform.ModuleState{
    88  				Path: []string{"root"},
    89  				Resources: map[string]*terraform.ResourceState{
    90  					"test_instance.foo": &terraform.ResourceState{
    91  						Type: "test_instance",
    92  						Primary: &terraform.InstanceState{
    93  							ID: "bar",
    94  							Attributes: map[string]string{
    95  								"foo": "value",
    96  								"bar": "value",
    97  							},
    98  						},
    99  					},
   100  
   101  					"test_instance.baz": &terraform.ResourceState{
   102  						Type: "test_instance",
   103  						Primary: &terraform.InstanceState{
   104  							ID: "foo",
   105  							Attributes: map[string]string{
   106  								"foo": "value",
   107  								"bar": "value",
   108  							},
   109  						},
   110  					},
   111  				},
   112  			},
   113  		},
   114  	}
   115  
   116  	statePath := testStateFile(t, state)
   117  
   118  	// init our backend
   119  	ui := new(cli.MockUi)
   120  	ic := &InitCommand{
   121  		Meta: Meta{
   122  			testingOverrides: metaOverridesForProvider(testProvider()),
   123  			Ui:               ui,
   124  		},
   125  	}
   126  
   127  	args := []string{}
   128  	if code := ic.Run(args); code != 0 {
   129  		t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
   130  	}
   131  
   132  	// only modify statePath
   133  	p := testProvider()
   134  	ui = new(cli.MockUi)
   135  	c := &StateMvCommand{
   136  		Meta: Meta{
   137  			testingOverrides: metaOverridesForProvider(p),
   138  			Ui:               ui,
   139  		},
   140  	}
   141  
   142  	args = []string{
   143  		"-backup", backupPath,
   144  		"-state", statePath,
   145  		"test_instance.foo",
   146  		"test_instance.bar",
   147  	}
   148  	if code := c.Run(args); code != 0 {
   149  		t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
   150  	}
   151  
   152  	// Test it is correct
   153  	testStateOutput(t, statePath, testStateMvOutput)
   154  }
   155  
   156  func TestStateMv_backupExplicit(t *testing.T) {
   157  	td := tempDir(t)
   158  	defer os.RemoveAll(td)
   159  	backupPath := filepath.Join(td, "backup")
   160  
   161  	state := &terraform.State{
   162  		Modules: []*terraform.ModuleState{
   163  			&terraform.ModuleState{
   164  				Path: []string{"root"},
   165  				Resources: map[string]*terraform.ResourceState{
   166  					"test_instance.foo": &terraform.ResourceState{
   167  						Type: "test_instance",
   168  						Primary: &terraform.InstanceState{
   169  							ID: "bar",
   170  							Attributes: map[string]string{
   171  								"foo": "value",
   172  								"bar": "value",
   173  							},
   174  						},
   175  					},
   176  
   177  					"test_instance.baz": &terraform.ResourceState{
   178  						Type: "test_instance",
   179  						Primary: &terraform.InstanceState{
   180  							ID: "foo",
   181  							Attributes: map[string]string{
   182  								"foo": "value",
   183  								"bar": "value",
   184  							},
   185  						},
   186  					},
   187  				},
   188  			},
   189  		},
   190  	}
   191  
   192  	statePath := testStateFile(t, state)
   193  
   194  	p := testProvider()
   195  	ui := new(cli.MockUi)
   196  	c := &StateMvCommand{
   197  		Meta: Meta{
   198  			testingOverrides: metaOverridesForProvider(p),
   199  			Ui:               ui,
   200  		},
   201  	}
   202  
   203  	args := []string{
   204  		"-backup", backupPath,
   205  		"-state", statePath,
   206  		"test_instance.foo",
   207  		"test_instance.bar",
   208  	}
   209  	if code := c.Run(args); code != 0 {
   210  		t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
   211  	}
   212  
   213  	// Test it is correct
   214  	testStateOutput(t, statePath, testStateMvOutput)
   215  
   216  	// Test backup
   217  	testStateOutput(t, backupPath, testStateMvOutputOriginal)
   218  }
   219  
   220  func TestStateMv_stateOutNew(t *testing.T) {
   221  	state := &terraform.State{
   222  		Modules: []*terraform.ModuleState{
   223  			&terraform.ModuleState{
   224  				Path: []string{"root"},
   225  				Resources: map[string]*terraform.ResourceState{
   226  					"test_instance.foo": &terraform.ResourceState{
   227  						Type: "test_instance",
   228  						Primary: &terraform.InstanceState{
   229  							ID: "bar",
   230  							Attributes: map[string]string{
   231  								"foo": "value",
   232  								"bar": "value",
   233  							},
   234  						},
   235  					},
   236  				},
   237  			},
   238  		},
   239  	}
   240  
   241  	statePath := testStateFile(t, state)
   242  	stateOutPath := statePath + ".out"
   243  
   244  	p := testProvider()
   245  	ui := new(cli.MockUi)
   246  	c := &StateMvCommand{
   247  		Meta: Meta{
   248  			testingOverrides: metaOverridesForProvider(p),
   249  			Ui:               ui,
   250  		},
   251  	}
   252  
   253  	args := []string{
   254  		"-state", statePath,
   255  		"-state-out", stateOutPath,
   256  		"test_instance.foo",
   257  		"test_instance.bar",
   258  	}
   259  	if code := c.Run(args); code != 0 {
   260  		t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
   261  	}
   262  
   263  	// Test it is correct
   264  	testStateOutput(t, stateOutPath, testStateMvOutput_stateOut)
   265  	testStateOutput(t, statePath, testStateMvOutput_stateOutSrc)
   266  
   267  	// Test we have backups
   268  	backups := testStateBackups(t, filepath.Dir(statePath))
   269  	if len(backups) != 1 {
   270  		t.Fatalf("bad: %#v", backups)
   271  	}
   272  	testStateOutput(t, backups[0], testStateMvOutput_stateOutOriginal)
   273  }
   274  
   275  func TestStateMv_stateOutExisting(t *testing.T) {
   276  	stateSrc := &terraform.State{
   277  		Modules: []*terraform.ModuleState{
   278  			&terraform.ModuleState{
   279  				Path: []string{"root"},
   280  				Resources: map[string]*terraform.ResourceState{
   281  					"test_instance.foo": &terraform.ResourceState{
   282  						Type: "test_instance",
   283  						Primary: &terraform.InstanceState{
   284  							ID: "bar",
   285  							Attributes: map[string]string{
   286  								"foo": "value",
   287  								"bar": "value",
   288  							},
   289  						},
   290  					},
   291  				},
   292  			},
   293  		},
   294  	}
   295  
   296  	statePath := testStateFile(t, stateSrc)
   297  
   298  	stateDst := &terraform.State{
   299  		Modules: []*terraform.ModuleState{
   300  			&terraform.ModuleState{
   301  				Path: []string{"root"},
   302  				Resources: map[string]*terraform.ResourceState{
   303  					"test_instance.qux": &terraform.ResourceState{
   304  						Type: "test_instance",
   305  						Primary: &terraform.InstanceState{
   306  							ID: "bar",
   307  						},
   308  					},
   309  				},
   310  			},
   311  		},
   312  	}
   313  
   314  	stateOutPath := testStateFile(t, stateDst)
   315  
   316  	p := testProvider()
   317  	ui := new(cli.MockUi)
   318  	c := &StateMvCommand{
   319  		Meta: Meta{
   320  			testingOverrides: metaOverridesForProvider(p),
   321  			Ui:               ui,
   322  		},
   323  	}
   324  
   325  	args := []string{
   326  		"-state", statePath,
   327  		"-state-out", stateOutPath,
   328  		"test_instance.foo",
   329  		"test_instance.bar",
   330  	}
   331  	if code := c.Run(args); code != 0 {
   332  		t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
   333  	}
   334  
   335  	// Test it is correct
   336  	testStateOutput(t, stateOutPath, testStateMvExisting_stateDst)
   337  	testStateOutput(t, statePath, testStateMvExisting_stateSrc)
   338  
   339  	// Test we have backups
   340  	backups := testStateBackups(t, filepath.Dir(statePath))
   341  	if len(backups) != 1 {
   342  		t.Fatalf("bad: %#v", backups)
   343  	}
   344  	testStateOutput(t, backups[0], testStateMvExisting_stateSrcOriginal)
   345  
   346  	backups = testStateBackups(t, filepath.Dir(stateOutPath))
   347  	if len(backups) != 1 {
   348  		t.Fatalf("bad: %#v", backups)
   349  	}
   350  	testStateOutput(t, backups[0], testStateMvExisting_stateDstOriginal)
   351  }
   352  
   353  func TestStateMv_noState(t *testing.T) {
   354  	tmp, cwd := testCwd(t)
   355  	defer testFixCwd(t, tmp, cwd)
   356  
   357  	p := testProvider()
   358  	ui := new(cli.MockUi)
   359  	c := &StateMvCommand{
   360  		Meta: Meta{
   361  			testingOverrides: metaOverridesForProvider(p),
   362  			Ui:               ui,
   363  		},
   364  	}
   365  
   366  	args := []string{"from", "to"}
   367  	if code := c.Run(args); code != 1 {
   368  		t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
   369  	}
   370  }
   371  
   372  func TestStateMv_stateOutNew_count(t *testing.T) {
   373  	state := &terraform.State{
   374  		Modules: []*terraform.ModuleState{
   375  			&terraform.ModuleState{
   376  				Path: []string{"root"},
   377  				Resources: map[string]*terraform.ResourceState{
   378  					"test_instance.foo.0": &terraform.ResourceState{
   379  						Type: "test_instance",
   380  						Primary: &terraform.InstanceState{
   381  							ID: "foo",
   382  							Attributes: map[string]string{
   383  								"foo": "value",
   384  								"bar": "value",
   385  							},
   386  						},
   387  					},
   388  
   389  					"test_instance.foo.1": &terraform.ResourceState{
   390  						Type: "test_instance",
   391  						Primary: &terraform.InstanceState{
   392  							ID: "bar",
   393  							Attributes: map[string]string{
   394  								"foo": "value",
   395  								"bar": "value",
   396  							},
   397  						},
   398  					},
   399  
   400  					"test_instance.bar": &terraform.ResourceState{
   401  						Type: "test_instance",
   402  						Primary: &terraform.InstanceState{
   403  							ID: "bar",
   404  							Attributes: map[string]string{
   405  								"foo": "value",
   406  								"bar": "value",
   407  							},
   408  						},
   409  					},
   410  				},
   411  			},
   412  		},
   413  	}
   414  
   415  	statePath := testStateFile(t, state)
   416  	stateOutPath := statePath + ".out"
   417  
   418  	p := testProvider()
   419  	ui := new(cli.MockUi)
   420  	c := &StateMvCommand{
   421  		Meta: Meta{
   422  			testingOverrides: metaOverridesForProvider(p),
   423  			Ui:               ui,
   424  		},
   425  	}
   426  
   427  	args := []string{
   428  		"-state", statePath,
   429  		"-state-out", stateOutPath,
   430  		"test_instance.foo",
   431  		"test_instance.bar",
   432  	}
   433  	if code := c.Run(args); code != 0 {
   434  		t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
   435  	}
   436  
   437  	// Test it is correct
   438  	testStateOutput(t, stateOutPath, testStateMvCount_stateOut)
   439  	testStateOutput(t, statePath, testStateMvCount_stateOutSrc)
   440  
   441  	// Test we have backups
   442  	backups := testStateBackups(t, filepath.Dir(statePath))
   443  	if len(backups) != 1 {
   444  		t.Fatalf("bad: %#v", backups)
   445  	}
   446  	testStateOutput(t, backups[0], testStateMvCount_stateOutOriginal)
   447  }
   448  
   449  // Modules with more than 10 resources were sorted lexically, causing the
   450  // indexes in the new location to change.
   451  func TestStateMv_stateOutNew_largeCount(t *testing.T) {
   452  	state := &terraform.State{
   453  		Modules: []*terraform.ModuleState{
   454  			&terraform.ModuleState{
   455  				Path: []string{"root"},
   456  				Resources: map[string]*terraform.ResourceState{
   457  					"test_instance.foo.0": &terraform.ResourceState{
   458  						Type: "test_instance",
   459  						Primary: &terraform.InstanceState{
   460  							ID: "foo0",
   461  							Attributes: map[string]string{
   462  								"foo": "value",
   463  								"bar": "value",
   464  							},
   465  						},
   466  					},
   467  
   468  					"test_instance.foo.1": &terraform.ResourceState{
   469  						Type: "test_instance",
   470  						Primary: &terraform.InstanceState{
   471  							ID: "foo1",
   472  							Attributes: map[string]string{
   473  								"foo": "value",
   474  								"bar": "value",
   475  							},
   476  						},
   477  					},
   478  
   479  					"test_instance.foo.2": &terraform.ResourceState{
   480  						Type: "test_instance",
   481  						Primary: &terraform.InstanceState{
   482  							ID: "foo2",
   483  							Attributes: map[string]string{
   484  								"foo": "value",
   485  								"bar": "value",
   486  							},
   487  						},
   488  					},
   489  
   490  					"test_instance.foo.3": &terraform.ResourceState{
   491  						Type: "test_instance",
   492  						Primary: &terraform.InstanceState{
   493  							ID: "foo3",
   494  							Attributes: map[string]string{
   495  								"foo": "value",
   496  								"bar": "value",
   497  							},
   498  						},
   499  					},
   500  
   501  					"test_instance.foo.4": &terraform.ResourceState{
   502  						Type: "test_instance",
   503  						Primary: &terraform.InstanceState{
   504  							ID: "foo4",
   505  							Attributes: map[string]string{
   506  								"foo": "value",
   507  								"bar": "value",
   508  							},
   509  						},
   510  					},
   511  
   512  					"test_instance.foo.5": &terraform.ResourceState{
   513  						Type: "test_instance",
   514  						Primary: &terraform.InstanceState{
   515  							ID: "foo5",
   516  							Attributes: map[string]string{
   517  								"foo": "value",
   518  								"bar": "value",
   519  							},
   520  						},
   521  					},
   522  
   523  					"test_instance.foo.6": &terraform.ResourceState{
   524  						Type: "test_instance",
   525  						Primary: &terraform.InstanceState{
   526  							ID: "foo6",
   527  							Attributes: map[string]string{
   528  								"foo": "value",
   529  								"bar": "value",
   530  							},
   531  						},
   532  					},
   533  
   534  					"test_instance.foo.7": &terraform.ResourceState{
   535  						Type: "test_instance",
   536  						Primary: &terraform.InstanceState{
   537  							ID: "foo7",
   538  							Attributes: map[string]string{
   539  								"foo": "value",
   540  								"bar": "value",
   541  							},
   542  						},
   543  					},
   544  
   545  					"test_instance.foo.8": &terraform.ResourceState{
   546  						Type: "test_instance",
   547  						Primary: &terraform.InstanceState{
   548  							ID: "foo8",
   549  							Attributes: map[string]string{
   550  								"foo": "value",
   551  								"bar": "value",
   552  							},
   553  						},
   554  					},
   555  
   556  					"test_instance.foo.9": &terraform.ResourceState{
   557  						Type: "test_instance",
   558  						Primary: &terraform.InstanceState{
   559  							ID: "foo9",
   560  							Attributes: map[string]string{
   561  								"foo": "value",
   562  								"bar": "value",
   563  							},
   564  						},
   565  					},
   566  
   567  					"test_instance.foo.10": &terraform.ResourceState{
   568  						Type: "test_instance",
   569  						Primary: &terraform.InstanceState{
   570  							ID: "foo10",
   571  							Attributes: map[string]string{
   572  								"foo": "value",
   573  								"bar": "value",
   574  							},
   575  						},
   576  					},
   577  
   578  					"test_instance.bar": &terraform.ResourceState{
   579  						Type: "test_instance",
   580  						Primary: &terraform.InstanceState{
   581  							ID: "bar",
   582  							Attributes: map[string]string{
   583  								"foo": "value",
   584  								"bar": "value",
   585  							},
   586  						},
   587  					},
   588  				},
   589  			},
   590  		},
   591  	}
   592  
   593  	statePath := testStateFile(t, state)
   594  	stateOutPath := statePath + ".out"
   595  
   596  	p := testProvider()
   597  	ui := new(cli.MockUi)
   598  	c := &StateMvCommand{
   599  		Meta: Meta{
   600  			testingOverrides: metaOverridesForProvider(p),
   601  			Ui:               ui,
   602  		},
   603  	}
   604  
   605  	args := []string{
   606  		"-state", statePath,
   607  		"-state-out", stateOutPath,
   608  		"test_instance.foo",
   609  		"test_instance.bar",
   610  	}
   611  	if code := c.Run(args); code != 0 {
   612  		t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
   613  	}
   614  
   615  	// Test it is correct
   616  	testStateOutput(t, stateOutPath, testStateMvLargeCount_stateOut)
   617  	testStateOutput(t, statePath, testStateMvLargeCount_stateOutSrc)
   618  
   619  	// Test we have backups
   620  	backups := testStateBackups(t, filepath.Dir(statePath))
   621  	if len(backups) != 1 {
   622  		t.Fatalf("bad: %#v", backups)
   623  	}
   624  	testStateOutput(t, backups[0], testStateMvLargeCount_stateOutOriginal)
   625  }
   626  
   627  func TestStateMv_stateOutNew_nestedModule(t *testing.T) {
   628  	state := &terraform.State{
   629  		Modules: []*terraform.ModuleState{
   630  			&terraform.ModuleState{
   631  				Path:      []string{"root"},
   632  				Resources: map[string]*terraform.ResourceState{},
   633  			},
   634  
   635  			&terraform.ModuleState{
   636  				Path:      []string{"root", "foo"},
   637  				Resources: map[string]*terraform.ResourceState{},
   638  			},
   639  
   640  			&terraform.ModuleState{
   641  				Path: []string{"root", "foo", "child1"},
   642  				Resources: map[string]*terraform.ResourceState{
   643  					"test_instance.foo": &terraform.ResourceState{
   644  						Type: "test_instance",
   645  						Primary: &terraform.InstanceState{
   646  							ID: "bar",
   647  							Attributes: map[string]string{
   648  								"foo": "value",
   649  								"bar": "value",
   650  							},
   651  						},
   652  					},
   653  				},
   654  			},
   655  
   656  			&terraform.ModuleState{
   657  				Path: []string{"root", "foo", "child2"},
   658  				Resources: map[string]*terraform.ResourceState{
   659  					"test_instance.foo": &terraform.ResourceState{
   660  						Type: "test_instance",
   661  						Primary: &terraform.InstanceState{
   662  							ID: "bar",
   663  							Attributes: map[string]string{
   664  								"foo": "value",
   665  								"bar": "value",
   666  							},
   667  						},
   668  					},
   669  				},
   670  			},
   671  		},
   672  	}
   673  
   674  	statePath := testStateFile(t, state)
   675  	stateOutPath := statePath + ".out"
   676  
   677  	p := testProvider()
   678  	ui := new(cli.MockUi)
   679  	c := &StateMvCommand{
   680  		Meta: Meta{
   681  			testingOverrides: metaOverridesForProvider(p),
   682  			Ui:               ui,
   683  		},
   684  	}
   685  
   686  	args := []string{
   687  		"-state", statePath,
   688  		"-state-out", stateOutPath,
   689  		"module.foo",
   690  		"module.bar",
   691  	}
   692  	if code := c.Run(args); code != 0 {
   693  		t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
   694  	}
   695  
   696  	// Test it is correct
   697  	testStateOutput(t, stateOutPath, testStateMvNestedModule_stateOut)
   698  	testStateOutput(t, statePath, testStateMvNestedModule_stateOutSrc)
   699  
   700  	// Test we have backups
   701  	backups := testStateBackups(t, filepath.Dir(statePath))
   702  	if len(backups) != 1 {
   703  		t.Fatalf("bad: %#v", backups)
   704  	}
   705  	testStateOutput(t, backups[0], testStateMvNestedModule_stateOutOriginal)
   706  }
   707  
   708  const testStateMvOutputOriginal = `
   709  test_instance.baz:
   710    ID = foo
   711    bar = value
   712    foo = value
   713  test_instance.foo:
   714    ID = bar
   715    bar = value
   716    foo = value
   717  `
   718  
   719  const testStateMvOutput = `
   720  test_instance.bar:
   721    ID = bar
   722    bar = value
   723    foo = value
   724  test_instance.baz:
   725    ID = foo
   726    bar = value
   727    foo = value
   728  `
   729  
   730  const testStateMvCount_stateOut = `
   731  test_instance.bar.0:
   732    ID = foo
   733    bar = value
   734    foo = value
   735  test_instance.bar.1:
   736    ID = bar
   737    bar = value
   738    foo = value
   739  `
   740  
   741  const testStateMvCount_stateOutSrc = `
   742  test_instance.bar:
   743    ID = bar
   744    bar = value
   745    foo = value
   746  `
   747  
   748  const testStateMvCount_stateOutOriginal = `
   749  test_instance.bar:
   750    ID = bar
   751    bar = value
   752    foo = value
   753  test_instance.foo.0:
   754    ID = foo
   755    bar = value
   756    foo = value
   757  test_instance.foo.1:
   758    ID = bar
   759    bar = value
   760    foo = value
   761  `
   762  
   763  const testStateMvLargeCount_stateOut = `
   764  test_instance.bar.0:
   765    ID = foo0
   766    bar = value
   767    foo = value
   768  test_instance.bar.1:
   769    ID = foo1
   770    bar = value
   771    foo = value
   772  test_instance.bar.2:
   773    ID = foo2
   774    bar = value
   775    foo = value
   776  test_instance.bar.3:
   777    ID = foo3
   778    bar = value
   779    foo = value
   780  test_instance.bar.4:
   781    ID = foo4
   782    bar = value
   783    foo = value
   784  test_instance.bar.5:
   785    ID = foo5
   786    bar = value
   787    foo = value
   788  test_instance.bar.6:
   789    ID = foo6
   790    bar = value
   791    foo = value
   792  test_instance.bar.7:
   793    ID = foo7
   794    bar = value
   795    foo = value
   796  test_instance.bar.8:
   797    ID = foo8
   798    bar = value
   799    foo = value
   800  test_instance.bar.9:
   801    ID = foo9
   802    bar = value
   803    foo = value
   804  test_instance.bar.10:
   805    ID = foo10
   806    bar = value
   807    foo = value
   808  `
   809  
   810  const testStateMvLargeCount_stateOutSrc = `
   811  test_instance.bar:
   812    ID = bar
   813    bar = value
   814    foo = value
   815  `
   816  
   817  const testStateMvLargeCount_stateOutOriginal = `
   818  test_instance.bar:
   819    ID = bar
   820    bar = value
   821    foo = value
   822  test_instance.foo.0:
   823    ID = foo0
   824    bar = value
   825    foo = value
   826  test_instance.foo.1:
   827    ID = foo1
   828    bar = value
   829    foo = value
   830  test_instance.foo.2:
   831    ID = foo2
   832    bar = value
   833    foo = value
   834  test_instance.foo.3:
   835    ID = foo3
   836    bar = value
   837    foo = value
   838  test_instance.foo.4:
   839    ID = foo4
   840    bar = value
   841    foo = value
   842  test_instance.foo.5:
   843    ID = foo5
   844    bar = value
   845    foo = value
   846  test_instance.foo.6:
   847    ID = foo6
   848    bar = value
   849    foo = value
   850  test_instance.foo.7:
   851    ID = foo7
   852    bar = value
   853    foo = value
   854  test_instance.foo.8:
   855    ID = foo8
   856    bar = value
   857    foo = value
   858  test_instance.foo.9:
   859    ID = foo9
   860    bar = value
   861    foo = value
   862  test_instance.foo.10:
   863    ID = foo10
   864    bar = value
   865    foo = value
   866  `
   867  
   868  const testStateMvNestedModule_stateOut = `
   869  <no state>
   870  module.bar:
   871    <no state>
   872  module.bar.child1:
   873    test_instance.foo:
   874      ID = bar
   875      bar = value
   876      foo = value
   877  module.bar.child2:
   878    test_instance.foo:
   879      ID = bar
   880      bar = value
   881      foo = value
   882  `
   883  
   884  const testStateMvNestedModule_stateOutSrc = `
   885  <no state>
   886  `
   887  
   888  const testStateMvNestedModule_stateOutOriginal = `
   889  <no state>
   890  module.foo:
   891    <no state>
   892  module.foo.child1:
   893    test_instance.foo:
   894      ID = bar
   895      bar = value
   896      foo = value
   897  module.foo.child2:
   898    test_instance.foo:
   899      ID = bar
   900      bar = value
   901      foo = value
   902  `
   903  
   904  const testStateMvOutput_stateOut = `
   905  test_instance.bar:
   906    ID = bar
   907    bar = value
   908    foo = value
   909  `
   910  
   911  const testStateMvOutput_stateOutSrc = `
   912  <no state>
   913  `
   914  
   915  const testStateMvOutput_stateOutOriginal = `
   916  test_instance.foo:
   917    ID = bar
   918    bar = value
   919    foo = value
   920  `
   921  
   922  const testStateMvExisting_stateSrc = `
   923  <no state>
   924  `
   925  
   926  const testStateMvExisting_stateDst = `
   927  test_instance.bar:
   928    ID = bar
   929    bar = value
   930    foo = value
   931  test_instance.qux:
   932    ID = bar
   933  `
   934  
   935  const testStateMvExisting_stateSrcOriginal = `
   936  test_instance.foo:
   937    ID = bar
   938    bar = value
   939    foo = value
   940  `
   941  
   942  const testStateMvExisting_stateDstOriginal = `
   943  test_instance.qux:
   944    ID = bar
   945  `