diff --git a/statecheck/expect_known_output_value.go b/statecheck/expect_known_output_value.go index 1cf6b69e8..64c47f819 100644 --- a/statecheck/expect_known_output_value.go +++ b/statecheck/expect_known_output_value.go @@ -56,7 +56,7 @@ func (e expectKnownOutputValue) CheckState(ctx context.Context, req CheckStateRe } if err := e.knownValue.CheckValue(result); err != nil { - resp.Error = err + resp.Error = fmt.Errorf("error checking value for output at path: %s, err: %s", e.outputAddress, err) return } diff --git a/statecheck/expect_known_output_value_at_path.go b/statecheck/expect_known_output_value_at_path.go index 7ff704b06..9fb8cc4f1 100644 --- a/statecheck/expect_known_output_value_at_path.go +++ b/statecheck/expect_known_output_value_at_path.go @@ -57,7 +57,7 @@ func (e expectKnownOutputValueAtPath) CheckState(ctx context.Context, req CheckS } if err := e.knownValue.CheckValue(result); err != nil { - resp.Error = err + resp.Error = fmt.Errorf("error checking value for output at path: %s.%s, err: %s", e.outputAddress, e.outputPath.String(), err) return } diff --git a/statecheck/expect_known_output_value_at_path_test.go b/statecheck/expect_known_output_value_at_path_test.go index 018deb31b..078daee04 100644 --- a/statecheck/expect_known_output_value_at_path_test.go +++ b/statecheck/expect_known_output_value_at_path_test.go @@ -1442,14 +1442,16 @@ func TestExpectKnownOutputValueAtPath_CheckState_UnknownAttributeType(t *testing State: &tfjson.State{ Values: &tfjson.StateValues{ Outputs: map[string]*tfjson.StateOutput{ - "float32_output": { - Value: float32(123), + "obj": { + Value: map[string]any{ + "float32_output": float32(123), + }, }, }, }, }, }, - expectedErr: fmt.Errorf("expected json.Number value for Int64Exact check, got: float32"), + expectedErr: fmt.Errorf("error checking value for output at path: obj.float32_output, err: expected json.Number value for Int64Exact check, got: float32"), }, } @@ -1459,7 +1461,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_UnknownAttributeType(t *testing t.Run(name, func(t *testing.T) { t.Parallel() - e := statecheck.ExpectKnownOutputValueAtPath("float32_output", tfjsonpath.Path{}, testCase.knownValue) + e := statecheck.ExpectKnownOutputValueAtPath("obj", tfjsonpath.New("float32_output"), testCase.knownValue) resp := statecheck.CheckStateResponse{} diff --git a/statecheck/expect_known_output_value_test.go b/statecheck/expect_known_output_value_test.go index 612891f74..b3f5e2ccf 100644 --- a/statecheck/expect_known_output_value_test.go +++ b/statecheck/expect_known_output_value_test.go @@ -1412,7 +1412,7 @@ func TestExpectKnownOutputValue_CheckState_UnknownAttributeType(t *testing.T) { }, }, }, - expectedErr: fmt.Errorf("expected json.Number value for Int64Exact check, got: float32"), + expectedErr: fmt.Errorf("error checking value for output at path: float32_output, err: expected json.Number value for Int64Exact check, got: float32"), }, } diff --git a/statecheck/expect_known_value.go b/statecheck/expect_known_value.go index 096699cba..96662c32a 100644 --- a/statecheck/expect_known_value.go +++ b/statecheck/expect_known_value.go @@ -61,7 +61,7 @@ func (e expectKnownValue) CheckState(ctx context.Context, req CheckStateRequest, } if err := e.knownValue.CheckValue(result); err != nil { - resp.Error = err + resp.Error = fmt.Errorf("error checking value for attribute at path: %s.%s, err: %s", e.resourceAddress, e.attributePath.String(), err) } } diff --git a/statecheck/expect_known_value_test.go b/statecheck/expect_known_value_test.go index e275212de..9625ec089 100644 --- a/statecheck/expect_known_value_test.go +++ b/statecheck/expect_known_value_test.go @@ -1294,7 +1294,7 @@ func TestExpectKnownValue_CheckState_UnknownAttributeType(t *testing.T) { }, }, }, - expectedErr: fmt.Errorf("expected json.Number value for Int64Exact check, got: float32"), + expectedErr: fmt.Errorf("error checking value for attribute at path: example_resource.test.attribute, err: expected json.Number value for Int64Exact check, got: float32"), }, }