Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #1113 verify all tags and not just the first #1116

Merged
merged 6 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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