提交 871c2e67 编写于 作者: M Medya Gh

Better clean up after tesdt proxy setup

上级 42e40e3b
......@@ -73,7 +73,7 @@ func readLineWithTimeout(b *bufio.Reader, timeout time.Duration) (string, error)
}
func testDashboard(t *testing.T) {
// t.Parallel()
t.Parallel()
minikubeRunner := NewMinikubeRunner(t)
cmd, out := minikubeRunner.RunDaemon("dashboard --url")
defer func() {
......
......@@ -61,26 +61,29 @@ func setUpProxy(t *testing.T) (*http.Server, error) {
}
func TestProxy(t *testing.T) {
origHP := os.Getenv("HTTP_PROXY")
origNP := os.Getenv("NO_PROXY")
srv, err := setUpProxy(t)
defer func(t *testing.T) {
err := srv.Shutdown(context.TODO()) // shutting down the http proxy after tests
if err != nil {
t.Fatalf("Failed to set up the test proxy: %s", err)
}
defer func(t *testing.T) { // Clean up after setting up proxy
err = os.Setenv("HTTP_PROXY", origHP)
if err != nil {
t.Errorf("Error shutting down the http proxy")
t.Errorf("Error reverting the HTTP_PROXY env")
}
err = os.Setenv("HTTP_PROXY", "")
err = os.Setenv("NO_PROCY", origNP)
if err != nil {
t.Errorf("Error reverting the HTTP_PROXY env")
}
err = os.Setenv("HTTPS_PROXY", "")
err := srv.Shutdown(context.TODO()) // shutting down the http proxy after tests
if err != nil {
t.Errorf("Error reverting the HTTPS_PROXY env")
t.Errorf("Error shutting down the http proxy")
}
}(t)
if err != nil {
t.Fatalf("Failed to set up the test proxy: %s", err)
}
t.Run("ConsoleWarnning", testProxyWarning)
t.Run("DashboardProxy", testDashboard)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册