(t *testing.T)
| 30 | } |
| 31 | |
| 32 | func TestReleaseCreateBasics(t *testing.T) { |
| 33 | runId := uuid.New() |
| 34 | apiClient, err := integration.GetApiClient(space1ID) |
| 35 | testutil.RequireSuccess(t, err) |
| 36 | |
| 37 | fx, err := integration.CreateCommonProject(t, apiClient, runId) |
| 38 | testutil.RequireSuccess(t, err) |
| 39 | |
| 40 | project := fx.Project // alias for convenience |
| 41 | |
| 42 | dep, err := apiClient.DeploymentProcesses.Get(fx.Project, "") |
| 43 | if !testutil.AssertSuccess(t, err) { |
| 44 | return |
| 45 | } |
| 46 | dep.Steps = []*deployments.DeploymentStep{ |
| 47 | { |
| 48 | Name: fmt.Sprintf("step1-%s", runId), |
| 49 | Properties: map[string]core.PropertyValue{"Octopus.Action.TargetRoles": core.NewPropertyValue("deploy", false)}, |
| 50 | Actions: []*deployments.DeploymentAction{ |
| 51 | { |
| 52 | ActionType: "Octopus.Script", |
| 53 | Name: "Run a script", |
| 54 | Properties: map[string]core.PropertyValue{ |
| 55 | "Octopus.Action.Script.ScriptBody": core.NewPropertyValue("echo 'hello'", false), |
| 56 | }, |
| 57 | }, |
| 58 | }, |
| 59 | }, |
| 60 | } |
| 61 | dep, err = apiClient.DeploymentProcesses.Update(dep) |
| 62 | if !testutil.AssertSuccess(t, err) { |
| 63 | return |
| 64 | } |
| 65 | |
| 66 | // whilst the project already has a Default channel, we make an explicit one |
| 67 | // so we can verify things aren't just silently using the default when we tell them not to |
| 68 | customChannel := channels.NewChannel(fmt.Sprintf("channel-%s", runId), project.ID) |
| 69 | customChannel, err = apiClient.Channels.Add(customChannel) |
| 70 | if !testutil.AssertSuccess(t, err) { |
| 71 | return |
| 72 | } |
| 73 | t.Cleanup(func() { assert.Nil(t, apiClient.Channels.DeleteByID(customChannel.ID)) }) |
| 74 | |
| 75 | t.Run("create a release specifying project,channel,version", func(t *testing.T) { |
| 76 | stdOut, stdErr, err := integration.RunCli(space1ID, "release", "create", "--project", project.Name, "--channel", customChannel.Name, "--version", "2.3.4") |
| 77 | if !testutil.AssertSuccess(t, err, stdOut, stdErr) { |
| 78 | return |
| 79 | } |
| 80 | t.Cleanup(func() { deleteAllReleasesInProject(t, apiClient, project) }) |
| 81 | |
| 82 | projectReleases, err := apiClient.Projects.GetReleases(project) |
| 83 | assert.Equal(t, 1, len(projectReleases)) |
| 84 | r1 := projectReleases[0] |
| 85 | |
| 86 | assert.Equal(t, project.ID, r1.ProjectID) |
| 87 | assert.Equal(t, customChannel.ID, r1.ChannelID) |
| 88 | assert.Equal(t, "2.3.4", r1.Version) |
| 89 |
nothing calls this directly
no test coverage detected