@@ -1518,7 +1518,7 @@ func TestDeployCreate_AskQuestions(t *testing.T) {
15181518 }, options )
15191519 }},
15201520
1521- {"target tags with specific and excluded tags" , func (t * testing.T , api * testutil.MockHttpServer , qa * testutil.AskMocker , stdout * bytes.Buffer ) {
1521+ {"target tags with specific tags selected " , func (t * testing.T , api * testutil.MockHttpServer , qa * testutil.AskMocker , stdout * bytes.Buffer ) {
15221522 options := & executor.TaskOptionsDeployRelease {
15231523 ProjectName : "fire project" ,
15241524 ReleaseVersion : "1.9" ,
@@ -1574,6 +1574,83 @@ func TestDeployCreate_AskQuestions(t *testing.T) {
15741574 Options : []string {"Environment/Production" , "Environment/Staging" , "Role/Database" , "Role/Legacy" , "Role/WebServer" },
15751575 }).AnswerWith ([]string {"Role/WebServer" , "Environment/Production" })
15761576
1577+ err := <- errReceiver
1578+ assert .Nil (t , err )
1579+
1580+ // check that the question-asking process has filled out the things we told it to
1581+ assert .Equal (t , & executor.TaskOptionsDeployRelease {
1582+ ProjectName : "Fire Project" ,
1583+ ReleaseVersion : "1.9" ,
1584+ Environments : []string {"dev" },
1585+ GuidedFailureMode : "false" ,
1586+ ForcePackageDownload : false ,
1587+ ForcePackageDownloadWasSpecified : true ,
1588+ Variables : make (map [string ]string , 0 ),
1589+ ExcludedSteps : []string {"Cleanup" },
1590+ DeploymentTargets : []string {"vm-1" },
1591+ SpecificTargetTagNames : []string {"Role/WebServer" , "Environment/Production" },
1592+ ExcludedTargetTagNames : nil ,
1593+ ReleaseID : release19 .ID ,
1594+ ScheduledStartTime : "now" ,
1595+ }, options )
1596+ }},
1597+
1598+ {"target tags with excluded tags selected" , func (t * testing.T , api * testutil.MockHttpServer , qa * testutil.AskMocker , stdout * bytes.Buffer ) {
1599+ options := & executor.TaskOptionsDeployRelease {
1600+ ProjectName : "fire project" ,
1601+ ReleaseVersion : "1.9" ,
1602+ Environments : []string {"dev" },
1603+ ExcludedSteps : []string {"Cleanup" },
1604+ GuidedFailureMode : "false" ,
1605+ ForcePackageDownloadWasSpecified : true ,
1606+ DeploymentTargets : []string {"vm-1" },
1607+ ScheduledStartTime : "now" ,
1608+ }
1609+
1610+ errReceiver := testutil .GoBegin (func () error {
1611+ defer testutil .Close (api , qa )
1612+ octopus , _ := octopusApiClient .NewClient (testutil .NewMockHttpClientWithTransport (api ), serverUrl , placeholderApiKey , "" )
1613+ return deploy .AskQuestions (octopus , stdout , qa .AsAsker (), space1 , options , now )
1614+ })
1615+
1616+ doStandardApiResponses (options , api , release19 , variableSnapshotNoVars )
1617+ stdout .Reset ()
1618+
1619+ _ = qa .ExpectQuestion (t , & survey.Select {
1620+ Message : "Change additional options?" ,
1621+ Options : []string {"Proceed to deploy" , "Change" },
1622+ }).AnswerWith ("Change" )
1623+ stdout .Reset ()
1624+
1625+ api .ExpectRequest (t , "GET" , fmt .Sprintf ("/api/Spaces-1/releases/%s/deployments/preview/%s?includeDisabledSteps=true" , release19 .ID , devEnvironment .ID )).RespondWith (& deployments.DeploymentPreview {
1626+ StepsToExecute : []* deployments.DeploymentTemplateStep {
1627+ {
1628+ AvailableTagSets : []* deployments.TagSetPreview {
1629+ {
1630+ TagSetName : "Role" ,
1631+ AvailableTags : []* deployments.TargetTagPreview {
1632+ {TagName : "WebServer" },
1633+ {TagName : "Database" },
1634+ {TagName : "Legacy" },
1635+ },
1636+ },
1637+ {
1638+ TagSetName : "Environment" ,
1639+ AvailableTags : []* deployments.TargetTagPreview {
1640+ {TagName : "Production" },
1641+ {TagName : "Staging" },
1642+ },
1643+ },
1644+ },
1645+ },
1646+ },
1647+ })
1648+
1649+ _ = qa .ExpectQuestion (t , & survey.MultiSelect {
1650+ Message : "Specific target tags to include (If none selected, include all)" ,
1651+ Options : []string {"Environment/Production" , "Environment/Staging" , "Role/Database" , "Role/Legacy" , "Role/WebServer" },
1652+ }).AnswerWith ([]string {}) // Selecting no specific tags to allow testing excluded tags
1653+
15771654 _ = qa .ExpectQuestion (t , & survey.MultiSelect {
15781655 Message : "Target tags to exclude (If none selected, exclude none)" ,
15791656 Options : []string {"Environment/Production" , "Environment/Staging" , "Role/Database" , "Role/Legacy" , "Role/WebServer" },
@@ -1593,7 +1670,7 @@ func TestDeployCreate_AskQuestions(t *testing.T) {
15931670 Variables : make (map [string ]string , 0 ),
15941671 ExcludedSteps : []string {"Cleanup" },
15951672 DeploymentTargets : []string {"vm-1" },
1596- SpecificTargetTagNames : [] string { "Role/WebServer" , "Environment/Production" } ,
1673+ SpecificTargetTagNames : nil ,
15971674 ExcludedTargetTagNames : []string {"Role/Legacy" },
15981675 ReleaseID : release19 .ID ,
15991676 ScheduledStartTime : "now" ,
0 commit comments