Skip to content

Commit

Permalink
Minor tidy ups
Browse files Browse the repository at this point in the history
Signed-off-by: Yogesh Deshpande <[email protected]>
  • Loading branch information
yogeshbdeshpande committed Feb 6, 2024
1 parent 8257db6 commit f86fd9e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions comid/integrityregisters.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@ func (i *IntegrityRegisters) UnmarshalJSON(data []byte) error {
var d Digests

if err := json.Unmarshal(val, &ktv); err != nil {
return fmt.Errorf("unable to unmarshal keyvalue: %w", err)
return fmt.Errorf("unable to unmarshal keyTypeAndValue: %w", err)
}
if err := json.Unmarshal(ktv.Value, &d); err != nil {
return fmt.Errorf("unable to unmarshal Digest: %w", err)
return fmt.Errorf("unable to unmarshal Digests: %w", err)
}
switch ktv.KeyType {
case UintType:
u, err := strconv.Atoi(key)
if err != nil {
return fmt.Errorf("unable to convert key to uint: %v", err)
return fmt.Errorf("unable to convert key to uint: %w", err)
} else if u < 0 {
return fmt.Errorf("invalid negative integer key")
}
Expand Down
2 changes: 1 addition & 1 deletion comid/integrityregisters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func TestIntegrityRegisters_UnmarshalJSON_NOK(t *testing.T) {
{
Name: "invalid digest",
Input: `{"1":{"key_type":"uint","Value":["sha-256;5Fty9cDAtXLbTY06t+l/3TmI0eoJN7LZ6hOUiTXU="]}}`,
Err: `unable to unmarshal Digest: illegal base64 data at input byte 40`,
Err: `unable to unmarshal Digests: illegal base64 data at input byte 40`,
},
} {
t.Run(tv.Name, func(t *testing.T) {
Expand Down

0 comments on commit f86fd9e

Please sign in to comment.