aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/gpg/gpg_test.go
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-05-24 15:12:17 -0500
committerRobin Jarry <robin@jarry.cc>2022-05-25 10:09:04 +0200
commit0cc992b4e3ed26c0f9f8dab94024985c87853a64 (patch)
tree6f790f1b09cca049208417f6af7d9e658355fc50 /lib/crypto/gpg/gpg_test.go
parent600913015d23a3d322ac10d6bbfde425e7f68606 (diff)
downloadaerc-0cc992b4e3ed26c0f9f8dab94024985c87853a64.tar.gz
gpg: refactor tests for macos compatibility
Refactor lib/crypto/gpg tests to facilitate unit test runs on macos. Macos creates temporary directories with names too long to call gpg-agent (108 characters). Additionally, too many concurrent test calls created IPC errors to gpg-agent. To get around this, tests were given shorter names and refactored into subtests to create fewer concurrent tests Tested on Linux and MacOS. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/crypto/gpg/gpg_test.go')
-rw-r--r--lib/crypto/gpg/gpg_test.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/crypto/gpg/gpg_test.go b/lib/crypto/gpg/gpg_test.go
index d8338301..e34cc2bb 100644
--- a/lib/crypto/gpg/gpg_test.go
+++ b/lib/crypto/gpg/gpg_test.go
@@ -31,41 +31,41 @@ func toCRLF(s string) string {
return strings.ReplaceAll(s, "\n", "\r\n")
}
-func deepEqual(t *testing.T, r *models.MessageDetails, expect *models.MessageDetails) {
+func deepEqual(t *testing.T, name string, r *models.MessageDetails, expect *models.MessageDetails) {
var resBuf bytes.Buffer
if _, err := io.Copy(&resBuf, r.Body); err != nil {
- t.Fatalf("io.Copy() = %v", err)
+ t.Fatalf("%s: io.Copy() = %v", name, err)
}
var expBuf bytes.Buffer
if _, err := io.Copy(&expBuf, expect.Body); err != nil {
- t.Fatalf("io.Copy() = %v", err)
+ t.Fatalf("%s: io.Copy() = %v", name, err)
}
if resBuf.String() != expBuf.String() {
- t.Errorf("MessagesDetails.Body = \n%v\n but want \n%v", resBuf.String(), expBuf.String())
+ t.Errorf("%s: MessagesDetails.Body = \n%v\n but want \n%v", name, resBuf.String(), expBuf.String())
}
if r.IsEncrypted != expect.IsEncrypted {
- t.Errorf("IsEncrypted = \n%v\n but want \n%v", r.IsEncrypted, expect.IsEncrypted)
+ t.Errorf("%s: IsEncrypted = \n%v\n but want \n%v", name, r.IsEncrypted, expect.IsEncrypted)
}
if r.IsSigned != expect.IsSigned {
- t.Errorf("IsSigned = \n%v\n but want \n%v", r.IsSigned, expect.IsSigned)
+ t.Errorf("%s: IsSigned = \n%v\n but want \n%v", name, r.IsSigned, expect.IsSigned)
}
if r.SignedBy != expect.SignedBy {
- t.Errorf("SignedBy = \n%v\n but want \n%v", r.SignedBy, expect.SignedBy)
+ t.Errorf("%s: SignedBy = \n%v\n but want \n%v", name, r.SignedBy, expect.SignedBy)
}
if r.SignedByKeyId != expect.SignedByKeyId {
- t.Errorf("SignedByKeyId = \n%v\n but want \n%v", r.SignedByKeyId, expect.SignedByKeyId)
+ t.Errorf("%s: SignedByKeyId = \n%v\n but want \n%v", name, r.SignedByKeyId, expect.SignedByKeyId)
}
if r.SignatureError != expect.SignatureError {
- t.Errorf("SignatureError = \n%v\n but want \n%v", r.SignatureError, expect.SignatureError)
+ t.Errorf("%s: SignatureError = \n%v\n but want \n%v", name, r.SignatureError, expect.SignatureError)
}
if r.DecryptedWith != expect.DecryptedWith {
- t.Errorf("DecryptedWith = \n%v\n but want \n%v", r.DecryptedWith, expect.DecryptedWith)
+ t.Errorf("%s: DecryptedWith = \n%v\n but want \n%v", name, r.DecryptedWith, expect.DecryptedWith)
}
if r.DecryptedWithKeyId != expect.DecryptedWithKeyId {
- t.Errorf("DecryptedWithKeyId = \n%v\n but want \n%v", r.DecryptedWithKeyId, expect.DecryptedWithKeyId)
+ t.Errorf("%s: DecryptedWithKeyId = \n%v\n but want \n%v", name, r.DecryptedWithKeyId, expect.DecryptedWithKeyId)
}
}