github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/configs/configload/loader_test.go (about)

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