Skip to content

Commit

Permalink
Add test for resolution with dependency locking
Browse files Browse the repository at this point in the history
  • Loading branch information
bigdaz committed Apr 6, 2024
1 parent dc07592 commit 3559192
Showing 1 changed file with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.gradle.github.dependencygraph

import org.gradle.test.fixtures.PluginPublisher
import org.gradle.test.fixtures.maven.MavenModule
import spock.lang.IgnoreIf

class DependencyLockingDependencyExtractorTest extends BaseExtractorTest {
private MavenModule foo
private MavenModule bar
private MavenModule baz
private File settingsFile
private File buildFile

def setup() {
establishEnvironmentVariables()

foo = mavenRepo.module("org.test", "foo", "1.0").publish()

settingsFile = file("settings.gradle") << """
rootProject.name = 'a'
"""

buildFile = file("build.gradle") << """
apply plugin: 'java'
repositories {
maven { url "${mavenRepo.uri}" }
}
"""
}

def "extracts dependencies when dependency locking is enabled"() {
given:
buildFile << """
dependencies {
implementation "org.test:foo:+"
}
dependencyLocking {
lockAllConfigurations()
lockMode = LockMode.STRICT
}
"""

// Write dependency lock file
run("dependencies", "--write-locks")
mavenRepo.module("org.test", "foo", "1.1").publish()

when:
applyDependencyGraphPlugin()
run()

then:
def manifest = gitHubManifest()
manifest.sourceFile == "settings.gradle"

manifest.assertResolved([
"org.test:foo:1.0": [
package_url: purlFor(foo)
]
])
}
}

0 comments on commit 3559192

Please sign in to comment.