Skip to content

hujson: fix Patch test operation for null values - #51

Closed
RaphaelFakhri wants to merge 1 commit into
tailscale:masterfrom
RaphaelFakhri:fix/patch-test-null
Closed

RaphaelFakhri wants to merge 1 commit into
tailscale:masterfrom
RaphaelFakhri:fix/patch-test-null

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Description

The test operation of Value.Patch always failed for a null value. equalValue used a nil interface both for a decoded JSON null and for an unmarshal error, so two nulls never compared equal.

This change tracks unmarshal success separately from the decoded value.

Testing

Two cases are added to TestPatch: a test of null against null succeeds, and a test of 0 against null still fails.

go test -run TestPatch .

Before the change, one subtest fails. After the change, all 59 subtests pass.

Fixes #50

equalValue treated a decoded JSON null as a failed unmarshal, so a
"test" operation against a null value always reported a difference.
Track unmarshal success separately from the decoded value.

Fixes #50

Signed-off-by: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Value.Patch: "test" operation always fails for a null value

1 participant