32 lines
652 B
Go
32 lines
652 B
Go
package go_pgp
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"io"
|
|
"testing"
|
|
)
|
|
|
|
func TestPGPErrorError(t *testing.T) {
|
|
testCases := []struct{ err error }{
|
|
{
|
|
err: fmt.Errorf("aarrr!!!"),
|
|
},
|
|
}
|
|
|
|
for i, testCase := range testCases {
|
|
err := PGPError{testCase.err}
|
|
expected := fmt.Sprintf("%s%s", pgpErrorPrefix, testCase.err.Error())
|
|
if result := err.Error(); result != expected {
|
|
t.Errorf("TestPGPErrorError: test case %d: expected '%s' but got '%s'", i+1, expected, result)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestPGPErrorUnwrap(t *testing.T) {
|
|
tester := &PGPError{io.EOF}
|
|
if !errors.Is(tester, io.EOF) {
|
|
t.Error("TestPGPErrorError: test case 1: Unwrapping failed")
|
|
}
|
|
}
|