From e4d4902839a6827650ab3a2abf349c2ef2ceffb9 Mon Sep 17 00:00:00 2001 From: Igor Lazarev Date: Wed, 23 Sep 2026 08:13:43 +0000 Subject: [PATCH 1/2] breaking(assertjson): remove deprecated APIs and JSON Pointer paths Drop legacy AssertNode helpers, Nodef/Atf, and single-string JSON Pointer navigation in favor of fluent chains and path elements. Co-authored-by: Cursor --- CHANGELOG.md | 4 ++ EXAMPLES.md | 14 +++--- README.md | 8 ++-- assertjson/array.go | 8 ---- assertjson/assertjson.go | 60 +----------------------- assertjson/assertjson_test.go | 87 ++++++----------------------------- assertjson/identifiers.go | 28 ----------- assertjson/numeric.go | 57 ----------------------- assertjson/object.go | 8 ---- assertjson/string.go | 32 ------------- 10 files changed, 29 insertions(+), 277 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d79783..0d00b6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,10 @@ this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Removed - Direct dependency on `github.com/golang-jwt/jwt/v5`. +- Deprecated `assertjson` APIs: legacy `AssertNode` helpers (`EqualToTheString`, + `IsNumberGreaterThan`, and similar), `Nodef` / `Atf`, UUID chain aliases + (`Nil`, `Version`, …), and JSON Pointer strings passed as a single path + argument to `Node` / `At`. ## [0.11.0] - 2026-02-07 diff --git a/EXAMPLES.md b/EXAMPLES.md index 7a40e04..0e90efb 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -272,22 +272,22 @@ assertjson.IsJWT(t, rawJWTString, keyFunc).WithPayload(func(json *assertjson.Ass ```go // Пакетная функция (аналог Has для одного JSON) assertjson.LinesHas(t, body, func(lines *assertjson.AssertJSONLines) { - lines.At(0).Node("id").EqualToTheInteger(1) - lines.At(0).Node("name").EqualToTheString("Alice") - lines.At(1).Node("id").EqualToTheInteger(2) - lines.At(1).Node("role").EqualToTheString("admin") + lines.At(0).Node("id").IsInteger().EqualTo(1) + lines.At(0).Node("name").IsString().EqualTo("Alice") + lines.At(1).Node("id").IsInteger().EqualTo(2) + lines.At(1).Node("role").IsString().EqualTo("admin") lines.WithLength(2) }) // Метод на результате Lines assertjson.Lines(t, body).Has(func(lines *assertjson.AssertJSONLines) { - lines.At(0).Node("event").EqualToTheString("created") - lines.At(1).Node("event").EqualToTheString("updated") + lines.At(0).Node("event").IsString().EqualTo("created") + lines.At(1).Node("event").IsString().EqualTo("updated") }) // Файл assertjson.FileLinesHas(t, "events.ndjson", func(lines *assertjson.AssertJSONLines) { - lines.At(0).Node("event").EqualToTheString("created") + lines.At(0).Node("event").IsString().EqualTo("created") }) ``` diff --git a/README.md b/README.md index edd0737..7df6ee5 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ func TestYourAPI(t *testing.T) { ## `assertjson` package -The `assertjson` package provides fluent assertions for JSON values. Nodes are selected via [JSON Pointer](https://tools.ietf.org/html/rfc6901) or path elements. Supports strings, numbers, arrays, objects, UUID, email, URL, time, and JWT. +The `assertjson` package provides fluent assertions for JSON values. Nodes are selected by path elements passed to `Node` and `At`. Supports strings, numbers, arrays, objects, UUID, email, URL, time, and JWT. ### Example @@ -105,9 +105,9 @@ func TestYourAPI(t *testing.T) { ```go assertjson.LinesHas(t, body, func(lines *assertjson.AssertJSONLines) { - lines.At(0).Node("id").EqualToTheInteger(1) - lines.At(0).Node("name").EqualToTheString("Alice") - lines.At(1).Node("role").EqualToTheString("admin") + lines.At(0).Node("id").IsInteger().EqualTo(1) + lines.At(0).Node("name").IsString().EqualTo("Alice") + lines.At(1).Node("role").IsString().EqualTo("admin") lines.WithLength(2) }) ``` diff --git a/assertjson/array.go b/assertjson/array.go index 0f6dfb4..3e4a647 100644 --- a/assertjson/array.go +++ b/assertjson/array.go @@ -9,14 +9,6 @@ import ( "github.com/stretchr/testify/assert" ) -// IsArrayWithElementsCount asserts that the JSON node is an array with given elements count. -// -// Deprecated: use IsArray().WithLength() instead. -func (node *AssertNode) IsArrayWithElementsCount(count int, msgAndArgs ...interface{}) { - node.t.Helper() - node.IsArray().WithLength(count, msgAndArgs...) -} - // IsArray asserts that the JSON node is an array. // It returns ArrayAssertion to execute a chain of assertions for the node value. func (node *AssertNode) IsArray(msgAndArgs ...interface{}) *ArrayAssertion { diff --git a/assertjson/assertjson.go b/assertjson/assertjson.go index 06e5bc0..90c0544 100644 --- a/assertjson/assertjson.go +++ b/assertjson/assertjson.go @@ -1,13 +1,11 @@ // Package assertjson provides methods for testing JSON values. -// Selecting JSON values provided by JSON Pointer Syntax (https://tools.ietf.org/html/rfc6901). +// Nodes are selected by path elements passed to Node and At. package assertjson import ( "encoding/json" "fmt" "os" - "strconv" - "strings" jsoniter "github.com/json-iterator/go" "github.com/muonsoft/api-testing/internal/js" @@ -78,15 +76,6 @@ func (j *AssertJSON) Node(path ...interface{}) *AssertNode { return node } -// Nodef searches for JSON node by JSON Path Syntax. Returns struct for asserting the node values. -// It calculates path by applying fmt.Sprintf function. -// -// Deprecated: use Node() with multiple arguments. -func (j *AssertJSON) Nodef(format string, a ...interface{}) *AssertNode { - j.t.Helper() - return j.Node(fmt.Sprintf(format, a...)) -} - // At is used to test assertions on some node in a batch. It returns AssertJSON object on that node. func (j *AssertJSON) At(path ...interface{}) *AssertJSON { j.t.Helper() @@ -107,15 +96,6 @@ func (j *AssertJSON) At(path ...interface{}) *AssertJSON { return a } -// Atf is used to test assertions on some node in a batch. It returns AssertJSON object on that node. -// It calculates path by applying fmt.Sprintf function. -// -// Deprecated: use At() with multiple arguments. -func (j *AssertJSON) Atf(format string, a ...interface{}) *AssertJSON { - j.t.Helper() - return j.At(fmt.Sprintf(format, a...)) -} - func (j *AssertJSON) assert(data []byte, jsonAssert JSONAssertFunc) { j.t.Helper() err := json.Unmarshal(data, &j.data) @@ -132,11 +112,6 @@ func (j *AssertJSON) fail(message string, msgAndArgs ...interface{}) { } func preprocessPath(path []interface{}) []interface{} { - // deprecated behaviour: should be removed - if jsonpath, ok := isJSONPointer(path); ok { - path = pathFromJSONPointer(jsonpath) - } - for i := range path { if s, ok := path[i].(fmt.Stringer); ok { path[i] = s.String() @@ -146,33 +121,6 @@ func preprocessPath(path []interface{}) []interface{} { return path } -func isJSONPointer(path []interface{}) (string, bool) { - if len(path) != 1 { - return "", false - } - if jsonpath, ok := path[0].(string); ok && (strings.HasPrefix(jsonpath, "/") || jsonpath == "") { - return jsonpath, true - } - - return "", false -} - -// Deprecated: should be removed in future versions. -func pathFromJSONPointer(p string) []interface{} { - elements := strings.Split(p, "/") - path := make([]interface{}, 0, len(elements)-1) - - for i := 1; i < len(elements); i++ { - if index, err := strconv.Atoi(elements[i]); err == nil { - path = append(path, index) - } else { - path = append(path, decodeReferenceToken(elements[i])) - } - } - - return path -} - func getValueByPath(data interface{}, path ...interface{}) (interface{}, error) { v := jsoniter.Wrap(data) for _, e := range path { @@ -190,9 +138,3 @@ func getValueByPath(data interface{}, path ...interface{}) (interface{}, error) return v.GetInterface(), nil } - -func decodeReferenceToken(token string) string { - step1 := strings.ReplaceAll(token, `~1`, `/`) - step2 := strings.ReplaceAll(step1, `~0`, `~`) - return step2 -} diff --git a/assertjson/assertjson_test.go b/assertjson/assertjson_test.go index 183df40..c4878ec 100644 --- a/assertjson/assertjson_test.go +++ b/assertjson/assertjson_test.go @@ -26,18 +26,10 @@ func TestFileHas(t *testing.T) { json.Node("objectNode").EqualJSON(`{"objectKey": "objectValue"}`) // string assertions - json.Node("stringNode").IsString() - json.Node("stringNode").EqualToTheString("stringValue") - json.Node("stringNode").AssertString(func(tb testing.TB, value string) { - tb.Helper() - assert.Equal(tb, "stringValue", value) - }) json.Node("stringNode").Matches("^string.*$") json.Node("stringNode").DoesNotMatch("^notMatch$") json.Node("stringNode").Contains("string") json.Node("stringNode").DoesNotContain("notContain") - json.Node("stringNode").IsStringWithLength(11) - json.Node("stringNode").IsStringWithLengthInRange(11, 11) // fluent string assertions json.Node("stringNode").IsString() @@ -76,12 +68,6 @@ func TestFileHas(t *testing.T) { json.Node("integerNode").IsInteger().GreaterThanOrEqual(123) json.Node("integerNode").IsInteger().LessThan(124) json.Node("integerNode").IsInteger().LessThanOrEqual(123) - json.Node("integerNode").EqualToTheInteger(123) - json.Node("integerNode").IsNumberInRange(122, 124) - json.Node("integerNode").IsNumberGreaterThan(122) - json.Node("integerNode").IsNumberGreaterThanOrEqual(123) - json.Node("integerNode").IsNumberLessThan(124) - json.Node("integerNode").IsNumberLessThanOrEqual(123) json.Node("floatNode").IsFloat() json.Node("floatNode").IsNumber() json.Node("zeroFloat").IsNumber().IsZero() @@ -94,12 +80,6 @@ func TestFileHas(t *testing.T) { json.Node("floatNode").IsNumber().LessThan(124) json.Node("floatNode").IsNumber().LessThanOrEqual(123.123) json.Node("floatNode").IsNumber().GreaterThanOrEqual(122).LessThanOrEqual(124) - json.Node("floatNode").EqualToTheFloat(123.123) - json.Node("floatNode").IsNumberInRange(122, 124) - json.Node("floatNode").IsNumberGreaterThan(122) - json.Node("floatNode").IsNumberGreaterThanOrEqual(123.123) - json.Node("floatNode").IsNumberLessThan(124) - json.Node("floatNode").IsNumberLessThanOrEqual(123.123) // string values assertions json.Node("uuid").IsString().WithUUID() @@ -152,7 +132,6 @@ func TestFileHas(t *testing.T) { isJWT.WithIssuedAt().BeforeDate(2022, time.October, 27) // array assertions - json.Node("arrayNode").IsArrayWithElementsCount(1) json.Node("arrayNode").IsArray() json.Node("arrayNode").IsArray().WithLength(1) json.Node("arrayNode").IsArray().WithLengthGreaterThan(0) @@ -187,7 +166,6 @@ func TestFileHas(t *testing.T) { assert.Equal(t, 1, json.Node("arrayNode").IsStrings().Length()) // object assertions - json.Node("objectNode").IsObjectWithPropertiesCount(1) json.Node("objectNode").IsObject() json.Node("objectNode").IsObject().WithPropertiesCount(1) json.Node("objectNode").IsObject().WithPropertiesCountGreaterThan(0) @@ -1808,14 +1786,14 @@ func TestHas(t *testing.T) { name: "JSON node is nil UUID", json: `{"key": "00000000-0000-0000-0000-000000000000"}`, assert: func(json *assertjson.AssertJSON) { - json.Node("key").IsUUID().Nil() + json.Node("key").IsUUID().IsNil() }, }, { name: "JSON node is nil UUID fails", json: `{"key": "bf0d10a1-d74c-436a-9db1-77c23b5e464f"}`, assert: func(json *assertjson.AssertJSON) { - json.Node("key").IsUUID().Nil() + json.Node("key").IsUUID().IsNil() }, wantMessages: []string{ `failed asserting that JSON node "key": is nil UUID, actual is "bf0d10a1-d74c-436a-9db1-77c23b5e464f"`, @@ -1825,14 +1803,14 @@ func TestHas(t *testing.T) { name: "JSON node is not nil UUID", json: `{"key": "bf0d10a1-d74c-436a-9db1-77c23b5e464f"}`, assert: func(json *assertjson.AssertJSON) { - json.Node("key").IsUUID().NotNil() + json.Node("key").IsUUID().IsNotNil() }, }, { name: "JSON node is not nil UUID fails", json: `{"key": "00000000-0000-0000-0000-000000000000"}`, assert: func(json *assertjson.AssertJSON) { - json.Node("key").IsUUID().NotNil() + json.Node("key").IsUUID().IsNotNil() }, wantMessages: []string{ `failed asserting that JSON node "key": is not nil UUID, actual is "00000000-0000-0000-0000-000000000000"`, @@ -1842,14 +1820,14 @@ func TestHas(t *testing.T) { name: "JSON node is UUID v4", json: `{"key": "bf0d10a1-d74c-436a-9db1-77c23b5e464f"}`, assert: func(json *assertjson.AssertJSON) { - json.Node("key").IsUUID().Version(4) + json.Node("key").IsUUID().OfVersion(4) }, }, { name: "JSON node is UUID v4 fails", json: `{"key": "00000000-0000-0000-0000-000000000000"}`, assert: func(json *assertjson.AssertJSON) { - json.Node("key").IsUUID().Version(4) + json.Node("key").IsUUID().OfVersion(4) }, wantMessages: []string{ `failed asserting that JSON node "key": is UUID of version 4, actual is 0`, @@ -1859,14 +1837,14 @@ func TestHas(t *testing.T) { name: "JSON node is UUID variant 1", json: `{"key": "a67e4bfc-1039-11ed-861d-0242ac120002"}`, assert: func(json *assertjson.AssertJSON) { - json.Node("key").IsUUID().Variant(1) + json.Node("key").IsUUID().OfVariant(1) }, }, { name: "JSON node is UUID variant 1 fails", json: `{"key": "00000000-0000-0000-0000-000000000000"}`, assert: func(json *assertjson.AssertJSON) { - json.Node("key").IsUUID().Variant(1) + json.Node("key").IsUUID().OfVariant(1) }, wantMessages: []string{ `failed asserting that JSON node "key": is UUID of variant 1, actual is 0`, @@ -1912,10 +1890,10 @@ func TestHas(t *testing.T) { assert: func(json *assertjson.AssertJSON) { json.Node("key"). IsUUID(). - Nil(). - NotNil(). - Version(0). - Variant(0). + IsNil(). + IsNotNil(). + OfVersion(0). + OfVariant(0). EqualTo(uuid.Nil). NotEqualTo(uuid.FromStringOrNil("bf0d10a1-d74c-436a-9db1-77c23b5e464f")). Value() @@ -2450,7 +2428,7 @@ func TestHas(t *testing.T) { json: `{"key": "{\"key\": \"00000000-0000-0000-0000-000000000000\"}"}`, assert: func(json *assertjson.AssertJSON) { json.Node("key").IsString().WithJSON(func(json *assertjson.AssertJSON) { - json.Node("key").IsUUID().NotNil() + json.Node("key").IsUUID().IsNotNil() }) }, wantMessages: []string{ @@ -3019,45 +2997,6 @@ func TestHas(t *testing.T) { `failed to find JSON node "a.b": [b] not found`, }, }, - // deprecated behaviour: seek by json pointer path - { - name: "deprecated: json pointer path", - json: `"value"`, - assert: func(json *assertjson.AssertJSON) { - json.Node("").IsString().EqualTo("value") - }, - }, - { - name: "deprecated: json pointer path", - json: `{"a": {"b": {"c": "value"}}}`, - assert: func(json *assertjson.AssertJSON) { - json.Node("/a/b/c").IsString().EqualTo("value") - }, - }, - { - name: "deprecated: json pointer path", - json: `{"a": {"b": {"c": ["value"]}}}`, - assert: func(json *assertjson.AssertJSON) { - json.Node("/a/b/c/0").IsString().EqualTo("value") - }, - }, - { - name: "deprecated: json pointer path", - json: `{"a": {"/b": {"~c": ["value"]}}}`, - assert: func(json *assertjson.AssertJSON) { - json.Node("/a/~1b/~0c/0").IsString().EqualTo("value") - }, - }, - { - name: "deprecated: json pointer path", - json: `{"a": {"b": {"c": ["value"]}}}`, - assert: func(json *assertjson.AssertJSON) { - json.Node("/a/b/c/1").IsString() - }, - wantMessages: []string{ - `failed to find JSON node "a.b.c[1]": [1] not found`, - }, - }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { diff --git a/assertjson/identifiers.go b/assertjson/identifiers.go index 774cb6a..b3214f2 100644 --- a/assertjson/identifiers.go +++ b/assertjson/identifiers.go @@ -156,34 +156,6 @@ func (node *AssertNode) UUID() uuid.UUID { return node.IsUUID().Value() } -// Nil asserts that the JSON node has a string value equals to nil UUID. -// -// Deprecated: use IsNil(). -func (a *UUIDAssertion) Nil(msgAndArgs ...interface{}) *UUIDAssertion { - return a.IsNil(msgAndArgs...) -} - -// NotNil asserts that the JSON node has a string value equals to not nil UUID. -// -// Deprecated: use IsNotNil(). -func (a *UUIDAssertion) NotNil(msgAndArgs ...interface{}) *UUIDAssertion { - return a.IsNotNil(msgAndArgs...) -} - -// Version asserts that the JSON node has a string value equals to UUID with the given version. -// -// Deprecated: use OfVersion(). -func (a *UUIDAssertion) Version(version byte, msgAndArgs ...interface{}) *UUIDAssertion { - return a.OfVersion(version, msgAndArgs...) -} - -// Variant asserts that the JSON node has a string value equals to UUID with the given variant. -// -// Deprecated: use OfVariant(). -func (a *UUIDAssertion) Variant(variant byte, msgAndArgs ...interface{}) *UUIDAssertion { - return a.OfVariant(variant, msgAndArgs...) -} - func (a *UUIDAssertion) fail(message string, msgAndArgs ...interface{}) { a.t.Helper() assert.Fail(a.t, a.message+message, msgAndArgs...) diff --git a/assertjson/numeric.go b/assertjson/numeric.go index 9e654ac..c12b493 100644 --- a/assertjson/numeric.go +++ b/assertjson/numeric.go @@ -68,63 +68,6 @@ func (node *AssertNode) IsNumber(msgAndArgs ...interface{}) *NumberAssertion { return nil } -// EqualToTheInteger asserts that the JSON node has an integer value equals to the given value. -// -// Deprecated: use IsInteger() instead. -func (node *AssertNode) EqualToTheInteger(expectedValue int, msgAndArgs ...interface{}) { - node.t.Helper() - node.IsInteger().EqualTo(expectedValue, msgAndArgs...) -} - -// EqualToTheFloat asserts that the JSON node has a float value equals to the given value. -// -// Deprecated: use IsNumber() instead. -func (node *AssertNode) EqualToTheFloat(expectedValue float64, msgAndArgs ...interface{}) { - node.t.Helper() - node.IsNumber().EqualTo(expectedValue, msgAndArgs...) -} - -// IsNumberGreaterThan asserts that the JSON node has a number greater than the given value. -// -// Deprecated: use IsNumber().GreaterThan() instead. -func (node *AssertNode) IsNumberGreaterThan(value float64, msgAndArgs ...interface{}) { - node.t.Helper() - node.IsNumber().GreaterThan(value, msgAndArgs...) -} - -// IsNumberGreaterThanOrEqual asserts that the JSON node has a number greater than or equal to the given value. -// -// Deprecated: use IsNumber().GreaterThanOrEqual() instead. -func (node *AssertNode) IsNumberGreaterThanOrEqual(value float64, msgAndArgs ...interface{}) { - node.t.Helper() - node.IsNumber().GreaterThanOrEqual(value, msgAndArgs...) -} - -// IsNumberLessThan asserts that the JSON node has a number less than the given value. -// -// Deprecated: use IsNumber().LessThan() instead. -func (node *AssertNode) IsNumberLessThan(value float64, msgAndArgs ...interface{}) { - node.t.Helper() - node.IsNumber().LessThan(value, msgAndArgs...) -} - -// IsNumberLessThanOrEqual asserts that the JSON node has a number less than or equal to the given value. -// -// Deprecated: use IsNumber().LessThanOrEqual() instead. -func (node *AssertNode) IsNumberLessThanOrEqual(value float64, msgAndArgs ...interface{}) { - node.t.Helper() - node.IsNumber().LessThanOrEqual(value, msgAndArgs...) -} - -// IsNumberInRange asserts that the JSON node has a number with value in the given range. -// -// Deprecated: use IsNumber().GreaterThanOrEqual().LessThanOrEqual() instead. -func (node *AssertNode) IsNumberInRange(vmin, vmax float64, msgAndArgs ...interface{}) { - node.t.Helper() - node.IsNumber().GreaterThanOrEqual(vmin, msgAndArgs...) - node.IsNumber().LessThanOrEqual(vmax, msgAndArgs...) -} - // NumberAssertion is used to build a chain of assertions for the numeric node. type NumberAssertion struct { t TestingT diff --git a/assertjson/object.go b/assertjson/object.go index 0dd9486..043fbbe 100644 --- a/assertjson/object.go +++ b/assertjson/object.go @@ -9,14 +9,6 @@ import ( "github.com/stretchr/testify/assert" ) -// IsObjectWithPropertiesCount asserts that the JSON node is an object with given properties count. -// -// Deprecated: use IsObject().WithPropertiesCount() instead. -func (node *AssertNode) IsObjectWithPropertiesCount(count int, msgAndArgs ...interface{}) { - node.t.Helper() - node.IsObject().WithPropertiesCount(count, msgAndArgs...) -} - // IsObject asserts that the JSON node is an object. // It returns ObjectAssertion to execute a chain of assertions for the node value. func (node *AssertNode) IsObject(msgAndArgs ...interface{}) *ObjectAssertion { diff --git a/assertjson/string.go b/assertjson/string.go index a5fa9e0..7b9bac6 100644 --- a/assertjson/string.go +++ b/assertjson/string.go @@ -33,14 +33,6 @@ func (node *AssertNode) IsString(msgAndArgs ...interface{}) *StringAssertion { return nil } -// EqualToTheString asserts that the JSON node has a string value equals to the given value. -// -// Deprecated: use IsString().EqualTo() instead. -func (node *AssertNode) EqualToTheString(expectedValue string, msgAndArgs ...interface{}) { - node.t.Helper() - node.IsString().EqualTo(expectedValue, msgAndArgs...) -} - // Matches asserts that the JSON node has a string value that matches the regular expression. func (node *AssertNode) Matches(regexp interface{}, msgAndArgs ...interface{}) { node.t.Helper() @@ -65,30 +57,6 @@ func (node *AssertNode) DoesNotContain(contain string, msgAndArgs ...interface{} node.IsString().NotContains(contain, msgAndArgs...) } -// IsStringWithLength asserts that the JSON node has a string value with length equal to the given value. -// -// Deprecated: use IsString().WithLength() instead. -func (node *AssertNode) IsStringWithLength(length int, msgAndArgs ...interface{}) { - node.t.Helper() - node.IsString().WithLength(length, msgAndArgs...) -} - -// IsStringWithLengthInRange asserts that the JSON node has a string value with length in a given range. -// -// Deprecated: use IsString().WithLengthGreaterThanOrEqual().WithLengthLessThanOrEqual() instead. -func (node *AssertNode) IsStringWithLengthInRange(vmin int, vmax int, msgAndArgs ...interface{}) { - node.t.Helper() - node.IsString().WithLengthGreaterThanOrEqual(vmin, msgAndArgs...).WithLengthLessThanOrEqual(vmax, msgAndArgs...) -} - -// AssertString asserts that the JSON node has a string value and it is satisfied by the user function assertFunc. -// -// Deprecated: use IsString().Assert() instead. -func (node *AssertNode) AssertString(assertFunc func(t testing.TB, value string)) { - node.t.Helper() - node.IsString().Assert(assertFunc) -} - // StringAssertion is used to build a chain of assertions for the string node. type StringAssertion struct { t TestingT From afe2e0c2c264c451f72e8bac360b21a477cfce8a Mon Sep 17 00:00:00 2001 From: Igor Lazarev Date: Wed, 23 Sep 2026 08:27:09 +0000 Subject: [PATCH 2/2] chore: bump golangci-lint to v2.13.2 Switch to gomodguard_v2, exclude goconst in tests, and fix govet inline on nilable kinds. Co-authored-by: Cursor --- .github/workflows/main.yml | 2 +- .github/workflows/release.yml | 2 +- .golangci.yml | 3 ++- CHANGELOG.md | 2 ++ assertjson/common.go | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b346911..15bc734 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,7 +38,7 @@ jobs: - name: Run golangci-lint uses: golangci/golangci-lint-action@v9 with: - version: v2.6.1 + version: v2.13.2 - name: Run tests run: go test -race -v ./... diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c043fd6..d521e9b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -84,7 +84,7 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v9 with: - version: v2.6.1 + version: v2.13.2 - name: Full release validation run: bash scripts/test-all.sh diff --git a/.golangci.yml b/.golangci.yml index 919bd7a..004e600 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,7 +18,7 @@ linters: - gocyclo - godot - godox - - gomodguard + - gomodguard_v2 - goprintffuncname - gosec - importas @@ -75,6 +75,7 @@ linters: - err113 - errcheck - funlen + - goconst - gochecknoglobals - gocyclo - gosec diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d00b6f..5144f01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - JWT assertion callbacks use `assertjson` types instead of `github.com/golang-jwt/jwt/v5`. - Module dependencies (`github.com/gofrs/uuid/v5`, `github.com/stretchr/testify`, `golang.org/x/net`) and minimum Go version (`1.26`). +- CI and local lint use golangci-lint `v2.13.2` (`gomodguard_v2`, test exclusions for + `goconst`). ### Removed diff --git a/assertjson/common.go b/assertjson/common.go index 2fdf1f2..36b442f 100644 --- a/assertjson/common.go +++ b/assertjson/common.go @@ -122,7 +122,7 @@ func isNil(object interface{}) bool { []reflect.Kind{ reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, - reflect.Ptr, reflect.Slice, + reflect.Pointer, reflect.Slice, }, kind, )