From cb7fa3dc1ca83727aba38a90eea20d86660b94ee Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 26 Jul 2023 15:15:17 +0200 Subject: [PATCH] feat: add ChecksAll --- CHANGELOG.md | 1 + tests/path_gateway_raw_test.go | 6 ++++-- tooling/test/sugar.go | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18df60519..71bb5d80e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased ### Added - `--verbose` flag displays all the output to the console +- `Expect.Headers.ChecksAll`: an expectation to test all the header values (0, 1, or more) ### Changed - finalized port of Kubo's sharness tests. [PR](https://github.com/ipfs/gateway-conformance/pull/92) diff --git a/tests/path_gateway_raw_test.go b/tests/path_gateway_raw_test.go index b6934e125..084c822cb 100644 --- a/tests/path_gateway_raw_test.go +++ b/tests/path_gateway_raw_test.go @@ -173,8 +173,10 @@ func TestGatewayBlockMultiRangeRequest(t *testing.T) { return v != "" }), Header("Content-Range"). - Checks(func(v string) bool { - contentRange = v + ChecksAll(func(v []string) bool { + if len(v) == 1 { + contentRange = v[0] + } return true }), ), diff --git a/tooling/test/sugar.go b/tooling/test/sugar.go index 301391306..966c96859 100644 --- a/tooling/test/sugar.go +++ b/tooling/test/sugar.go @@ -267,6 +267,13 @@ func (h HeaderBuilder) Checks(f func(string) bool) HeaderBuilder { return h } +func (h HeaderBuilder) ChecksAll(f func([]string) bool) HeaderBuilder { + h.Check_ = check.CheckFunc[[]string]{ + Fn: f, + } + return h +} + func (h HeaderBuilder) Not() HeaderBuilder { h.Not_ = !h.Not_ return h