Configurable base URL for mocks
Problem: Test your connector against a mock server without hitting production. Solution: Add a base URL field to your configuration, and give it a default that points at the real API:make generate, the generated configuration struct has a BaseUrl field. Pass it to your client:
Insecure TLS for local testing
Problem: Test against a mock server that uses a self-signed certificate. Solution: Add a bool field, and apply it when you build the HTTP client:--insecure flag lets you test without installing a custom certificate authority.
Unit-test a resource builder
Problem: Verify that a builder lists the right resources, including across pages, without running a full sync. Solution: Call the builder’s methods directly with a fake client, and loop until the page token is empty:require is github.com/stretchr/testify/require. Have the fake client return small pages, so the loop crosses a page boundary. Call Entitlements and Grants the same way, passing the resource under test.
Why: Testing the page loop catches token bugs before they reach a real sync. A V2 builder returns its next token in results.NextPageToken, and nil results mean the same as an empty token.
Use the SDK test helpers
Thepkg/test package has helpers for common checks:
These helpers accept the V1 interfaces,
ResourceSyncerLimited and ResourceProvisionerLimited. A V2 builder doesn’t satisfy them, so for V2 builders write the page loop yourself, as in the previous recipe.Run and inspect with the baton CLI
Problem: Check a connector end to end against a real or mock API. Solution: Run the connector to produce a sync file, then inspect it with thebaton CLI:
baton CLI reads the same file that C1 would receive, so you see what your connector actually produced, including IDs and parent links.