test(model): add unit tests for GetErrorMessage and Flag.MarshalJSON#1981
test(model): add unit tests for GetErrorMessage and Flag.MarshalJSON#1981anxkhn wants to merge 1 commit into
Conversation
core/pkg/model had no tests (0% coverage) despite being imported by 17 packages. Add table-driven tests covering both real functions: - GetErrorMessage: every known code maps to its readable message and an unknown code falls through to "Unknown error code: <code>". - Flag.MarshalJSON: locks in the non-obvious key omission and the json:"-" FlagSetId/Priority fields never serializing, plus the targeting/metadata omitempty behaviour. Test-only; no production change. Brings the package to 100% coverage. Relates to open-feature#1773 Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
❌ Deploy Preview for polite-licorice-3db33c failed. Why did it fail? →
|
✅ Deploy Preview for polite-licorice-3db33c ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds ChangesModel Unit Tests
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
core/pkg/model had no test coverage (0.0%) even though it is imported by 17 packages and holds the core Flag type. This adds table-driven tests for the two functions in the package that have real behaviour:
GetErrorMessage: every known code maps to its readable message, and an unknown code falls through toUnknown error code: <code>.Flag.MarshalJSON: locks in the non-obvious behaviour wherekeyis deliberately omitted from the serialized JSON,FlagSetId/Priority(json:"-") never serialize, andtargeting/metadatahonouromitempty.Test-only, no production change. Brings the package to 100% coverage.
Relates to #1773.
Checklist
make test-core/go test -race -short ./pkg/model/passes (100% cov)make lint(golangci-lint v2.7.2) clean