@@ -1517,6 +1517,88 @@ func TestDeployCreate_AskQuestions(t *testing.T) {
15171517 ScheduledExpiryTime : "2022-09-08T13:31:03+08:00" ,
15181518 }, options )
15191519 }},
1520+
1521+ {"target tags with specific and excluded tags" , func (t * testing.T , api * testutil.MockHttpServer , qa * testutil.AskMocker , stdout * bytes.Buffer ) {
1522+ options := & executor.TaskOptionsDeployRelease {
1523+ ProjectName : "fire project" ,
1524+ ReleaseVersion : "1.9" ,
1525+ Environments : []string {"dev" },
1526+ ExcludedSteps : []string {"Cleanup" },
1527+ GuidedFailureMode : "false" ,
1528+ ForcePackageDownloadWasSpecified : true ,
1529+ DeploymentTargets : []string {"vm-1" },
1530+ ScheduledStartTime : "now" ,
1531+ }
1532+
1533+ errReceiver := testutil .GoBegin (func () error {
1534+ defer testutil .Close (api , qa )
1535+ octopus , _ := octopusApiClient .NewClient (testutil .NewMockHttpClientWithTransport (api ), serverUrl , placeholderApiKey , "" )
1536+ return deploy .AskQuestions (octopus , stdout , qa .AsAsker (), space1 , options , now )
1537+ })
1538+
1539+ doStandardApiResponses (options , api , release19 , variableSnapshotNoVars )
1540+ stdout .Reset ()
1541+
1542+ _ = qa .ExpectQuestion (t , & survey.Select {
1543+ Message : "Change additional options?" ,
1544+ Options : []string {"Proceed to deploy" , "Change" },
1545+ }).AnswerWith ("Change" )
1546+ stdout .Reset ()
1547+
1548+ api .ExpectRequest (t , "GET" , fmt .Sprintf ("/api/Spaces-1/releases/%s/deployments/preview/%s?includeDisabledSteps=true" , release19 .ID , devEnvironment .ID )).RespondWith (& deployments.DeploymentPreview {
1549+ StepsToExecute : []* deployments.DeploymentTemplateStep {
1550+ {
1551+ AvailableTagSets : []* deployments.TagSetPreview {
1552+ {
1553+ TagSetName : "Role" ,
1554+ AvailableTags : []* deployments.TargetTagPreview {
1555+ {TagName : "WebServer" },
1556+ {TagName : "Database" },
1557+ {TagName : "Legacy" },
1558+ },
1559+ },
1560+ {
1561+ TagSetName : "Environment" ,
1562+ AvailableTags : []* deployments.TargetTagPreview {
1563+ {TagName : "Production" },
1564+ {TagName : "Staging" },
1565+ },
1566+ },
1567+ },
1568+ },
1569+ },
1570+ })
1571+
1572+ _ = qa .ExpectQuestion (t , & survey.MultiSelect {
1573+ Message : "Specific target tags to include (If none selected, include all)" ,
1574+ Options : []string {"Environment/Production" , "Environment/Staging" , "Role/Database" , "Role/Legacy" , "Role/WebServer" },
1575+ }).AnswerWith ([]string {"Role/WebServer" , "Environment/Production" })
1576+
1577+ _ = qa .ExpectQuestion (t , & survey.MultiSelect {
1578+ Message : "Target tags to exclude (If none selected, exclude none)" ,
1579+ Options : []string {"Environment/Production" , "Environment/Staging" , "Role/Database" , "Role/Legacy" , "Role/WebServer" },
1580+ }).AnswerWith ([]string {"Role/Legacy" })
1581+
1582+ err := <- errReceiver
1583+ assert .Nil (t , err )
1584+
1585+ // check that the question-asking process has filled out the things we told it to
1586+ assert .Equal (t , & executor.TaskOptionsDeployRelease {
1587+ ProjectName : "Fire Project" ,
1588+ ReleaseVersion : "1.9" ,
1589+ Environments : []string {"dev" },
1590+ GuidedFailureMode : "false" ,
1591+ ForcePackageDownload : false ,
1592+ ForcePackageDownloadWasSpecified : true ,
1593+ Variables : make (map [string ]string , 0 ),
1594+ ExcludedSteps : []string {"Cleanup" },
1595+ DeploymentTargets : []string {"vm-1" },
1596+ SpecificTargetTagNames : []string {"Role/WebServer" , "Environment/Production" },
1597+ ExcludedTargetTagNames : []string {"Role/Legacy" },
1598+ ReleaseID : release19 .ID ,
1599+ ScheduledStartTime : "now" ,
1600+ }, options )
1601+ }},
15201602 }
15211603
15221604 for _ , test := range tests {
0 commit comments