浏览代码

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
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 9 次插入2 次删除
  1. 9
    2
      internal/driver/webui_test.go

+ 9
- 2
internal/driver/webui_test.go 查看文件

@@ -119,8 +119,15 @@ func TestWebInterface(t *testing.T) {
119 119
 		for count := 0; count < 2; count++ {
120 120
 			wg.Add(1)
121 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
 	}