Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: run actions don't accept json-api resource request bodies #388

Merged
merged 1 commit into from May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions run.go
Expand Up @@ -253,13 +253,13 @@ type RunCreateOptions struct {
// RunApplyOptions represents the options for applying a run.
type RunApplyOptions struct {
// An optional comment about the run.
Comment *string `jsonapi:"attr,comment,omitempty"`
Comment *string `json:"comment,omitempty"`
}

// RunCancelOptions represents the options for canceling a run.
type RunCancelOptions struct {
// An optional explanation for why the run was canceled.
Comment *string `jsonapi:"attr,comment,omitempty"`
Comment *string `json:"comment,omitempty"`
}

// RunVariable represents a variable that can be applied to a run. All values must be expressed as an HCL literal
Expand All @@ -273,13 +273,13 @@ type RunVariable struct {
// RunForceCancelOptions represents the options for force-canceling a run.
type RunForceCancelOptions struct {
// An optional comment explaining the reason for the force-cancel.
Comment *string `jsonapi:"attr,comment,omitempty"`
Comment *string `json:"comment,omitempty"`
}

// RunDiscardOptions represents the options for discarding a run.
type RunDiscardOptions struct {
// An optional explanation for why the run was discarded.
Comment *string `jsonapi:"attr,comment,omitempty"`
Comment *string `json:"comment,omitempty"`
}

// List all the runs of the given workspace.
Expand Down
13 changes: 12 additions & 1 deletion run_integration_test.go
Expand Up @@ -295,8 +295,19 @@ func TestRunsApply(t *testing.T) {
rTest, _ := createPlannedRun(t, client, wTest)

t.Run("when the run exists", func(t *testing.T) {
err := client.Runs.Apply(ctx, rTest.ID, RunApplyOptions{})
err := client.Runs.Apply(ctx, rTest.ID, RunApplyOptions{
Comment: String("Hello, Earl"),
})
assert.NoError(t, err)

r, err := client.Runs.Read(ctx, rTest.ID)
assert.NoError(t, err)

assert.Len(t, r.Comments, 1)

c, err := client.Comments.Read(ctx, r.Comments[0].ID)
assert.NoError(t, err)
assert.Equal(t, "Hello, Earl", c.Body)
})

t.Run("when the run does not exist", func(t *testing.T) {
Expand Down