From 5b06ba07d9432b80a55d63d97c688f2f85618f31 Mon Sep 17 00:00:00 2001 From: Brandon Croft Date: Mon, 2 May 2022 13:26:27 -0600 Subject: [PATCH] fix: run actions don't accept json-api resource request bodies --- run.go | 8 ++++---- run_integration_test.go | 13 ++++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/run.go b/run.go index 796d74ff8..5c1cd85fc 100644 --- a/run.go +++ b/run.go @@ -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 @@ -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. diff --git a/run_integration_test.go b/run_integration_test.go index 7e12735b2..aabcfb4fb 100644 --- a/run_integration_test.go +++ b/run_integration_test.go @@ -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) {