aboutsummaryrefslogtreecommitdiff
path: root/openpgp
diff options
context:
space:
mode:
authoraviau <alexandre@alexandreviau.net>2018-06-14 15:39:14 -0400
committerFilippo Valsorda <filippo@golang.org>2018-06-14 19:53:31 +0000
commit550ed51fee2efe5b5bf5cdb85db39253b56afbc3 (patch)
treef02faaaefb86547cd0bed9625630f71f8a2f1b29 /openpgp
parentfd5f17ee729917fcb39f16421460212d917a0813 (diff)
downloadgo-x-crypto-550ed51fee2efe5b5bf5cdb85db39253b56afbc3.tar.xz
openpgp: fix bad error message
When failing, TestKeyExpiry would output the wrong expected key id. It would output "Expected key 1ABB25A0" instead of "Expected key 96A672F5". Avoid this mistake by declaring the variable only once and using it in the error format. Change-Id: I860d82bf2c7fa80558051cdb21a41d506e95c25f Reviewed-on: https://go-review.googlesource.com/118958 Reviewed-by: Filippo Valsorda <filippo@golang.org> Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'openpgp')
-rw-r--r--openpgp/keys_test.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/openpgp/keys_test.go b/openpgp/keys_test.go
index 40aa391..d877589 100644
--- a/openpgp/keys_test.go
+++ b/openpgp/keys_test.go
@@ -29,16 +29,16 @@ func TestKeyExpiry(t *testing.T) {
//
// So this should select the newest, non-expired encryption key.
key, _ := entity.encryptionKey(time1)
- if id := key.PublicKey.KeyIdShortString(); id != "96A672F5" {
- t.Errorf("Expected key 1ABB25A0 at time %s, but got key %s", time1.Format(timeFormat), id)
+ if id, expected := key.PublicKey.KeyIdShortString(), "96A672F5"; id != expected {
+ t.Errorf("Expected key %s at time %s, but got key %s", expected, time1.Format(timeFormat), id)
}
// Once the first encryption subkey has expired, the second should be
// selected.
time2, _ := time.Parse(timeFormat, "2013-07-09")
key, _ = entity.encryptionKey(time2)
- if id := key.PublicKey.KeyIdShortString(); id != "96A672F5" {
- t.Errorf("Expected key 96A672F5 at time %s, but got key %s", time2.Format(timeFormat), id)
+ if id, expected := key.PublicKey.KeyIdShortString(), "96A672F5"; id != expected {
+ t.Errorf("Expected key %s at time %s, but got key %s", expected, time2.Format(timeFormat), id)
}
// Once all the keys have expired, nothing should be returned.