github.com/opentofu/opentofu@v1.7.1/internal/configs/configload/loader_test.go (about) 1 // Copyright (c) The OpenTofu Authors 2 // SPDX-License-Identifier: MPL-2.0 3 // Copyright (c) 2023 HashiCorp, Inc. 4 // SPDX-License-Identifier: MPL-2.0 5 6 package configload 7 8 import ( 9 "testing" 10 11 "github.com/hashicorp/hcl/v2" 12 "github.com/zclconf/go-cty/cty" 13 ) 14 15 func assertNoDiagnostics(t *testing.T, diags hcl.Diagnostics) bool { 16 t.Helper() 17 return assertDiagnosticCount(t, diags, 0) 18 } 19 20 func assertDiagnosticCount(t *testing.T, diags hcl.Diagnostics, want int) bool { 21 t.Helper() 22 if len(diags) != want { 23 t.Errorf("wrong number of diagnostics %d; want %d", len(diags), want) 24 for _, diag := range diags { 25 t.Logf("- %s", diag) 26 } 27 return true 28 } 29 return false 30 } 31 func assertResultCtyEqual(t *testing.T, got, want cty.Value) bool { 32 t.Helper() 33 if !got.RawEquals(want) { 34 t.Errorf("wrong result\ngot: %#v\nwant: %#v", got, want) 35 return true 36 } 37 return false 38 }