Skip to content

Commit

Permalink
Add tests for build selector paramter.
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaMaciaszek committed Jun 13, 2018
1 parent f8ff09b commit 06dda96
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import javaposse.jobdsl.dsl.JobManagement
import spock.lang.Specification

class BuildParametersContextSpec extends Specification {

static final String DEFAULT_SELECTOR_CLASS = 'hudson.plugins.copyartifact.StatusBuildSelector'
JobManagement jobManagement = Mock(JobManagement)
Item item = Mock(Item)
BuildParametersContext context = new BuildParametersContext(jobManagement, item)
Expand Down Expand Up @@ -1481,4 +1483,28 @@ class BuildParametersContextSpec extends Specification {
then:
thrown(DslScriptException)
}

def 'should add buildSelectorParameter node'() {
when:
context.buildSelectorParam('myParameterName') { description('myDescription') }
then:
context.buildParameterNodes
context.buildParameterNodes.size() == 1
context.buildParameterNodes['myParameterName'].name() == 'hudson.plugins.copyartifact.BuildSelectorParameter'
context.buildParameterNodes['myParameterName'].name.text() == 'myParameterName'
context.buildParameterNodes['myParameterName'].children().size() == 3
context.buildParameterNodes['myParameterName'].description.text() == 'myDescription'
context.buildParameterNodes['myParameterName'].defaultSelector.get(0).attributes().class ==
DEFAULT_SELECTOR_CLASS
}

def 'buildSelectorParameter name should not be null, empty or previously defined'() {
when:
context.stringParam('myParameterName')
context.buildSelectorParam(name) {}
then:
thrown(DslScriptException)
where:
name << [null, '', 'myParameterName']
}
}

0 comments on commit 06dda96

Please sign in to comment.