From bf0f6330fd04cd861f92fe262dc3b0a5336a2f0e Mon Sep 17 00:00:00 2001 From: Shawn Smith Date: Sat, 3 Oct 2015 17:28:38 +0900 Subject: [PATCH] start GoTool tests --- check/utils_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/check/utils_test.go b/check/utils_test.go index 9cb8853..c6e17e2 100644 --- a/check/utils_test.go +++ b/check/utils_test.go @@ -15,3 +15,30 @@ func TestGoFiles(t *testing.T) { t.Errorf("GoFiles(%q) = %v, want %v", "testfiles/", files, want) } } + +var goToolTests = []struct { + name string + dir string + filenames []string + tool []string + percent float64 + failed []FileSummary + wantErr bool +}{ + {"go vet", "testfiles/", []string{"testfiles/a.go", "testfiles/b.go", "testfiles/c.go"}, []string{"go", "tool", "vet"}, 1, []FileSummary{}, false}, +} + +func TestGoTool(t *testing.T) { + for _, tt := range goToolTests { + f, fs, err := GoTool(tt.dir, tt.filenames, tt.tool) + if err != nil && !tt.wantErr { + t.Fatal(err) + } + if f != tt.percent { + t.Errorf("[%s] GoTool percent = %f, want %f", tt.name, f, tt.percent) + } + if !reflect.DeepEqual(fs, tt.failed) { + t.Errorf("[%s] GoTool failed = %v, want %v", tt.name, fs, tt.failed) + } + } +}