Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateResourceTestHandlers ¶
func CreateResourceTestHandlers(t *testing.T, config ResourceTestConfig, tracker *APICallTracker) map[string]MockEndpointHandler
CreateResourceTestHandlers creates standard CRUD handlers for testing any dbt Cloud resource
Types ¶
type APICallTracker ¶
APICallTracker tracks API calls made during testing
type CapturedCall ¶
CapturedCall holds the details of a single HTTP request received by the mock server.
type MockEndpointHandler ¶
type MockEndpointHandler func(r *http.Request) (statusCode int, responseBody interface{}, err error)
MockEndpointHandler is a function that inspects a request and dynamically determines the response. If err is non-nil, the server returns a 400 Bad Request with the error message. Otherwise, it returns the specified statusCode and marshals responseBody to JSON.
type MockServer ¶
MockServer is a wrapper around httptest.Server that captures calls.
func SetupMockServer ¶
func SetupMockServer(t *testing.T, handlers map[string]MockEndpointHandler) *MockServer
SetupMockServer creates and starts a new MockServer using dynamic handlers. The handlers map keys should be in the format "METHOD /path", e.g., "POST /users".
func (*MockServer) GetLastCall ¶
func (s *MockServer) GetLastCall(path string) *CapturedCall
GetLastCall returns the most recent call made to a specific path.
type ResourceTestConfig ¶
type ResourceTestConfig struct {
ResourceType string // e.g., "dbtcloud_postgres_credential"
AccountID int
ProjectID int // Optional, only needed for project-scoped resources
ResourceID int // The main resource ID
APIPath string // e.g., "credentials" for /v3/accounts/{account}/projects/{project}/credentials/
}
ResourceTestConfig holds configuration for testing a dbt Cloud resource