Skip to content

Conversation

@GregoryAlbouy
Copy link
Member

@GregoryAlbouy GregoryAlbouy commented Nov 6, 2022

Description

Package benchttptest provides utilities for benchttp testing.

It exposes comparison utilities to be used by benchttp consumers in their tests: configparse/configio, benchttp/cli.configflag, and any source that needs to ensure it creates or retrieves an expected benchttp.Runner.

Currently exposed functions:

// AssertEqualRunners fails t and shows a diff if a and b are not equal,
// as determined by RunnerCmpOptions.
func AssertEqualRunners(t *testing.T, x, y benchttp.Runner) {}

// EqualRunners returns true if x and y are equal, as determined by
// RunnerCmpOptions.
func EqualRunners(x, y benchttp.Runner) bool {}

// DiffRunner returns a string showing the diff between x and y,
// as determined by RunnerCmpOptions.
func DiffRunner(x, y benchttp.Runner) string {}

It uses go-cmp internally, which allows to fine-tune equality checks contrary to reflect.DeepEqual.
However it has some severe rules regarding immutability and I haven't managed to tweak it around Request.Body, as it cannot be read without mutation. As a work-around we simply compare the body separately (and restore it afterwards).

Changes

No changes to the existing in this PR. However it makes tests much simpler in the following PRs:

Notes

@GregoryAlbouy GregoryAlbouy added the enhancement New feature or request label Nov 6, 2022
@GregoryAlbouy GregoryAlbouy added this to the v0.2 milestone Nov 6, 2022
@GregoryAlbouy GregoryAlbouy changed the base branch from main to feat/major-api-improvements November 6, 2022 12:00
@codecov-commenter
Copy link

codecov-commenter commented Nov 6, 2022

Codecov Report

Merging #62 (6c67087) into main (5a25fcb) will decrease coverage by 0.15%.
The diff coverage is 71.73%.

❗ Current head 6c67087 differs from pull request most recent head 243547c. Consider uploading reports for the commit 243547c to get more accurate results

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main      #62      +/-   ##
==========================================
- Coverage   74.40%   74.26%   -0.15%     
==========================================
  Files          25       26       +1     
  Lines         801      847      +46     
==========================================
+ Hits          596      629      +33     
- Misses        181      191      +10     
- Partials       24       27       +3     
Flag Coverage Δ
unittests 74.26% <71.73%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
benchttptest/compare.go 71.73% <71.73%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@GregoryAlbouy GregoryAlbouy force-pushed the feat/major-api-improvements branch from ced71cd to 3492ed9 Compare March 28, 2023 19:55
Base automatically changed from feat/major-api-improvements to main March 28, 2023 20:01
- implement AssertEqualRunners, EqualRunners, DiffRunner
- Unit test exposed functions
@GregoryAlbouy GregoryAlbouy merged commit d6957ab into main Mar 28, 2023
@GregoryAlbouy GregoryAlbouy deleted the feat/benchttptest branch March 28, 2023 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants