Skip to content
This repository has been archived by the owner on Feb 7, 2021. It is now read-only.

Commit

Permalink
Added integration tests for NebulaBintrayVersionTask
Browse files Browse the repository at this point in the history
  • Loading branch information
rpalcolea committed Mar 26, 2019
1 parent 3d8ad8a commit bc5810b
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ open class NebulaBintrayPackageTask : NebulaBintrayAbstractTask() {
)

bintrayClient.createOrUpdatePackage(resolvedSubject, repo.get(), pkgName.get(), packageRequest)
logger.info("Package ${pkgName.get()} has been created/updated")
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 Netflix, Inc.
* Copyright 2019 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,7 +32,7 @@ class NebulaBintrayPublishingPluginIntegrationSpec extends LauncherSpec {
apply plugin: 'java'
group = 'test.nebula.netflix'
version = '1.0'
version = '1.0.0'
bintray {
user = 'nebula-plugins'
Expand All @@ -52,6 +52,47 @@ class NebulaBintrayPublishingPluginIntegrationSpec extends LauncherSpec {
result.standardOutput.contains('Task :publishPackageToBintray')
}

def 'publishes package to bintray'() {
given:
stubFor(get(urlEqualTo("/packages/nebula/gradle-plugins/my-plugin"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")))

stubFor(put(urlEqualTo("/packages/nebula/gradle-plugins"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")))



buildFile << """
apply plugin: 'nebula.nebula-bintray'
apply plugin: 'java'
group = 'test.nebula.netflix'
version = '1.0.0'
description = 'my plugin'
bintray {
user = 'nebula-plugins'
apiKey = 'mykey'
apiUrl = 'http://localhost:${wireMockRule.port()}'
pkgName = 'my-plugin'
autoPublish = true
}
"""

writeHelloWorld()

when:
def result = runTasks('publishPackageToBintray')

then:
result.standardOutput.contains('ackage my-plugin has been created/updated')
}

def 'build fails if bad response from bintray when getting package information'() {
given:
stubFor(get(urlEqualTo("/packages/nebula/gradle-plugins/my-plugin"))
Expand All @@ -65,7 +106,7 @@ class NebulaBintrayPublishingPluginIntegrationSpec extends LauncherSpec {
apply plugin: 'java'
group = 'test.nebula.netflix'
version = '1.0'
version = '1.0.0'
description = 'my plugin'
bintray {
Expand Down Expand Up @@ -108,7 +149,7 @@ class NebulaBintrayPublishingPluginIntegrationSpec extends LauncherSpec {
apply plugin: 'java'
group = 'test.nebula.netflix'
version = '1.0'
version = '1.0.0'
description = 'my plugin'
bintray {
Expand Down Expand Up @@ -151,7 +192,7 @@ class NebulaBintrayPublishingPluginIntegrationSpec extends LauncherSpec {
apply plugin: 'java'
group = 'test.nebula.netflix'
version = '1.0'
version = '1.0.0'
description = 'my plugin'
bintray {
Expand All @@ -173,4 +214,74 @@ class NebulaBintrayPublishingPluginIntegrationSpec extends LauncherSpec {
result.standardError.contains('Could not create or update information for package gradle-plugins/nebula/my-plugin ')
}

def 'publishes version to bintray'() {
given:
stubFor(post(urlEqualTo("/content/nebula/gradle-plugins/my-plugin/1.0.0/publish"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")))


buildFile << """
apply plugin: 'nebula.nebula-bintray'
apply plugin: 'java'
group = 'test.nebula.netflix'
version = '1.0.0'
description = 'my plugin'
bintray {
user = 'nebula-plugins'
apiKey = 'mykey'
apiUrl = 'http://localhost:${wireMockRule.port()}'
pkgName = 'my-plugin'
autoPublish = true
}
"""

writeHelloWorld()

when:
def result = runTasks('publishVersionToBintray')

then:
result.standardOutput.contains('my-plugin version 1.0.0 has been published')
}

def 'publishes version to bintray fails if version already exists'() {
given:
stubFor(post(urlEqualTo("/content/nebula/gradle-plugins/my-plugin/1.0.0/publish"))
.willReturn(aResponse()
.withStatus(400)
.withHeader("Content-Type", "application/json")))


buildFile << """
apply plugin: 'nebula.nebula-bintray'
apply plugin: 'java'
group = 'test.nebula.netflix'
version = '1.0.0'
description = 'my plugin'
bintray {
user = 'nebula-plugins'
apiKey = 'mykey'
apiUrl = 'http://localhost:${wireMockRule.port()}'
pkgName = 'my-plugin'
autoPublish = true
}
"""

writeHelloWorld()

when:
def result = runTasks('publishVersionToBintray')

then:
result.standardError.contains('Could not publish 1.0.0 version for package gradle-plugins/nebula/my-plugin')
}

}

0 comments on commit bc5810b

Please sign in to comment.