changeset 16:bfc035bd5132

cleaning up tests per go vet
author Paul Fisher <paul@pfish.zone>
date Fri, 30 Oct 2015 00:01:59 -0400
parents 9b4ec6b5c23e
children 342f63116bfd
files auth/auth_test.go file/file_test.go
diffstat 2 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/auth/auth_test.go	Thu Oct 29 23:56:53 2015 -0400
+++ b/auth/auth_test.go	Fri Oct 30 00:01:59 2015 -0400
@@ -112,7 +112,7 @@
 			t.Errorf("NewEntry(_) = _, %q, _; wanted to match xxxx-xxxx-xxxx-xxxx", password)
 		}
 		if !entry.Authenticate(password) {
-			t.Errorf("NewEntry(%q).Authenticate(%q, %q) failed",
+			t.Errorf("NewEntry(%q).Authenticate(%q) failed",
 				c.description, password)
 		}
 	}
@@ -142,7 +142,7 @@
 	for _, c := range cases {
 		got := entry.Authenticate(c.password)
 		if got != c.want {
-			t.Errorf("entry.Authenticate(%q) == %q, want %q",
+			t.Errorf("entry.Authenticate(%q) == %v, want %v",
 				c.password, got, c.want)
 		}
 	}
@@ -159,7 +159,7 @@
 	for _, c := range cases {
 		got := entry.Authenticate(c.password)
 		if got != c.want {
-			t.Errorf("entry.Authenticate(%q, %q) == %q, want %q",
+			t.Errorf("entry.Authenticate(%q) == %v, want %v",
 				c.password, got, c.want)
 		}
 	}
--- a/file/file_test.go	Thu Oct 29 23:56:53 2015 -0400
+++ b/file/file_test.go	Fri Oct 30 00:01:59 2015 -0400
@@ -71,7 +71,7 @@
 func (f *testfile) read() string {
 	contents, err := ioutil.ReadFile(f.filepath())
 	if err != nil {
-		f.t.Fatalf("couldn't read output file: %q", err.Error())
+		f.t.Fatalf("couldn't read output file: %v", err)
 	}
 	return string(contents)
 }
@@ -79,14 +79,14 @@
 func (f *testfile) write(data string) {
 	err := ioutil.WriteFile(f.filepath(), []byte(data), filemode)
 	if err != nil {
-		f.t.Fatalf("couldn't write output file: %q", err)
+		f.t.Fatalf("couldn't write output file: %v", err)
 	}
 }
 
 func (f *testfile) perms() os.FileMode {
 	stat, err := os.Stat(f.filepath())
 	if err != nil {
-		f.t.Fatalf("couldn't stat output file: %q", err)
+		f.t.Fatalf("couldn't stat output file: %v", err)
 	}
 	return stat.Mode().Perm()
 }
@@ -104,7 +104,7 @@
 		t.Fatal(err.Error())
 	}
 	if f.perms() != filemode {
-		t.Errorf("want perms %q; got %q", filemode, f.perms())
+		t.Errorf("want perms %o; got %o", filemode, f.perms())
 	}
 	want := fmt.Sprintf("%s\n%s\n", Banner, shadowSpooky)
 	got := f.read()
@@ -172,7 +172,7 @@
 	s := New(f.filepath())
 	entries, err := s.AllEntries()
 	if len(entries) != 0 {
-		t.Errorf("want 0 entries; got %q", entries)
+		t.Errorf("want 0 entries; got %d", entries)
 	}
 
 	f.write(fmt.Sprintf("%s\n%s\n%s\n", Banner, shadowWhatever, shadowSpooky))
@@ -181,10 +181,10 @@
 		t.Fatal(err.Error())
 	}
 	if len(entries) != 2 {
-		t.Fatalf("want len(entries) == 2; got entries = %q", entries)
+		t.Fatalf("want len(entries) == 2; got entries = %d", entries)
 	}
 	if *entries[0] != *aWhatever || *entries[1] != *aSpooky {
-		t.Fatalf("want {aWhatever, aSpooky}; got %q", entries)
+		t.Fatalf("want {aWhatever, aSpooky}; got %d", entries)
 	}
 }
 
@@ -257,11 +257,11 @@
 	}
 	ev := <-events
 	if unlocked != ev {
-		t.Errorf("event 0: %q; got %q", unlocked, ev)
+		t.Errorf("event 0: %v; got %v", unlocked, ev)
 	}
 	ev = <-events
 	if written != ev {
-		t.Errorf("event 1: %q; got %q", written, ev)
+		t.Errorf("event 1: %v; got %v", written, ev)
 	}
 
 	want := fmt.Sprintf("%s\n%s\n", Banner, shadowWhatever)
@@ -298,11 +298,11 @@
 	}
 	ev := <-events
 	if failed != ev {
-		t.Errorf("event 0: want %q; got %q", failed, ev)
+		t.Errorf("event 0: want %v; got %v", failed, ev)
 	}
 	ev = <-events
 	if unlocked != ev {
-		t.Errorf("event 1: want %q; got %q", unlocked, ev)
+		t.Errorf("event 1: want %v; got %v", unlocked, ev)
 	}
 
 	want := fmt.Sprintf("%s\n", Banner)