-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Core locking: verify offline resolution behavior
- Loading branch information
1 parent
d926292
commit e42a7a3
Showing
3 changed files
with
75 additions
and
0 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
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
67 changes: 67 additions & 0 deletions
67
src/test/groovy/nebula/plugin/dependencylock/caching/OfflineModeSpec.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,67 @@ | ||
/** | ||
* | ||
* 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package nebula.plugin.dependencylock.caching | ||
|
||
import com.github.tomakehurst.wiremock.client.WireMock | ||
import com.github.tomakehurst.wiremock.stubbing.ServeEvent | ||
|
||
class OfflineModeSpec extends AbstractCachingAndCoreLockingSpec { | ||
private static final String OFFLINE_MODE_NOTIFICATION = 'offline mode enabled. Using cached dependencies' | ||
|
||
def setup() { | ||
buildFile << """ | ||
dependencies { | ||
implementation 'test.offlineMode:z-$uniqueId:latest.release' | ||
} | ||
""".stripIndent() | ||
} | ||
|
||
def 'offline mode with core locking uses cached dependencies'() { | ||
given: | ||
setupBaseDependencyAndMockedResponses(uniqueId, "offlineMode") | ||
|
||
when: | ||
def result = runTasks('dependencies', '--write-locks', '--configuration', 'compileClasspath') | ||
|
||
then: | ||
result.output.contains("test.offlineMode:z-$uniqueId:latest.release -> 1.0.0") | ||
result.output.contains("\\--- test.nebula:a-$uniqueId:1.0.0") | ||
!result.output.contains(OFFLINE_MODE_NOTIFICATION) | ||
|
||
def lockFile = new File(projectDir, 'gradle/dependency-locks/compileClasspath.lockfile') | ||
lockFile.exists() | ||
|
||
List<ServeEvent> allServeEvents = WireMock.getAllServeEvents() | ||
WireMock.verify(WireMock.exactly(1), WireMock.getRequestedFor(WireMock.urlEqualTo("/${parseGroup('test.offlineMode')}/z-${uniqueId}/maven-metadata.xml"))) | ||
WireMock.verify(WireMock.exactly(1), WireMock.getRequestedFor(WireMock.urlEqualTo('/' + filePathFor('test.offlineMode', "z-$uniqueId", '1.0.0', 'pom')))) | ||
WireMock.verify(WireMock.exactly(1), WireMock.getRequestedFor(WireMock.urlEqualTo('/' + filePathFor('test.nebula', "a-$uniqueId", '1.0.0', 'pom')))) | ||
assert allServeEvents.size() == 3 | ||
|
||
when: | ||
def offlineResults = runTasks('dependencies', '--configuration', 'compileClasspath', '--offline') | ||
|
||
then: | ||
offlineResults.output.contains("test.offlineMode:z-$uniqueId:latest.release -> 1.0.0") | ||
offlineResults.output.contains("\\--- test.nebula:a-$uniqueId:1.0.0") | ||
offlineResults.output.contains(OFFLINE_MODE_NOTIFICATION) | ||
|
||
List<ServeEvent> allServeEventsUpdated = WireMock.getAllServeEvents() | ||
assert allServeEventsUpdated.size() == 3 // there are no new events because offline mode used the cache | ||
} | ||
} |