Skip to content

Commit

Permalink
Fix add wather invlid payload issue
Browse files Browse the repository at this point in the history
  • Loading branch information
djx339 committed Nov 12, 2024
1 parent 56a6927 commit cb9ba4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions jira/internal/watcher_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ func (i *internalWatcherImpl) Add(ctx context.Context, issueKeyOrID string, acco

endpoint := fmt.Sprintf("rest/api/%v/issue/%v/watchers", i.version, issueKeyOrID)

var payload []byte // add self user
var payload string // add self user
if len(accountID) > 0 {
payload = []byte(accountID[0]) // add another user
payload = accountID[0] // add another user
}
request, err := i.c.NewRequest(ctx, http.MethodPost, endpoint, "", payload)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions jira/internal/watcher_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) {
http.MethodPost,
"rest/api/3/issue/DUMMY-5/watchers",
"",
[]byte(nil)).
"").
Return(&http.Request{}, nil)

client.On("Call",
Expand Down Expand Up @@ -230,7 +230,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) {
http.MethodPost,
"rest/api/3/issue/DUMMY-5/watchers",
"",
[]byte("someAccountID")).
"someAccountID").
Return(&http.Request{}, nil)

client.On("Call",
Expand Down Expand Up @@ -261,7 +261,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) {
http.MethodPost,
"rest/api/2/issue/DUMMY-5/watchers",
"",
[]byte(nil),
"",
).
Return(&http.Request{}, nil)

Expand Down Expand Up @@ -293,7 +293,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) {
http.MethodPost,
"rest/api/2/issue/DUMMY-5/watchers",
"",
[]byte("someAccountID")).
"someAccountID").
Return(&http.Request{}, nil)

client.On("Call",
Expand Down Expand Up @@ -335,7 +335,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) {
http.MethodPost,
"rest/api/3/issue/DUMMY-5/watchers",
"",
[]byte(nil)).
"").
Return(&http.Request{}, errors.New("error, unable to create the http request"))

fields.c = client
Expand Down

0 comments on commit cb9ba4a

Please sign in to comment.