veraison / go-cose

go library for CBOR Object Signing and Encryption (COSE)
Mozilla Public License 2.0
49 stars 26 forks source link

Convert key tests to tabular tests #157

Closed qmuntal closed 1 year ago

qmuntal commented 1 year ago

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[bot] commented 1 year ago

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%) :arrow_down:

... and 1 file with indirect coverage changes

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