예제 #1
0
	g.JustBeforeEach(func() {
		oc.SetOutputDir(exutil.TestContext.OutputDir)

		g.By(fmt.Sprintf("calling oc new-app -f %q", templatePath))
		err := oc.Run("new-app").Args("-f", templatePath).Execute()
		o.Expect(err).NotTo(o.HaveOccurred())

		g.By("expecting the jenkins service get endpoints")
		err = oc.KubeFramework().WaitForAnEndpoint("jenkins")
		o.Expect(err).NotTo(o.HaveOccurred())

		g.By("Getting the jenkins pod name")
		selector, _ := labels.Parse("name=jenkins")
		pods, err := oc.KubeREST().Pods(oc.Namespace()).List(selector, fields.Everything())
		o.Expect(err).NotTo(o.HaveOccurred())
		o.Expect(len(pods.Items)).ToNot(o.BeZero())
		podName = pods.Items[0].Name
	})

	g.Describe("copy by strategy", func() {

		testRsyncFn := func(strategy string) func() {
			return func() {
				g.By(fmt.Sprintf("Calling oc rsync %s %s:/tmp --strategy=%s", sourcePath1, podName, strategy))
				err := oc.Run("rsync").Args(
					sourcePath1,
					fmt.Sprintf("%s:/tmp", podName),
					fmt.Sprintf("--strategy=%s", strategy)).Execute()
				o.Expect(err).NotTo(o.HaveOccurred())

				g.By("Verifying that files are copied to the container")
예제 #2
0
					user.Token = token
					user.Save()

					body := ""
					request, _ = http.NewRequest("GET", "/fake",
						strings.NewReader(body))
					request.Header.Add("Authorization", "Bearer "+token.Hash)
				})

				It("Check if user with token is saved on the database", func() {
					chkUser := models.User{}
					chkUser.IdUser = user.IdUser
					chkUser, err := chkUser.Get()

					Expect(err).To(gomega.BeNil())
					Expect(chkUser).ShouldNot(gomega.BeZero())
				})

				It("Return status code 200", func() {
					serve.Handler.ServeHTTP(recorder, request)
					Expect(recorder.Code).To(gomega.Equal(200))
				})
			})

			Context("With a user who does not exist in the database", func() {

				var user *models.User

				BeforeEach(func() {
					user = gory.Build("userBad").(*models.User)
					token, _ := models.GenerateToken("testOk")
예제 #3
0
				})

				It("Return a status code of 400", func() {
					serve.Handler.ServeHTTP(recorder, request)
					Expect(recorder.Code).To(gomega.Equal(400))
				})

				It("User must not be saved in the database", func() {
					user := gory.Build("userBad").(*models.User)
					userTest := models.User{
						IdUser: user.IdUser,
					}
					userTest, err := userTest.Get()
					errTest := errors.New("not found")
					Expect(err).To(gomega.Equal(errTest))
					Expect(userTest).To(gomega.BeZero())
				})
			})

			Context("With valid JSON", func() {

				BeforeEach(func() {
					body, _ := json.Marshal(gory.Build("userOk"))
					request, _ = http.NewRequest("POST", "/auth/signup",
						bytes.NewReader(body))
				})

				It("Return a status code of 200", func() {
					serve.Handler.ServeHTTP(recorder, request)
					Expect(recorder.Code).To(gomega.Equal(200))
				})
예제 #4
0
			user, err := user.Get()
			Expect(err).To(gomega.BeNil())
			Expect(user.Name).To(gomega.Equal("test"))
			Expect(user.Pass).To(gomega.Equal("1234"))
		})

		It("Delete user with Id", func() {
			user := models.User{
				IdUser: "******",
			}
			err := user.Delete()
			Expect(err).To(gomega.BeNil())
		})

		Context("If user deleted", func() {
			user := models.User{
				IdUser: "******",
			}

			It("We need received zero value for user and error", func() {
				user, err := user.Get()
				errTest := errors.New("not found")
				Expect(err).To(gomega.Equal(errTest))
				Expect(user.Name).To(gomega.BeZero())
				Expect(user.Pass).To(gomega.BeZero())
			})
		})
	})
})