You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: state_test.go
    path of file: ./repos/terraform/internal/states
    
    the code of the file until where you have to start completion: // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

package states

import (
	"fmt"
	"reflect"
	"testing"

	"github.com/go-test/deep"
	"github.com/google/go-cmp/cmp"
	"github.com/zclconf/go-cty/cty"

	"github.com/hashicorp/terraform/internal/addrs"
	"github.com/hashicorp/terraform/internal/lang/marks"
)

func TestState(t *testing.T) {
	// This basic tests exercises the main mutation methods to construct
	// a state. It is not fully comprehensive, so other tests should visit
	// more esoteric codepaths.

	state := NewState()

	rootModule := state.RootModule()
	if rootModule == nil {
		t.Errorf("root module is nil; want valid object")
	}

	state.SetOutputValue(
		addrs.OutputValue{Name: "bar"}.Absolute(addrs.RootModuleInstance),
		cty.StringVal("bar value"), false,
	)
	state.SetOutputValue(
		addrs.OutputValue{Name: "secret"}.Absolute(addrs.RootModuleInstance),
		cty.StringVal("secret value"), true,
	)
	rootModule.SetResourceInstanceCurrent(
		addrs.Resource{
			Mode: addrs.ManagedResourceMode,
			Type: "test_thing",
			Name: "baz",
		}.Instance(addrs.IntKey(0)),
		&ResourceInstanceObjectSrc{
			Status:        ObjectReady,
			SchemaVersion: 1,
			AttrsJSON:     []byte(`{"woozles":"confuzles"}`),
		},
		addrs.AbsProviderConfig{
			Provider: addrs.NewDefaultProvider("test"),
			Module:   addrs.RootModule,
		},
	)

	// State silently ignores attempts to write to non-root outputs, because
	// historically we did track those here but these days we track them in
	// namedvals.State instead, and we're being gracious to existing callers
	// that might not know yet that they need to treat root module output
	// values in a special way.
	childModule := state.EnsureModule(addrs.RootModuleInstance.Child("child", addrs.NoKey))
	state.SetOutputValue(addrs.OutputValue{Name: "pizza"}.Absolute(childModule.Addr), cty.StringVal("hawaiian"), false)
	multiModA := state.EnsureModule(addrs.RootModuleInstance.Child("multi", addrs.StringKey("a")))
	state.SetOutputValue(addrs.OutputValue{Name: "pizza"}.Absolute(multiModA.Addr), cty.StringVal("cheese"), false)
	multiModB := state.EnsureModule(addrs.RootModuleInstance.Child("multi", addrs.StringKey("b")))
	state.SetOutputValue(addrs.OutputValue{Name: "pizza"}.Absolute(multiModB.Addr), cty.StringVal("sausage"), false)

	want := &State{
		RootOutputValues: map[string]*OutputValue{
			"bar": {
				Addr: addrs.AbsOutputValue{
					OutputValue: addrs.OutputValue{
						Name: "bar",
					},
				},
				Value:     cty.StringVal("bar value"),
				Sensitive: false,
			},
			"secret": {
				Addr: addrs.AbsOutputValue{
					OutputValue: addrs.OutputValue{
						Name: "secret",
					},
				},
				Value:     cty.StringVal("secret value"),
				Sensitive: true,
			},
		},

		Modules: map[string]*Module{
			"": {
				Addr: addrs.R
    
func TestState(t *testing.T) {
	// This basic tests exercises the main mutation methods to construct
	// a state. It is not fully comprehensive, so other tests should visit
	// more esoteric codepaths.

	state := NewState()

	rootModule := state.RootModule()
	if rootModule == nil {
		t.Errorf("root module is nil; want valid object")
	}

	state.SetOutputValue(
		addrs.OutputValue{Name: "bar"}.Absolute(addrs.RootModuleInstance),
		cty.StringVal("bar value"), false,
	)
	state.SetOutputValue(
		addrs.OutputValue{Name: "secret"}.Absolute(addrs.RootModuleInstance),
		cty.StringVal("secret value"), true,
	)
	rootModule.SetResourceInstanceCurrent(
		addrs.Resource{
			Mode: addrs.ManagedResourceMode,
			Type: "test_thing",
			Name: "baz",
		}.Instance(addrs.IntKey(0)),
		&ResourceInstanceObjectSrc{
			Status:        ObjectReady,
			SchemaVersion: 1,
			AttrsJSON:     []byte(`{"woozles":"confuzles"}`),
		},
		addrs.AbsProviderConfig{
			Provider: addrs.NewDefaultProvider("test"),
			Module:   addrs.RootModule,
		},
	)

	// State silently ignores attempts to write to non-root outputs, because
	// historically we did track those here but these days we track them in
	// namedvals.State instead, and we're being gracious to existing callers
	// that might not know yet that they need to treat root module output
	// values in a special way.
	childModule := state.EnsureModule(addrs.RootModuleInstance.Child("child", addrs.NoKey))
	state.SetOutputValue(addrs.OutputValue{Name: "pizza"}.Absolute(childModule.Addr), cty.StringVal("hawaiian"), false)
	multiModA := state.EnsureModule(addrs.RootModuleInstance.Child("multi", addrs.StringKey("a")))
	state.SetOutputValue(addrs.OutputValue{Name: "pizza"}.Absolute(multiModA.Addr), cty.StringVal("cheese"), false)
	multiModB := state.EnsureModule(addrs.RootModuleInstance.Child("multi", addrs.StringKey("b")))
	state.SetOutputValue(addrs.OutputValue{Name: "pizza"}.Absolute(multiModB.Addr), cty.StringVal("sausage"), false)

	want := &State{
		RootOutputValues: map[string]*OutputValue{
			"bar": {
				Addr: addrs.AbsOutputValue{
					OutputValue: addrs.OutputValue{
						Name: "bar",
					},
				},
				Value:     cty.StringVal("bar value"),
				Sensitive: false,
			},
			"secret": {
				Addr: addrs.AbsOutputValue{
					OutputValue: addrs.OutputValue{
						Name: "secret",
					},
				},
				Value:     cty.StringVal("secret value"),
				Sensitive: true,
			},
		},

		Modules: map[string]*Module{
			"": {
				Addr: addrs.RootModuleInstance,
				Resources: map[string]*Resource{
					"test_thing.baz": {
						Addr: addrs.Resource{
							Mode: addrs.ManagedResourceMode,
							Type: "test_thing",
							Name: "baz",
						}.Absolute(addrs.RootModuleInstance),

						Instances: map[addrs.InstanceKey]*ResourceInstance{
							addrs.IntKey(0): {
								Current: &ResourceInstanceObjectSrc{
									SchemaVersion: 1,
									Status:        ObjectReady,
									AttrsJSON:     []byte(`{"woozles":"confuzles"}`),
								},
								Deposed: map[DeposedKey]*ResourceInstanceObjectSrc{},
							},
						},
						ProviderConfig: addrs.AbsProviderConfig{
							Provider: addrs.NewDefaultProvider("test"),
							Module:   addrs.RootModule,
						},
					},
				},
			},
			"module.child": {
				Addr:      addrs.RootModuleInstance.Child("child", addrs.NoKey),
				Resources: map[string]*Resource{},
			},
			`module.multi["a"]`: {
				Addr:      addrs.RootModuleInstance.Child("multi", addrs.StringKey("a")),
				Resources: map[string]*Resource{},
			},
			`module.multi["b"]`: {
				Addr:      addrs.RootModuleInstance.Child("multi", addrs.StringKey("b")),
				Resources: map[string]*Resource{},
			},
		},
	}

	{
		// Our structure goes deep, so we need to temporarily override the
		// deep package settings to ensure that we visit the full structure.
		oldDeepDepth := deep.MaxDepth
		oldDeepCompareUnexp := deep.CompareUnexportedFields
		deep.MaxDepth = 50
		deep.CompareUnexportedFields = true
		defer func() {
			deep.MaxDepth = oldDeepDepth
			deep.CompareUnexportedFields = oldDeepCompareUnexp
		}()
	}

	if diff := cmp.Diff(want.String(), state.String()); diff != "" {
		t.Errorf("wrong result\n%s", diff)
	}
}