(t *testing.T)
| 177 | } |
| 178 | |
| 179 | func TestReleaseListAndDelete(t *testing.T) { |
| 180 | runId := uuid.New() |
| 181 | apiClient, err := integration.GetApiClient(space1ID) |
| 182 | testutil.RequireSuccess(t, err) |
| 183 | |
| 184 | fx, err := integration.CreateCommonProject(t, apiClient, runId) |
| 185 | testutil.RequireSuccess(t, err) |
| 186 | |
| 187 | project := fx.Project // alias for convenience |
| 188 | |
| 189 | dep, err := apiClient.DeploymentProcesses.Get(fx.Project, "") |
| 190 | if !testutil.AssertSuccess(t, err) { |
| 191 | return |
| 192 | } |
| 193 | dep.Steps = []*deployments.DeploymentStep{ |
| 194 | { |
| 195 | Name: fmt.Sprintf("step1-%s", runId), |
| 196 | Properties: map[string]core.PropertyValue{"Octopus.Action.TargetRoles": core.NewPropertyValue("deploy", false)}, |
| 197 | Actions: []*deployments.DeploymentAction{ |
| 198 | { |
| 199 | ActionType: "Octopus.Script", |
| 200 | Name: "Run a script", |
| 201 | Properties: map[string]core.PropertyValue{ |
| 202 | "Octopus.Action.Script.ScriptBody": core.NewPropertyValue("echo 'hello'", false), |
| 203 | }, |
| 204 | }, |
| 205 | }, |
| 206 | }, |
| 207 | } |
| 208 | dep, err = apiClient.DeploymentProcesses.Update(dep) |
| 209 | if !testutil.AssertSuccess(t, err) { |
| 210 | return |
| 211 | } |
| 212 | |
| 213 | // create some releases so we can list them |
| 214 | createReleaseCmd := releases.NewCreateReleaseCommandV1(space1ID, fx.Project.GetName()) |
| 215 | for i := 0; i < 5; i++ { |
| 216 | createReleaseCmd.ReleaseVersion = fmt.Sprintf("%d.0", i+1) |
| 217 | _, err := releases.CreateReleaseV1(apiClient, createReleaseCmd) |
| 218 | assert.Nil(t, err) |
| 219 | } |
| 220 | t.Cleanup(func() { deleteAllReleasesInProject(t, apiClient, project) }) |
| 221 | |
| 222 | t.Run("list releases - basic", func(t *testing.T) { |
| 223 | stdOut, stdErr, err := integration.RunCli(space1ID, "release", "list", "--project", project.Name, "--output-format", "basic") |
| 224 | if !testutil.AssertSuccess(t, err, stdOut, stdErr) { |
| 225 | return |
| 226 | } |
| 227 | |
| 228 | assert.Equal(t, "5.0\n4.0\n3.0\n2.0\n1.0\n", stdOut) |
| 229 | assert.Equal(t, "", stdErr) |
| 230 | }) |
| 231 | |
| 232 | t.Run("delete release", func(t *testing.T) { |
| 233 | createReleaseCmd.ReleaseVersion = "DeleteMe5.0" |
| 234 | createResponse, err := releases.CreateReleaseV1(apiClient, createReleaseCmd) |
| 235 | require.Nil(t, err) |
| 236 |
nothing calls this directly
no test coverage detected