-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #482 from rundeck/enh/proj-archive-component-options
RUN-1348: Add component options to project archives import
- Loading branch information
Showing
3 changed files
with
131 additions
and
5 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
80 changes: 80 additions & 0 deletions
80
rd-cli-tool/src/test/groovy/org/rundeck/client/tool/commands/projects/ArchivesSpec.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,80 @@ | ||
package org.rundeck.client.tool.commands.projects | ||
|
||
import groovy.transform.CompileStatic | ||
import okhttp3.ResponseBody | ||
import org.rundeck.client.api.RundeckApi | ||
import org.rundeck.client.api.model.ProjectImportStatus | ||
import org.rundeck.client.tool.CommandOutput | ||
import org.rundeck.client.tool.RdApp | ||
import org.rundeck.client.tool.commands.RdToolImpl | ||
import org.rundeck.client.tool.options.ProjectRequiredNameOptions | ||
import org.rundeck.client.util.Client | ||
import org.rundeck.client.util.RdClientConfig | ||
import retrofit2.Response | ||
import retrofit2.Retrofit | ||
import retrofit2.converter.jackson.JacksonConverterFactory | ||
import retrofit2.mock.Calls | ||
import spock.lang.Specification | ||
|
||
class ArchivesSpec extends Specification { | ||
File tempFile | ||
|
||
def setup() { | ||
tempFile = File.createTempFile('ArchivesSpec-test', 'zip') | ||
} | ||
|
||
def cleanup() { | ||
if (tempFile.exists()) { | ||
tempFile.delete() | ||
} | ||
} | ||
|
||
def "import component options set in url"() { | ||
|
||
def api = Mock(RundeckApi) | ||
|
||
def retrofit = new Retrofit.Builder() | ||
.addConverterFactory(JacksonConverterFactory.create()) | ||
.baseUrl('http://example.com/fake/').build() | ||
def out = Mock(CommandOutput) | ||
def client = new Client(api, retrofit, null, null, 18, true, null) | ||
|
||
def rdapp = Mock(RdApp) { | ||
getClient() >> client | ||
getAppConfig() >> Mock(RdClientConfig) | ||
} | ||
def rdTool = new RdToolImpl(rdapp) | ||
|
||
def sut = new Archives() | ||
sut.rdOutput = out | ||
sut.rdTool = rdTool | ||
def opts = new Archives.ArchiveImportOpts() | ||
opts.components = ['test-comp'].toSet() | ||
opts.componentOptions = ['test-comp.key': 'value'] | ||
opts.file = tempFile | ||
opts.project = 'Aproj' | ||
|
||
|
||
when: | ||
def result = sut.importArchive(opts) | ||
|
||
then: | ||
1 * api.importProjectArchive( | ||
'Aproj', | ||
_, | ||
_, | ||
_, | ||
_, | ||
_, | ||
_, | ||
_, | ||
_, | ||
[ | ||
'importComponents.test-comp': 'true', | ||
'importOpts.test-comp.key' : 'value', | ||
], | ||
_ | ||
) >> Calls.response(new ProjectImportStatus()) | ||
0 * api._(*_) | ||
} | ||
} |