Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save big-guy/0b3f7dc11467e9e0efbf49d83ea675c8 to your computer and use it in GitHub Desktop.
Save big-guy/0b3f7dc11467e9e0efbf49d83ea675c8 to your computer and use it in GitHub Desktop.
git version control system integration test base
package org.gradle.vcs.git.internal
import org.gradle.integtests.fixtures.AbstractIntegrationSpec
import org.gradle.vcs.fixtures.GitRepository
import org.gradle.vcs.internal.VersionControlSystemFactory
import org.junit.Rule
class GitVersionControlSystemIntegrationTest extends AbstractIntegrationSpec {
@Rule GitRepository repo = new GitRepository(temporaryFolder)
def setup() {
buildFile << """
import ${VersionControlSystemFactory.canonicalName}
import ${DefaultGitVersionControlSpec.canonicalName}
class GitClone extends DefaultTask {
private final VersionControlSystemFactory versionControlSystemFactory
@Input
URI url = project.uri("${repo.url}")
@OutputDirectory
File outputDir = temporaryDir
@javax.inject.Inject
GitClone(VersionControlSystemFactory versionControlSystemFactory) {
this.versionControlSystemFactory = versionControlSystemFactory
}
@TaskAction
void populate() {
def spec = new DefaultGitVersionControlSpec()
spec.url = url
def system = versionControlSystemFactory.create(spec)
def refs = system.getAvailableVersions(spec)
system.populate(outputDir, refs[0], spec)
assert new File(outputDir, "repo/.git").exists()
}
}
task clone(type: GitClone)
"""
}
def "can clone"() {
def source = repo.workTree.file("source")
source.text = "hello world"
repo.commit("initial commit", source)
expect:
succeeds("clone")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment