From 3f68ed39e79b009e1f9e689524932af5174aecc8 Mon Sep 17 00:00:00 2001 From: Zack Mullaly Date: Thu, 26 Jul 2018 15:17:47 -0400 Subject: [PATCH] Fixing some errors raised by tests --- mig-agent/agentcontext/env_linux.go | 1 + mig-agent/agentcontext/env_linux_test.go | 3 +-- pgp/gpgagent/gpgagent_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mig-agent/agentcontext/env_linux.go b/mig-agent/agentcontext/env_linux.go index 847160b8..4dea8ca8 100644 --- a/mig-agent/agentcontext/env_linux.go +++ b/mig-agent/agentcontext/env_linux.go @@ -12,6 +12,7 @@ import ( "fmt" "github.com/mozilla/mig" "github.com/mozilla/mig/service" + "io" "io/ioutil" "os" "os/exec" diff --git a/mig-agent/agentcontext/env_linux_test.go b/mig-agent/agentcontext/env_linux_test.go index e667dd77..d660ae11 100644 --- a/mig-agent/agentcontext/env_linux_test.go +++ b/mig-agent/agentcontext/env_linux_test.go @@ -52,12 +52,11 @@ REDHAT_SUPPORT_PRODUCT_VERSION="7"`, reader := strings.NewReader(testCase.FileContents) ident, err := getOSRelease(reader) - defer reader.Close() gotErr := err != nil if testCase.ExpectError && !gotErr { t.Errorf("Expected to get an error but did not") - } else if !testCase.ExpectedIdent && gotErr { + } else if !testCase.ExpectError && gotErr { t.Errorf("Did not expect to get an error, but got %s", err.Error()) } else if ident != testCase.ExpectedIdent { t.Errorf("Expected to get ident \"%s\" but got \"%s\"", testCase.ExpectedIdent, ident) diff --git a/pgp/gpgagent/gpgagent_test.go b/pgp/gpgagent/gpgagent_test.go index 3e078585..489c9bb8 100644 --- a/pgp/gpgagent/gpgagent_test.go +++ b/pgp/gpgagent/gpgagent_test.go @@ -37,7 +37,7 @@ func TestPrompt(t *testing.T) { Desc: "Type 'foo' for testing", Error: "seriously, or I'll be an error.", Prompt: "foo", - CacheKey: fmt.Sprintf("gpgagent_test-cachekey-%d", time.Now()), + CacheKey: fmt.Sprintf("gpgagent_test-cachekey-%d", time.Now().Unix()), } s1, err := conn.GetPassphrase(req) if err != nil { @@ -73,7 +73,7 @@ func TestPrompt(t *testing.T) { Desc: "Press Cancel for testing", Error: "seriously, or I'll be an error.", Prompt: "cancel!", - CacheKey: fmt.Sprintf("gpgagent_test-cachekey-%d", time.Now()), + CacheKey: fmt.Sprintf("gpgagent_test-cachekey-%d", time.Now().Unix()), }) if err != ErrCancel { t.Errorf("expected cancel, got %q, %v", s4, err)