블로그 Engineering

Fixing a Test That Could Never Pass: Portkey's Terraform Provider

영문 기사. A Portkey Terraform acceptance test compared a workspace slug to a UUID. The merged fix asserts the UUID shape instead, verified against the live API.

GoPortkey-AI/terraform-provider-portkeyTerraformtestingSCIM

Not every bug is in production code. This one was in an acceptance test.

짧은 답변

An acceptance test in Portkey's Terraform provider asserted that a SCIM mapping's workspace_id, which the API returns as a UUID, equals the workspace resource's id, which is a slug. That check could never pass. The fix replaces it with a UUID-shape assertion. It was merged as PR #84 and closed issue #63.

The problem

Issue #63, filed by a maintainer, laid it out. TestAccScimWorkspaceMappingsDataSource_withCreatedMapping failed against the live API:

Attribute 'mappings.0.workspace_id' expected "ws-tf-acc-329a4f", got "d4f92461-0e9b-4c91-9b70-eb2d19c099ed"

The issue called it "a test bug, not a provider bug." The data source correctly reports the API's UUID, while the resource keeps the user's slug. It also noted that CI doesn't run acceptance tests, which is how the check went unnoticed.

The fix

-                   resource.TestCheckResourceAttrPair(
+                   resource.TestMatchResourceAttr(
                        "data.portkey_scim_workspace_mappings.filtered", "mappings.0.workspace_id",
-                       "portkey_workspace.test", "id",
+                       workspaceUUIDPattern,
                    ),

By the numbers

  • Repository: Portkey-AI/terraform-provider-portkey, 8 stars (Nov 3, 2026), Go, MPL-2.0
  • Files changed: 1 (test only)
  • Lines: +5 / -2
  • Commits: 1
  • Opened: Oct 6, 2026. Merged: Oct 12, 2026. Time to merge: 5 days, 15 hours
  • Review: approved and merged by a maintainer, after a live-API test run

How the review went

The maintainer approved with "Correct fix for #63" and posted a local run against the live API, with TestAccScimWorkspaceMappingsDataSource_withCreatedMapping passing. They explained why the new assertion still gives real coverage: "the UUID regex adds that the data source reported the API value instead of echoing the slug it filtered on."

They left two non-blocking nits: add a comment explaining why slug and UUID can't be compared, and inline the package-level regex, since other tests in the package define theirs at the point of use.

FAQ

Did this change the provider's behavior?

No. Only the test file changed.

Where can I read more?

See the pull request and the original issue.

목표

A test that can never pass trains a team to ignore failures. A small, verified correction brings the signal back.

루프 실행

프로덕션 신호를 리뷰된 수정으로 바꾸세요.

무료 체험으로 Prilog가 실제 인시던트를 코드 수준 Pull Request로 연결하는 방식을 확인하세요.