-
-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Implement new Gradle DSL for consumer version selectors
- Loading branch information
Showing
12 changed files
with
593 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...oker/src/test/groovy/au/com/dius/pact/core/pactbroker/ConsumerVersionSelectorsSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package au.com.dius.pact.core.pactbroker | ||
|
||
import spock.lang.Specification | ||
import spock.lang.Unroll | ||
|
||
@SuppressWarnings('LineLength') | ||
class ConsumerVersionSelectorsSpec extends Specification { | ||
@Unroll | ||
def 'convert to JSON'() { | ||
expect: | ||
selector.toJson().serialise() == json | ||
|
||
where: | ||
|
||
selector | json | ||
ConsumerVersionSelectors.MainBranch.INSTANCE | '{"mainBranch":true}' | ||
new ConsumerVersionSelectors.Branch('<branch>') | '{"branch":"<branch>"}' | ||
ConsumerVersionSelectors.DeployedOrReleased.INSTANCE | '{"deployedOrReleased":true}' | ||
ConsumerVersionSelectors.MatchingBranch.INSTANCE | '{"matchingBranch":true}' | ||
new ConsumerVersionSelectors.Branch('<branch>', '<consumer>') | '{"branch":"<branch>","consumer":"<consumer>"}' | ||
new ConsumerVersionSelectors.Branch('<branch>', null, '<fbranch>') | '{"branch":"<branch>","fallbackBranch":"<fbranch>"}' | ||
new ConsumerVersionSelectors.DeployedTo('<environment>') | '{"deployed":true,"environment":"<environment>"}' | ||
new ConsumerVersionSelectors.ReleasedTo('<environment>') | '{"environment":"<environment>","released":true}' | ||
new ConsumerVersionSelectors.Environment('<environment>') | '{"environment":"<environment>"}' | ||
new ConsumerVersionSelectors.Tag('<tag>') | '{"tag":"<tag>"}' | ||
new ConsumerVersionSelectors.LatestTag('<tag>') | '{"latest":true,"tag":"<tag>"}' | ||
new ConsumerVersionSelectors.LatestTag('<tag>', '<fallback>') | '{"fallbackTag":"<fallback>","latest":true,"tag":"<tag>"}' | ||
new ConsumerVersionSelectors.Selector('<tag>') | '{"tag":"<tag>"}' | ||
new ConsumerVersionSelectors.Selector('<tag>', true) | '{"latest":true,"tag":"<tag>"}' | ||
new ConsumerVersionSelectors.Selector('<tag>', false) | '{"latest":false,"tag":"<tag>"}' | ||
new ConsumerVersionSelectors.Selector('<tag>', true, null, '<fallback>') | '{"fallbackTag":"<fallback>","latest":true,"tag":"<tag>"}' | ||
new ConsumerVersionSelectors.Selector('<tag>', true, '<consumer>') | '{"consumer":"<consumer>","latest":true,"tag":"<tag>"}' | ||
new ConsumerVersionSelectors.Selector(null, true) | '{"latest":true}' | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/GradleConsumerInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package au.com.dius.pact.provider.gradle | ||
|
||
import au.com.dius.pact.core.model.Consumer | ||
import au.com.dius.pact.core.pactbroker.VerificationNotice | ||
import au.com.dius.pact.core.support.Auth | ||
import au.com.dius.pact.provider.ConsumerInfo | ||
import au.com.dius.pact.provider.IConsumerInfo | ||
import au.com.dius.pact.provider.PactVerification | ||
import javax.inject.Inject | ||
|
||
open class GradleConsumerInfo( | ||
override var name: String, | ||
override var stateChange: Any? = null, | ||
override var stateChangeUsesBody: Boolean = false, | ||
override var packagesToScan: List<String> = emptyList(), | ||
override var verificationType: PactVerification? = null, | ||
override var pactSource: Any? = null, | ||
override var pactFileAuthentication: List<Any?> = emptyList(), | ||
override val notices: List<VerificationNotice> = mutableListOf(), | ||
override val pending: Boolean = false, | ||
override val wip: Boolean = false, | ||
override val auth: Auth? = null | ||
) : IConsumerInfo { | ||
@Inject | ||
constructor(name: String): this(name, null, false, emptyList(), null, null, emptyList()) | ||
|
||
override fun toPactConsumer() = Consumer(name) | ||
|
||
override fun resolvePactSource() = ConsumerInfo.resolvePactSource(pactSource) | ||
} |
Oops, something went wrong.