Fixing some errors raised by tests

This commit is contained in:
Zack Mullaly 2018-07-26 15:17:47 -04:00
Родитель ff6d7d82fa
Коммит 3f68ed39e7
3 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -12,6 +12,7 @@ import (
"fmt" "fmt"
"github.com/mozilla/mig" "github.com/mozilla/mig"
"github.com/mozilla/mig/service" "github.com/mozilla/mig/service"
"io"
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec" "os/exec"

Просмотреть файл

@ -52,12 +52,11 @@ REDHAT_SUPPORT_PRODUCT_VERSION="7"`,
reader := strings.NewReader(testCase.FileContents) reader := strings.NewReader(testCase.FileContents)
ident, err := getOSRelease(reader) ident, err := getOSRelease(reader)
defer reader.Close()
gotErr := err != nil gotErr := err != nil
if testCase.ExpectError && !gotErr { if testCase.ExpectError && !gotErr {
t.Errorf("Expected to get an error but did not") 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()) t.Errorf("Did not expect to get an error, but got %s", err.Error())
} else if ident != testCase.ExpectedIdent { } else if ident != testCase.ExpectedIdent {
t.Errorf("Expected to get ident \"%s\" but got \"%s\"", testCase.ExpectedIdent, ident) t.Errorf("Expected to get ident \"%s\" but got \"%s\"", testCase.ExpectedIdent, ident)

Просмотреть файл

@ -37,7 +37,7 @@ func TestPrompt(t *testing.T) {
Desc: "Type 'foo' for testing", Desc: "Type 'foo' for testing",
Error: "seriously, or I'll be an error.", Error: "seriously, or I'll be an error.",
Prompt: "foo", 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) s1, err := conn.GetPassphrase(req)
if err != nil { if err != nil {
@ -73,7 +73,7 @@ func TestPrompt(t *testing.T) {
Desc: "Press Cancel for testing", Desc: "Press Cancel for testing",
Error: "seriously, or I'll be an error.", Error: "seriously, or I'll be an error.",
Prompt: "cancel!", Prompt: "cancel!",
CacheKey: fmt.Sprintf("gpgagent_test-cachekey-%d", time.Now()), CacheKey: fmt.Sprintf("gpgagent_test-cachekey-%d", time.Now().Unix()),
}) })
if err != ErrCancel { if err != ErrCancel {
t.Errorf("expected cancel, got %q, %v", s4, err) t.Errorf("expected cancel, got %q, %v", s4, err)