From cb9ba4a335cca761b4ce4b6b9f31b6767edf457f Mon Sep 17 00:00:00 2001 From: Daniel D Date: Tue, 12 Nov 2024 10:17:48 +0800 Subject: [PATCH] Fix add wather invlid payload issue --- jira/internal/watcher_impl.go | 4 ++-- jira/internal/watcher_impl_test.go | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/jira/internal/watcher_impl.go b/jira/internal/watcher_impl.go index fda17805..bbaf98d6 100644 --- a/jira/internal/watcher_impl.go +++ b/jira/internal/watcher_impl.go @@ -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 { diff --git a/jira/internal/watcher_impl_test.go b/jira/internal/watcher_impl_test.go index f55c1366..0b3f4c2b 100644 --- a/jira/internal/watcher_impl_test.go +++ b/jira/internal/watcher_impl_test.go @@ -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", @@ -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", @@ -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) @@ -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", @@ -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