Files
opentf/internal/tofu/provider_for_test_framework_test.go
Christian Mesh 3c76c5f419 Use the correct data when mocking a resource refresh (#3068)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
Co-authored-by: Diogenes Fernandes <diofeher@gmail.com>
2025-07-25 22:00:43 -03:00

37 lines
926 B
Go

// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package tofu
import (
"strings"
"testing"
"github.com/opentofu/opentofu/internal/providers"
)
func TestProviderForTest_ReadResource(t *testing.T) {
mockProvider := &MockProvider{}
provider, err := newProviderForTestWithSchema(mockProvider, mockProvider.GetProviderSchema(t.Context()))
if err != nil {
t.Fatalf("unexpected error: %s", err.Error())
}
resp := provider.ReadResource(t.Context(), providers.ReadResourceRequest{
TypeName: "test",
Private: []byte{},
})
if !resp.Diagnostics.HasErrors() {
t.Fatalf("expected errors but none were found")
}
errMsg := resp.Diagnostics[0].Description().Summary
if !strings.Contains(errMsg, "Unexpected null value for prior state") {
t.Fatalf("expected prior state not found error but got: %s", errMsg)
}
}