Skip to content

Commit

Permalink
refactor(test): Handle errors if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
lubux committed Nov 23, 2023
1 parent 26e7edc commit e3b2b43
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion openpgp/clearsign/clearsign.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ func (d *dashEscaper) Write(data []byte) (n int, err error) {
}
d.whitespace = d.whitespace[:0]
}
d.toHash.Write(d.byteBuf)
if _, err = d.toHash.Write(d.byteBuf); err != nil {
return
}
if err = d.buffered.WriteByte(b); err != nil {
return
}
Expand Down
4 changes: 3 additions & 1 deletion openpgp/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,9 @@ func TestRevokeSubkey(t *testing.T) {
}

serializedEntity := bytes.NewBuffer(nil)
entity.SerializePrivate(serializedEntity, nil)
if err := entity.SerializePrivate(serializedEntity, nil); err != nil {
t.Fatal(err)
}

// Make sure revocation reason subpackets are not lost during serialization.
newEntity, err := ReadEntity(packet.NewReader(bytes.NewBuffer(serializedEntity.Bytes())))
Expand Down
3 changes: 3 additions & 0 deletions openpgp/packet/symmetric_key_encrypted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ func TestSerializeSymmetricKeyEncryptedV6RandomizeSlow(t *testing.T) {
}

key, err := SerializeSymmetricKeyEncrypted(&buf, passphrase, config)
if err != nil {
t.Errorf("failed to serialize %s", err)
}
p, err := Read(&buf)
if err != nil {
t.Errorf("failed to reparse %s", err)
Expand Down
1 change: 0 additions & 1 deletion openpgp/v2/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ func readToNextPublicKey(packets *packet.Reader) (err error) {
return
} else if err != nil {
if _, ok := err.(errors.UnsupportedError); ok {
err = nil
continue
}
return
Expand Down
4 changes: 3 additions & 1 deletion openpgp/v2/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,9 @@ func TestRevokeSubkey(t *testing.T) {
}

serializedEntity := bytes.NewBuffer(nil)
entity.SerializePrivate(serializedEntity, nil)
if err := entity.SerializePrivate(serializedEntity, nil); err != nil {
t.Fatal(err)
}

// Make sure revocation reason subpackets are not lost during serialization.
newEntity, err := ReadEntity(packet.NewReader(bytes.NewBuffer(serializedEntity.Bytes())))
Expand Down

0 comments on commit e3b2b43

Please sign in to comment.