Browse Source

Optimize tests

Volodymyr Tkach 2 years ago
parent
commit
93e5221241
1 changed files with 7 additions and 36 deletions
  1. 7 36
      utils/http/servauth/servauth_test.go

+ 7 - 36
utils/http/servauth/servauth_test.go

@@ -118,43 +118,14 @@ var _ = Describe("servauth", func() {
 			Expect(err).To(Succeed())
 			Expect(err).To(Succeed())
 			req.SetBasicAuth("user", "wrong")
 			req.SetBasicAuth("user", "wrong")
 
 
-			// 1
-			resp, err := client.Do(req)
-			Expect(err).To(Succeed())
-			defer resp.Body.Close()
-
-			Expect(resp.StatusCode).To(Equal(http.StatusUnauthorized))
-
-			// 2
-			resp, err = client.Do(req)
-			Expect(err).To(Succeed())
-			defer resp.Body.Close()
-
-			Expect(resp.StatusCode).To(Equal(http.StatusUnauthorized))
-
-			// 3
-			resp, err = client.Do(req)
-			Expect(err).To(Succeed())
-			defer resp.Body.Close()
+			for i := 1; i <= 5; i++ {
+				resp, err := client.Do(req)
+				Expect(err).To(Succeed())
+				Expect(resp.Body.Close())
+				Expect(resp.StatusCode).To(Equal(http.StatusUnauthorized))
+			}
 
 
-			Expect(resp.StatusCode).To(Equal(http.StatusUnauthorized))
-
-			// 4
-			resp, err = client.Do(req)
-			Expect(err).To(Succeed())
-			defer resp.Body.Close()
-
-			Expect(resp.StatusCode).To(Equal(http.StatusUnauthorized))
-
-			// 5
-			resp, err = client.Do(req)
-			Expect(err).To(Succeed())
-			defer resp.Body.Close()
-
-			Expect(resp.StatusCode).To(Equal(http.StatusUnauthorized))
-
-			// 6
-			resp, err = client.Do(req)
+			resp, err := client.Do(req)
 			Expect(err).To(Succeed())
 			Expect(err).To(Succeed())
 			defer resp.Body.Close()
 			defer resp.Body.Close()