Skip to content

Commit

Permalink
[#26] Improved Git task tests and added checks for applied options.
Browse files Browse the repository at this point in the history
  • Loading branch information
lreimer committed Aug 5, 2016
1 parent d4b5be0 commit e15999a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,24 @@ class GitCloneTaskSpec extends Specification {
}

def "Define GitCloneTask"() {
given:
def options = new GitCloneOptions()

expect: "the clone task to be undefined"
that project.tasks.findByName(TEST_GIT_CLONE), is(nullValue())

when: "we defined and configure the clone task"
project.task(TEST_GIT_CLONE, type: GitCloneTask) {
def task = (GitCloneTask) project.task(TEST_GIT_CLONE, type: GitCloneTask) {
url = "https://github.com/qaware/QAseuac.git"
directory = this.directory
branch = 'TEST'
username = 'user'
password = 'secret'
}
task.applyOptions(options)
task = (GitCloneTask) project.tasks.findByName(TEST_GIT_CLONE)

then: "we expect to find the task correctly configured"
GitCloneTask task = project.tasks.findByName(TEST_GIT_CLONE)

expect task, notNullValue()
expect task.group, equalTo('Version Control')
Expand All @@ -66,6 +70,12 @@ class GitCloneTaskSpec extends Specification {
expect task.username, equalTo('user')
expect task.password, equalTo('secret')
expect task.directory, notNullValue()

task.singleBranch == options.singleBranch
task.cloneAllBranches == options.cloneAllBranches
task.cloneSubmodules == options.cloneSubmodules
task.noCheckout == options.noCheckout
task.timeout == options.timeout
}

def "Invoke doClone"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class GitCommitTaskSpec extends Specification {
password = 'secret'
}
task.applyOptions(options)

task = (GitCommitTask) project.tasks.findByName(TEST_GIT_COMMIT)

then: "the we expect to find the task to be correctly configured"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,33 @@ class GitPullTaskSpec extends Specification {
}

def "Define GitPullTask"() {
given:
def options = new GitPullOptions()

expect: "the pull task to be undefined"
that project.tasks.findByName(TEST_GIT_PULL), is(nullValue())

when: "we we defined and configure the task"
project.task(TEST_GIT_PULL, type: GitPullTask) {
def task = (GitPullTask) project.task(TEST_GIT_PULL, type: GitPullTask) {
directory = this.directory
username = 'user'
password = 'secret'
remote = 'test'
}
task.applyOptions(options)
task = (GitPullTask) project.tasks.findByName(TEST_GIT_PULL)

then: "we expect to find the task correctly configured"
GitPullTask task = project.tasks.findByName(TEST_GIT_PULL)

expect task, notNullValue()
expect task.group, equalTo('Version Control')
expect task.remote, equalTo('test')
expect task.username, equalTo('user')
expect task.password, equalTo('secret')
expect task.directory, notNullValue()

task.rebase == options.rebase
task.timeout == options.timeout
}

def "Invoke doPull"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,36 @@ class GitPushTaskSpec extends Specification {
}

def "Define GitPushTask"() {
given:
def options = new GitPushOptions()

expect: "the push task to be undefined"
that project.tasks.findByName(TEST_GIT_PUSH), is(nullValue())

when: "we define and configure the task for the project"
project.task(TEST_GIT_PUSH, type: GitPushTask) {
def task = (GitPushTask) project.task(TEST_GIT_PUSH, type: GitPushTask) {
directory = this.directory
username = 'user'
password = 'secret'
remote = 'test'
}
task.applyOptions(options)
task = (GitPushTask) project.tasks.findByName(TEST_GIT_PUSH)

then: "we expect to find the task correctly configured"
GitPushTask task = project.tasks.findByName(TEST_GIT_PUSH)

expect task, notNullValue()
expect task.group, equalTo('Version Control')
expect task.remote, equalTo('test')
expect task.username, equalTo('user')
expect task.password, equalTo('secret')
expect task.directory, notNullValue()

task.force == options.force
task.dryRun == options.dryRun
task.pushAll == options.pushAll
task.pushTags == options.pushTags
task.timeout == options.timeout
}

def "Invoke doPush"() {
Expand Down

0 comments on commit e15999a

Please sign in to comment.