MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / TestDeployCreate_AutomationMode

Function TestDeployCreate_AutomationMode

pkg/cmd/release/deploy/deploy_test.go:1532–2027  ·  view source on GitHub ↗

These tests ensure that given the right input, we call the server's API appropriately they all run in automation mode where survey is disabled; they'd error if they tried to ask questions

(t *testing.T)

Source from the content-addressed store, hash-verified

1530// These tests ensure that given the right input, we call the server's API appropriately
1531// they all run in automation mode where survey is disabled; they'd error if they tried to ask questions
1532func TestDeployCreate_AutomationMode(t *testing.T) {
1533 const spaceID = "Spaces-1"
1534 const fireProjectID = "Projects-22"
1535
1536 space1 := fixtures.NewSpace(spaceID, "Default Space")
1537
1538 defaultChannel := fixtures.NewChannel(spaceID, "Channels-1", "Fire Project Default Channel", fireProjectID)
1539 defaultChannel.Type = channels.ChannelTypeLifecycle
1540
1541 fireProject := fixtures.NewProject(spaceID, fireProjectID, "Fire Project", "Lifecycles-1", "ProjectGroups-1", "deploymentprocess-"+fireProjectID)
1542 //
1543 //
1544 release10 := fixtures.NewRelease(spaceID, "Releases-200", "2.0", fireProjectID, defaultChannel.ID)
1545 ////release20.ProjectDeploymentProcessSnapshotID = depProcessSnapshot.ID
1546 //release20.ProjectVariableSetSnapshotID = variableSnapshotWithPromptedVariables.ID
1547 //
1548 //devEnvironment := fixtures.NewEnvironment(spaceID, "Environments-12", "dev")
1549
1550 // TEST STARTS HERE
1551 tests := []struct {
1552 name string
1553 run func(t *testing.T, api *testutil.MockHttpServer, rootCmd *cobra.Command, stdOut *bytes.Buffer, stdErr *bytes.Buffer)
1554 }{
1555 {"release deploy requires a project name", func(t *testing.T, api *testutil.MockHttpServer, rootCmd *cobra.Command, stdOut *bytes.Buffer, stdErr *bytes.Buffer) {
1556 cmdReceiver := testutil.GoBegin2(func() (*cobra.Command, error) {
1557 defer api.Close()
1558 rootCmd.SetArgs([]string{"release", "deploy"})
1559 return rootCmd.ExecuteC()
1560 })
1561
1562 api.ExpectRequest(t, "GET", "/api/").RespondWith(rootResource)
1563 api.ExpectRequest(t, "GET", "/api/Spaces-1").RespondWith(rootResource)
1564
1565 _, err := testutil.ReceivePair(cmdReceiver)
1566 assert.EqualError(t, err, "project must be specified")
1567
1568 assert.Equal(t, "", stdOut.String())
1569 assert.Equal(t, "", stdErr.String())
1570 }},
1571
1572 {"release deploy requires a release version", func(t *testing.T, api *testutil.MockHttpServer, rootCmd *cobra.Command, stdOut *bytes.Buffer, stdErr *bytes.Buffer) {
1573 cmdReceiver := testutil.GoBegin2(func() (*cobra.Command, error) {
1574 defer api.Close()
1575 rootCmd.SetArgs([]string{"release", "deploy", "--project", "Fire Project"})
1576 return rootCmd.ExecuteC()
1577 })
1578
1579 api.ExpectRequest(t, "GET", "/api/").RespondWith(rootResource)
1580 api.ExpectRequest(t, "GET", "/api/Spaces-1").RespondWith(rootResource)
1581 api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/"+fireProject.GetName()).RespondWith(fireProject)
1582
1583 _, err := testutil.ReceivePair(cmdReceiver)
1584 assert.EqualError(t, err, "release version must be specified")
1585
1586 assert.Equal(t, "", stdOut.String())
1587 assert.Equal(t, "", stdErr.String())
1588 }},
1589

Callers

nothing calls this directly

Calls 13

CloseMethod · 0.95
ExpectRequestMethod · 0.95
NewSpaceFunction · 0.92
NewChannelFunction · 0.92
NewProjectFunction · 0.92
NewReleaseFunction · 0.92
GoBegin2Function · 0.92
ReceivePairFunction · 0.92
NewMockHttpServerFunction · 0.92
NewMockFactoryWithSpaceFunction · 0.92
RespondWithMethod · 0.80
RespondWithStatusMethod · 0.80

Tested by

no test coverage detected