Add one focused unit test.
- Review the repository to find core logic and existing test patterns
- Target a single untested helper or pure function in core logic
- Use existing test tooling and patterns — do not add a new framework
- Keep the change as small as possible
- If there is no test tooling: add only the minimal setup for the primary language, just enough to run that one test
Problem
The helper UnmarshalEmbeddedJSON in pkg/utils/json.go is a small, pure-ish utility (it lazily unmarshals JSON bytes into a map[string]any guarded by a sync.Once) but it currently has no test coverage. Its sibling helper in the same package (NormalizeEmail) already has pkg/utils/email_test.go, so there is a clear, established pattern to follow without introducing anything new.
- The project is Go (
go 1.26.2, module github.com/superplanehq/superplane).
- Existing tests use the standard
testing package plus github.com/stretchr/testify/assert.
pkg/utils/email_test.go demonstrates the table-driven t.Run style used across the repo.
UnmarshalEmbeddedJSON(once *sync.Once, data []byte, target *map[string]any) map[string]any returns the populated map and caches it via once.Do.
Acceptance criteria
- Add a single new test file
pkg/utils/json_test.go in package utils.
- Cover
UnmarshalEmbeddedJSON with a table-driven test using testify/assert, matching the style of email_test.go.
- Verify at least: valid JSON is parsed into the expected map, invalid/empty JSON yields an empty (non-nil) map, and the
sync.Once caches the first result so a second call with different data returns the originally cached value.
- Do not add any new test framework, dependency, or tooling.
- Keep the change limited to the one new test file; do not modify
json.go.
- The test passes via
go test ./pkg/utils/....
Automatically created by the Software Factory
Add one focused unit test.
Problem
The helper
UnmarshalEmbeddedJSONinpkg/utils/json.gois a small, pure-ish utility (it lazily unmarshals JSON bytes into amap[string]anyguarded by async.Once) but it currently has no test coverage. Its sibling helper in the same package (NormalizeEmail) already haspkg/utils/email_test.go, so there is a clear, established pattern to follow without introducing anything new.go 1.26.2, modulegithub.com/superplanehq/superplane).testingpackage plusgithub.com/stretchr/testify/assert.pkg/utils/email_test.godemonstrates the table-drivent.Runstyle used across the repo.UnmarshalEmbeddedJSON(once *sync.Once, data []byte, target *map[string]any) map[string]anyreturns the populated map and caches it viaonce.Do.Acceptance criteria
pkg/utils/json_test.goin packageutils.UnmarshalEmbeddedJSONwith a table-driven test usingtestify/assert, matching the style ofemail_test.go.sync.Oncecaches the first result so a second call with different data returns the originally cached value.json.go.go test ./pkg/utils/....Automatically created by the Software Factory