Ejemplo n.º 1
0
			protocol         = "http"
			port             = 4546
			createdImposter  map[string]interface{}
			expectedImposter gobank.ImposterElement
			err              error

			once sync.Once
		)

		BeforeEach(func() {
			once.Do(func() {
				okResponse := responses.Is().StatusCode(200).Body("{ \"greeting\": \"Hello GoBank\" }").Build()

				equals := predicates.Equals().Path("/test-path").Build()
				contains := predicates.Contains().Header("Accept", "application/json").Build()
				exists := predicates.Exists().Method(true).Query("q", false).Body(false).Build()
				or := predicates.Or().Predicates(equals, contains, exists).Build()

				stub := gobank.Stub().Responses(okResponse).Predicates(or).Build()

				expectedImposter = gobank.NewImposterBuilder().Protocol(protocol).Port(port).Name("Greeting Imposter").Stubs(stub).Build()

				client := gobank.NewClient(MountebankUri)
				createdImposter, err = client.CreateImposter(expectedImposter)
				log.Println("ActualImposter: ", createdImposter)
			})
		})

		It("should have the Imposter installed on Mountebank", func() {
			imposterUri := MountebankUri + "/imposters/" + strconv.Itoa(port)
			resp, body, _ := gorequest.New().Get(imposterUri).End()
Ejemplo n.º 2
0
			expectedPath             = true
			expectedHeader           = "Accept"
			expectedHeaderValue      = true
			expectedBody             = false
			expectedQueryParam1      = "q"
			expectedQueryParamValue1 = true
			expectedQueryParam2      = "search"
			expectedQueryParamValue2 = false

			once sync.Once
		)

		BeforeEach(func() {
			once.Do(func() {
				actualPredicate := predicates.Exists().
					Path(expectedPath).
					Header(expectedHeader, expectedHeaderValue).
					Query(expectedQueryParam1, expectedQueryParamValue1).
					Query(expectedQueryParam2, expectedQueryParamValue2).
					Body(expectedBody).
					Build()
				log.Println(actualPredicate, "******************")
				jsonBytes, _ := json.Marshal(actualPredicate)

				actualPredicateAsMap = map[string]interface{}{}
				json.Unmarshal(jsonBytes, &actualPredicateAsMap)
				log.Println(actualPredicateAsMap, "***************")
			})
		})