Skip to content

Commit

Permalink
Merge pull request #329 from hashicorp/sebasslash/run-task-1.0-sync
Browse files Browse the repository at this point in the history
Sync run task changes with 1.0 effort
  • Loading branch information
sebasslash committed Feb 24, 2022
2 parents 57f36e6 + 5df3e72 commit 861c6e3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
1 change: 1 addition & 0 deletions run.go
Expand Up @@ -170,6 +170,7 @@ const (
RunConfigVer RunIncludeOps = "configuration_version"
RunConfigVerIngress RunIncludeOps = "configuration_version.ingress_attributes"
RunWorkspace RunIncludeOps = "workspace"
RunTaskStages RunIncludeOps = "task_stages"
)

// RunListOptions represents the options for listing runs.
Expand Down
4 changes: 2 additions & 2 deletions run_task.go
Expand Up @@ -134,7 +134,7 @@ type RunTaskListOptions struct {
ListOptions

// A list of relations to include
Include []RunTaskIncludeOps `url:"include"`
Include []RunTaskIncludeOps `url:"include,omitempty"`
}

// List all the run tasks for an organization
Expand Down Expand Up @@ -165,7 +165,7 @@ func (s *runTasks) Read(ctx context.Context, runTaskID string) (*RunTask, error)

// RunTaskReadOptions represents the set of options for reading a run task
type RunTaskReadOptions struct {
Include []RunTaskIncludeOps `url:"include"`
Include []RunTaskIncludeOps `url:"include,omitempty"`
}

// Read is used to read an organization's run task by ID with options
Expand Down
6 changes: 3 additions & 3 deletions task_stages.go
Expand Up @@ -68,7 +68,7 @@ const (

// TaskStageReadOptions represents the set of options when reading a task stage
type TaskStageReadOptions struct {
Include []TaskStageIncludeOps `url:"include"`
Include []TaskStageIncludeOps `url:"include,omitempty"`
}

// Read a task stage by ID
Expand All @@ -78,7 +78,7 @@ func (s *taskStages) Read(ctx context.Context, taskStageID string, options *Task
}

u := fmt.Sprintf("task-stages/%s", taskStageID)
req, err := s.client.newRequest("GET", u, &options)
req, err := s.client.newRequest("GET", u, options)
if err != nil {
return nil, err
}
Expand All @@ -104,7 +104,7 @@ func (s *taskStages) List(ctx context.Context, runID string, options *TaskStageL
}

u := fmt.Sprintf("runs/%s/task-stages", runID)
req, err := s.client.newRequest("GET", u, &options)
req, err := s.client.newRequest("GET", u, options)
if err != nil {
return nil, err
}
Expand Down
15 changes: 5 additions & 10 deletions task_stages_integration_test.go
Expand Up @@ -32,12 +32,12 @@ func TestTaskStagesRead(t *testing.T) {
rTest, rTestCleanup := createRun(t, client, wkspaceTest)
defer rTestCleanup()

t.Run("without include param", func(t *testing.T) {
r, err := client.Runs.ReadWithOptions(ctx, rTest.ID, &RunReadOptions{
Include: "task_stages",
})
require.NoError(t, err)
r, err := client.Runs.ReadWithOptions(ctx, rTest.ID, &RunReadOptions{
Include: []RunIncludeOps{RunTaskStages},
})
require.NoError(t, err)

t.Run("without read options", func(t *testing.T) {
taskStage, err := client.TaskStages.Read(ctx, r.TaskStages[0].ID, nil)
require.NoError(t, err)

Expand All @@ -58,11 +58,6 @@ func TestTaskStagesRead(t *testing.T) {
})

t.Run("with include param task_results", func(t *testing.T) {
r, err := client.Runs.ReadWithOptions(ctx, rTest.ID, &RunReadOptions{
Include: "task_stages",
})
require.NoError(t, err)

taskStage, err := client.TaskStages.Read(ctx, r.TaskStages[0].ID, &TaskStageReadOptions{
Include: []TaskStageIncludeOps{TaskStageTaskResults},
})
Expand Down

0 comments on commit 861c6e3

Please sign in to comment.