Пример #1
0
			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()
Пример #2
0
)

var _ = Describe("Or Predicate Builder Tests", func() {
	Describe("When building a Predicate of type \"Or\"", func() {

		var (
			actualPredicateAsMap map[string]interface{}
			predicate1           = predicates.Equals().Build()
			predicate2           = predicates.Contains().Build()
			predicate3           = predicates.Equals().Build()

			once sync.Once
		)
		BeforeEach(func() {
			once.Do(func() {
				actualPredicate := predicates.Or().Predicates(predicate1, predicate2, predicate3).Build()

				jsonBytes, _ := json.Marshal(actualPredicate)

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

			})
		})

		It("should create an \"Or\" Predicate", func() {
			Expect(actualPredicateAsMap).To(HaveKey("or"))
		})

		It("should have list of predicates", func() {
			orPredicate := actualPredicateAsMap["or"]