Skip to content

Commit

Permalink
fix: #1113 verify all tags and not just the first
Browse files Browse the repository at this point in the history
  • Loading branch information
anto committed Jun 10, 2020
1 parent 83cc4c5 commit d162857
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ open class PactBrokerClient(val pactBrokerUrl: String, override val options: Map
if (selectors.isEmpty()) {
fetchConsumers(providerName)
} else {
fetchConsumersWithTag(providerName, selectors.first().tag)
selectors.flatMap { fetchConsumersWithTag(providerName, it.tag) }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,36 @@ class PactBrokerClientSpec extends Specification {
consumers.first().source == 'http://bob.com/'
}

def 'fetches consumers with more than one tag successfully'() {
given:
def halClient = Mock(IHalClient)
halClient.navigate() >> halClient
halClient.navigate(_, _) >> halClient
halClient.forAll(_, _) >> { args -> args[1].accept([name: 'bob', href: 'http://bob.com/']) }

def client = Spy(PactBrokerClient, constructorArgs: ['http://pactBrokerUrl']) {
newHalClient() >> halClient
}

when:
def consumers = client.fetchConsumersWithSelectors('provider',
[ new ConsumerVersionSelector('tag', true),
new ConsumerVersionSelector('anotherTag', true) ], [], false).value

then:
consumers.size() == 2

consumers.first()
consumers.first().name == 'bob'
consumers.first().source == 'http://bob.com/'
consumers.first().tag == 'tag'

consumers.last()
consumers.last().name == 'bob'
consumers.last().source == 'http://bob.com/'
consumers.last().tag == 'anotherTag'
}

def 'when fetching consumers with specified tag, sets the auth if there is any'() {
given:
def halClient = Mock(IHalClient)
Expand Down

0 comments on commit d162857

Please sign in to comment.