Преглед изворни кода

Read response from http.Get() in TestWebInterface, so http.Get() does not hang (#315)

* fix TestWebInterface

* check errors in modified portion of TestWebInterface

* use defer wg.Done()
Margaret Nolan пре 7 година
родитељ
комит
aed84736a0
No account linked to committer's email address
1 измењених фајлова са 9 додато и 2 уклоњено
  1. 9
    2
      internal/driver/webui_test.go

+ 9
- 2
internal/driver/webui_test.go Прегледај датотеку

119
 		for count := 0; count < 2; count++ {
119
 		for count := 0; count < 2; count++ {
120
 			wg.Add(1)
120
 			wg.Add(1)
121
 			go func() {
121
 			go func() {
122
-				http.Get(path)
123
-				wg.Done()
122
+				defer wg.Done()
123
+				res, err := http.Get(path)
124
+				if err != nil {
125
+					t.Error("could not fetch", c.path, err)
126
+					return
127
+				}
128
+				if _, err = ioutil.ReadAll(res.Body); err != nil {
129
+					t.Error("could not read response", c.path, err)
130
+				}
124
 			}()
131
 			}()
125
 		}
132
 		}
126
 	}
133
 	}