diff --git a/fetchall/main_test.go b/fetchall/main_test.go index 71c3855..2dca656 100644 --- a/fetchall/main_test.go +++ b/fetchall/main_test.go @@ -35,7 +35,7 @@ func TestMain(m *testing.M) { func TestFetchall_valid(t *testing.T) { binary, err := binCache.GetBinary(fetchallImportPath) - require.Nil(t, err) + require.NoError(t, err) type endpoint string @@ -73,14 +73,14 @@ func TestFetchall_valid(t *testing.T) { cmd.Stdout = nil cmd.Stderr = os.Stderr - require.Nil(t, cmd.Run()) + require.NoError(t, cmd.Run()) }) } } func TestFetchall_multipleURLs(t *testing.T) { binary, err := binCache.GetBinary(fetchallImportPath) - require.Nil(t, err) + require.NoError(t, err) var fooHit, barHit int32 @@ -101,7 +101,7 @@ func TestFetchall_multipleURLs(t *testing.T) { cmd.Stdout = nil cmd.Stderr = os.Stderr - require.Nil(t, cmd.Run()) + require.NoError(t, cmd.Run()) require.Equal(t, int32(1), atomic.LoadInt32(&fooHit)) require.Equal(t, int32(1), atomic.LoadInt32(&barHit)) @@ -109,7 +109,7 @@ func TestFetchall_multipleURLs(t *testing.T) { func TestFetchall_malformed(t *testing.T) { binary, err := binCache.GetBinary(fetchallImportPath) - require.Nil(t, err) + require.NoError(t, err) hit := int32(0) s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -123,14 +123,14 @@ func TestFetchall_malformed(t *testing.T) { cmd.Stderr = os.Stderr err = cmd.Run() - require.Nil(t, err) + require.NoError(t, err) require.True(t, atomic.LoadInt32(&hit) >= 2) } func TestFetchall_concurrency(t *testing.T) { binary, err := binCache.GetBinary(fetchallImportPath) - require.Nil(t, err) + require.NoError(t, err) var mu sync.Mutex var callOrder []time.Duration @@ -140,7 +140,7 @@ func TestFetchall_concurrency(t *testing.T) { require.NotEmpty(t, s) d, err := time.ParseDuration(s) - require.Nil(t, err) + require.NoError(t, err) time.Sleep(d) @@ -165,7 +165,7 @@ func TestFetchall_concurrency(t *testing.T) { cmd.Stdout = nil cmd.Stderr = os.Stderr - require.Nil(t, cmd.Run()) + require.NoError(t, cmd.Run()) mu.Lock() defer mu.Unlock() diff --git a/tools/testtool/commands/test_submission_test.go b/tools/testtool/commands/test_submission_test.go index 6031b74..8a64296 100644 --- a/tools/testtool/commands/test_submission_test.go +++ b/tools/testtool/commands/test_submission_test.go @@ -29,11 +29,11 @@ func listDirs(dir string) ([]string, error) { func Test_testSubmission_correct(t *testing.T) { testDirs, err := listDirs("../testdata/submissions/correct") - require.Nil(t, err) + require.NoError(t, err) for _, dir := range testDirs { absDir, err := filepath.Abs(dir) - require.Nil(t, err) + require.NoError(t, err) problem := path.Base(absDir) t.Run(problem, func(t *testing.T) { studentRepo := path.Join(absDir, "student") @@ -46,11 +46,11 @@ func Test_testSubmission_correct(t *testing.T) { func Test_testSubmission_incorrect(t *testing.T) { testDirs, err := listDirs("../testdata/submissions/incorrect") - require.Nil(t, err) + require.NoError(t, err) for _, dir := range testDirs { absDir, err := filepath.Abs(dir) - require.Nil(t, err) + require.NoError(t, err) problem := path.Base(absDir) t.Run(problem, func(t *testing.T) { diff --git a/urlfetch/main_test.go b/urlfetch/main_test.go index 99b441d..dc5b763 100644 --- a/urlfetch/main_test.go +++ b/urlfetch/main_test.go @@ -33,7 +33,7 @@ func TestMain(m *testing.M) { func TestUrlFetch_valid(t *testing.T) { binary, err := binCache.GetBinary(urlfetchImportPath) - require.Nil(t, err) + require.NoError(t, err) type endpoint string type response string @@ -91,7 +91,7 @@ func TestUrlFetch_valid(t *testing.T) { cmd.Stderr = os.Stderr data, err := cmd.Output() - require.Nil(t, err) + require.NoError(t, err) for _, r := range tc.expected { require.True(t, bytes.Contains(data, []byte(r)), @@ -104,7 +104,7 @@ func TestUrlFetch_valid(t *testing.T) { func TestUrlFetch_malformed(t *testing.T) { binary, err := binCache.GetBinary(urlfetchImportPath) - require.Nil(t, err) + require.NoError(t, err) s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { _, _ = w.Write([]byte("success")) @@ -141,7 +141,7 @@ func TestUrlFetch_malformed(t *testing.T) { func TestUrlFetch_order(t *testing.T) { binary, err := binCache.GetBinary(urlfetchImportPath) - require.Nil(t, err) + require.NoError(t, err) mux := http.NewServeMux() @@ -175,7 +175,7 @@ func TestUrlFetch_order(t *testing.T) { cmd.Stdout = nil cmd.Stderr = os.Stderr - require.Nil(t, cmd.Run()) + require.NoError(t, cmd.Run()) mu.Lock() defer mu.Unlock() diff --git a/wordcount/main_test.go b/wordcount/main_test.go index e2413dd..179c227 100644 --- a/wordcount/main_test.go +++ b/wordcount/main_test.go @@ -33,7 +33,7 @@ func TestMain(m *testing.M) { func TestWordCount(t *testing.T) { binary, err := binCache.GetBinary(wordcountImportPath) - require.Nil(t, err) + require.NoError(t, err) type counts map[string]int64 type files []string @@ -77,7 +77,7 @@ b`, t.Run(tc.name, func(t *testing.T) { // Create temp directory. testDir, err := ioutil.TempDir("", "wordcount-testdata-") - require.Nil(t, err) + require.NoError(t, err) defer func() { _ = os.RemoveAll(testDir) }() // Create test files in temp directory. @@ -85,7 +85,7 @@ b`, for _, f := range tc.files { file := path.Join(testDir, testtool.RandomName()) err = ioutil.WriteFile(file, []byte(f), 0644) - require.Nil(t, err) + require.NoError(t, err) files = append(files, file) } @@ -94,11 +94,11 @@ b`, cmd.Stderr = os.Stderr output, err := cmd.Output() - require.Nil(t, err) + require.NoError(t, err) // Parse output and compare with an expected one. counts, err := parseStdout(output) - require.Nil(t, err) + require.NoError(t, err) require.True(t, reflect.DeepEqual(tc.expected, counts), fmt.Sprintf("expected: %v; got: %v", tc.expected, counts))