Skip to content

Commit 6ad57cb

Browse files
committed
Fix Slice typo and use local toolchain for testing
Fix the panic messages from `spec.Slice` to properly report coming from `Slice` and not `NewSlice`. Also set `GOTOOLCHAIN=local` when testing to ensure tests run as the current version of Go to future-proof against unexpected testing against a different version should `toolchain` be set in `go.mod`.
1 parent 2f66ebf commit 6ad57cb

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ All notable changes to this project will be documented in this file. It uses the
77
[Semantic Versioning]: https://semver.org/spec/v2.0.0.html
88
"Semantic Versioning 2.0.0"
99

10+
## [v0.4.1] — Unreleased
11+
12+
### 🪲 Bug Fixes
13+
14+
* Fixed the panic messages from `spec.Slice` to properly report coming from
15+
`Slice` and not `NewSlice`.
16+
17+
[v0.4.1]: https://github.com/theory/jsonpath/compare/v0.4.0...v0.4.1
18+
1019
## [v0.4.0] — 2025-01-15
1120

1221
### ⚡ Improvements

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ GO ?= go
22

33
.PHONY: test # Run the unit tests
44
test:
5-
$(GO) test ./... -count=1
5+
GOTOOLCHAIN=local $(GO) test ./... -count=1
66

77
.PHONY: cover # Run test coverage
88
cover: $(shell find . -name \*.go)
9-
$(GO) test -v -coverprofile=cover.out -covermode=count ./...
9+
GOTOOLCHAIN=local $(GO) test -v -coverprofile=cover.out -covermode=count ./...
1010
@$(GO) tool cover -html=cover.out
1111

1212
.PHONY: lint # Lint the project

spec/selector.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func Slice(args ...any) SliceSelector {
278278
case nil:
279279
// Nothing to do
280280
default:
281-
panic("Third value passed to NewSlice is not an integer")
281+
panic("Third value passed to Slice is not an integer")
282282
}
283283
fallthrough
284284
case endArg:
@@ -292,7 +292,7 @@ func Slice(args ...any) SliceSelector {
292292
s.end = math.MinInt
293293
}
294294
default:
295-
panic("Second value passed to NewSlice is not an integer")
295+
panic("Second value passed to Slice is not an integer")
296296
}
297297
fallthrough
298298
case startArg:
@@ -305,7 +305,7 @@ func Slice(args ...any) SliceSelector {
305305
s.start = math.MaxInt
306306
}
307307
default:
308-
panic("First value passed to NewSlice is not an integer")
308+
panic("First value passed to Slice is not an integer")
309309
}
310310
}
311311
return s

spec/selector_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,15 +336,15 @@ func TestSlicePanic(t *testing.T) {
336336
a := assert.New(t)
337337

338338
a.PanicsWithValue(
339-
"First value passed to NewSlice is not an integer",
339+
"First value passed to Slice is not an integer",
340340
func() { Slice("hi") },
341341
)
342342
a.PanicsWithValue(
343-
"Second value passed to NewSlice is not an integer",
343+
"Second value passed to Slice is not an integer",
344344
func() { Slice(nil, "hi") },
345345
)
346346
a.PanicsWithValue(
347-
"Third value passed to NewSlice is not an integer",
347+
"Third value passed to Slice is not an integer",
348348
func() { Slice(nil, 42, "hi") },
349349
)
350350
}

0 commit comments

Comments
 (0)