Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert key tests to tabular tests #157

Merged
merged 3 commits into from
Jul 10, 2023
Merged

Convert key tests to tabular tests #157

merged 3 commits into from
Jul 10, 2023

Conversation

qmuntal
Copy link
Contributor

@qmuntal qmuntal commented Jul 10, 2023

This PR contains converts all COSE_Key-related tests to tabular tests, making those test more similar to the COSE_Sign related tests. Also, IMO, tabular tests make it easier to understand what is being tested, as they don't depend on reusing and mutating inputs but on explicit and clearly definid inputs and outputs.

There is just one behavior change in this PR: NewEC2Key and NewOKPKey return a nil key if the validation fails, together with the corresponding error. Returning nil objects when there is an error instead is more idiomatic and less error prone.

This will also facilitate testing the API redesign that I'll submit as part of #151.

@codecov
Copy link

codecov bot commented Jul 10, 2023

Codecov Report

Merging #157 (382c9bf) into main (d16fe13) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #157       /-   ##
==========================================
  Coverage   91.32%   91.35%    0.02%     
==========================================
  Files          12       12              
  Lines        1545     1550        5     
==========================================
  Hits         1411     1416        5     
- Misses         97       98        1     
  Partials       37       36       -1     
Impacted Files Coverage Δ
key.go 89.30% <100.00%> (-0.59%) ⬇️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@thomas-fossati thomas-fossati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

key_test.go Outdated Show resolved Hide resolved
Signed-off-by: qmuntal <[email protected]>
Copy link
Contributor

@yogeshbdeshpande yogeshbdeshpande left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@qmuntal qmuntal merged commit c862f87 into main Jul 10, 2023
5 checks passed
@qmuntal qmuntal deleted the keytests branch July 10, 2023 15:50
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.

4 participants