From 60a42cff9e1c628ee3ec077151bf0d7f735a9216 Mon Sep 17 00:00:00 2001 From: Maxime LIBS Date: Mon, 15 Jul 2024 11:36:21 +0200 Subject: [PATCH 1/5] add watcher that is another user --- jira/internal/watcher_impl.go | 12 ++++++++---- jira/internal/watcher_impl_test.go | 2 +- service/jira/watcher.go | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/jira/internal/watcher_impl.go b/jira/internal/watcher_impl.go index ea860bfd..405169d0 100644 --- a/jira/internal/watcher_impl.go +++ b/jira/internal/watcher_impl.go @@ -42,8 +42,8 @@ func (w *WatcherService) Gets(ctx context.Context, issueKeyOrID string) (*model. // POST /rest/api/{2-3}/issue/{issueKeyOrID}/watchers // // https://docs.go-atlassian.io/jira-software-cloud/issues/watcher#add-watcher -func (w *WatcherService) Add(ctx context.Context, issueKeyOrID string) (*model.ResponseScheme, error) { - return w.internalClient.Add(ctx, issueKeyOrID) +func (w *WatcherService) Add(ctx context.Context, issueKeyOrID, accountId string) (*model.ResponseScheme, error) { + return w.internalClient.Add(ctx, issueKeyOrID, accountId) } // Delete deletes a user as a watcher of an issue. @@ -82,7 +82,7 @@ func (i *internalWatcherImpl) Gets(ctx context.Context, issueKeyOrID string) (*m return watchers, response, nil } -func (i *internalWatcherImpl) Add(ctx context.Context, issueKeyOrID string) (*model.ResponseScheme, error) { +func (i *internalWatcherImpl) Add(ctx context.Context, issueKeyOrID, accountId string) (*model.ResponseScheme, error) { if issueKeyOrID == "" { return nil, model.ErrNoIssueKeyOrIDError @@ -90,7 +90,11 @@ func (i *internalWatcherImpl) Add(ctx context.Context, issueKeyOrID string) (*mo endpoint := fmt.Sprintf("rest/api/%v/issue/%v/watchers", i.version, issueKeyOrID) - request, err := i.c.NewRequest(ctx, http.MethodPost, endpoint, "", nil) + payload := []byte(accountId) // add another user + if len(accountId) == 0 { + payload = []byte("dummy=true") // self watcher + } + request, err := i.c.NewRequest(ctx, http.MethodPost, endpoint, "", payload) if err != nil { return nil, err } diff --git a/jira/internal/watcher_impl_test.go b/jira/internal/watcher_impl_test.go index 9b42699f..2ab815c0 100644 --- a/jira/internal/watcher_impl_test.go +++ b/jira/internal/watcher_impl_test.go @@ -288,7 +288,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { newService, err := NewWatcherService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResponse, err := newService.Add(testCase.args.ctx, testCase.args.issueKeyOrID) + gotResponse, err := newService.Add(testCase.args.ctx, testCase.args.issueKeyOrID, "") if testCase.wantErr { diff --git a/service/jira/watcher.go b/service/jira/watcher.go index 29150fa5..61a200cb 100644 --- a/service/jira/watcher.go +++ b/service/jira/watcher.go @@ -23,7 +23,7 @@ type WatcherConnector interface { // POST /rest/api/{2-3}/issue/{issueIdOrKey}/watchers // // https://docs.go-atlassian.io/jira-software-cloud/issues/watcher#add-watcher - Add(ctx context.Context, issueKeyOrId string) (*model.ResponseScheme, error) + Add(ctx context.Context, issueKeyOrId, accountId string) (*model.ResponseScheme, error) // Delete deletes a user as a watcher of an issue. // From d7bab94bc44d61698e56205e876e921dd061ebb2 Mon Sep 17 00:00:00 2001 From: Maxime LIBS Date: Mon, 22 Jul 2024 11:50:37 +0200 Subject: [PATCH 2/5] test: fixed tests + retro-compatibility using variadic --- jira/internal/watcher_impl.go | 12 ++--- jira/internal/watcher_impl_test.go | 71 +++++++++++++++++++++++++++++- service/jira/watcher.go | 2 +- 3 files changed, 76 insertions(+), 9 deletions(-) diff --git a/jira/internal/watcher_impl.go b/jira/internal/watcher_impl.go index 405169d0..d9903ef5 100644 --- a/jira/internal/watcher_impl.go +++ b/jira/internal/watcher_impl.go @@ -42,8 +42,8 @@ func (w *WatcherService) Gets(ctx context.Context, issueKeyOrID string) (*model. // POST /rest/api/{2-3}/issue/{issueKeyOrID}/watchers // // https://docs.go-atlassian.io/jira-software-cloud/issues/watcher#add-watcher -func (w *WatcherService) Add(ctx context.Context, issueKeyOrID, accountId string) (*model.ResponseScheme, error) { - return w.internalClient.Add(ctx, issueKeyOrID, accountId) +func (w *WatcherService) Add(ctx context.Context, issueKeyOrID string, accountId ...string) (*model.ResponseScheme, error) { + return w.internalClient.Add(ctx, issueKeyOrID, accountId...) } // Delete deletes a user as a watcher of an issue. @@ -82,7 +82,7 @@ func (i *internalWatcherImpl) Gets(ctx context.Context, issueKeyOrID string) (*m return watchers, response, nil } -func (i *internalWatcherImpl) Add(ctx context.Context, issueKeyOrID, accountId string) (*model.ResponseScheme, error) { +func (i *internalWatcherImpl) Add(ctx context.Context, issueKeyOrID string, accountId ...string) (*model.ResponseScheme, error) { if issueKeyOrID == "" { return nil, model.ErrNoIssueKeyOrIDError @@ -90,9 +90,9 @@ func (i *internalWatcherImpl) Add(ctx context.Context, issueKeyOrID, accountId s endpoint := fmt.Sprintf("rest/api/%v/issue/%v/watchers", i.version, issueKeyOrID) - payload := []byte(accountId) // add another user - if len(accountId) == 0 { - payload = []byte("dummy=true") // self watcher + var payload []byte = nil // add self user + if len(accountId) > 0 { + payload = []byte(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 2ab815c0..3a9acd05 100644 --- a/jira/internal/watcher_impl_test.go +++ b/jira/internal/watcher_impl_test.go @@ -171,6 +171,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { type args struct { ctx context.Context issueKeyOrID string + accountId []string } testCases := []struct { @@ -187,6 +188,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", + accountId: nil, }, on: func(fields *fields) { @@ -197,7 +199,38 @@ 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", + &http.Request{}, nil). + Return(&model.ResponseScheme{}, nil) + + fields.c = client + }, + wantErr: false, + Err: nil, + }, + + { + name: "when the api version is v3 and the watcher accountId is set", + fields: fields{version: "3"}, + args: args{ + ctx: context.Background(), + issueKeyOrID: "DUMMY-5", + accountId: []string{"someAccountId"}, + }, + on: func(fields *fields) { + + client := mocks.NewConnector(t) + + client.On("NewRequest", + context.Background(), + http.MethodPost, + "rest/api/3/issue/DUMMY-5/watchers", + "", + []byte("someAccountId")). Return(&http.Request{}, nil) client.On("Call", @@ -217,6 +250,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", + accountId: nil, }, on: func(fields *fields) { @@ -227,7 +261,39 @@ func Test_internalWatcherImpl_Add(t *testing.T) { http.MethodPost, "rest/api/2/issue/DUMMY-5/watchers", "", + []byte(nil), + ). + Return(&http.Request{}, nil) + + client.On("Call", + &http.Request{}, nil). + Return(&model.ResponseScheme{}, nil) + + fields.c = client + }, + wantErr: false, + Err: nil, + }, + + { + name: "when the api version is v2 and the watcher accountId is set", + fields: fields{version: "2"}, + args: args{ + ctx: context.Background(), + issueKeyOrID: "DUMMY-5", + accountId: []string{"someAccountId"}, + }, + on: func(fields *fields) { + + client := mocks.NewConnector(t) + + client.On("NewRequest", + context.Background(), + http.MethodPost, + "rest/api/2/issue/DUMMY-5/watchers", + "", + []byte("someAccountId")). Return(&http.Request{}, nil) client.On("Call", @@ -258,6 +324,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", + accountId: nil, }, on: func(fields *fields) { @@ -268,7 +335,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { http.MethodPost, "rest/api/3/issue/DUMMY-5/watchers", "", - nil). + []byte(nil)). Return(&http.Request{}, errors.New("error, unable to create the http request")) fields.c = client @@ -288,7 +355,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { newService, err := NewWatcherService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResponse, err := newService.Add(testCase.args.ctx, testCase.args.issueKeyOrID, "") + gotResponse, err := newService.Add(testCase.args.ctx, testCase.args.issueKeyOrID, testCase.args.accountId...) if testCase.wantErr { diff --git a/service/jira/watcher.go b/service/jira/watcher.go index 61a200cb..bbf72232 100644 --- a/service/jira/watcher.go +++ b/service/jira/watcher.go @@ -23,7 +23,7 @@ type WatcherConnector interface { // POST /rest/api/{2-3}/issue/{issueIdOrKey}/watchers // // https://docs.go-atlassian.io/jira-software-cloud/issues/watcher#add-watcher - Add(ctx context.Context, issueKeyOrId, accountId string) (*model.ResponseScheme, error) + Add(ctx context.Context, issueKeyOrId string, accountId ...string) (*model.ResponseScheme, error) // Delete deletes a user as a watcher of an issue. // From cfe009f860e94b0fb5d0a812bf3e0757f1a39b9a Mon Sep 17 00:00:00 2001 From: Maxime LIBS Date: Mon, 22 Jul 2024 11:56:39 +0200 Subject: [PATCH 3/5] removed variadic --- jira/internal/watcher_impl.go | 8 ++++---- jira/internal/watcher_impl_test.go | 14 +++++++------- service/jira/watcher.go | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/jira/internal/watcher_impl.go b/jira/internal/watcher_impl.go index d9903ef5..b6270f6c 100644 --- a/jira/internal/watcher_impl.go +++ b/jira/internal/watcher_impl.go @@ -42,8 +42,8 @@ func (w *WatcherService) Gets(ctx context.Context, issueKeyOrID string) (*model. // POST /rest/api/{2-3}/issue/{issueKeyOrID}/watchers // // https://docs.go-atlassian.io/jira-software-cloud/issues/watcher#add-watcher -func (w *WatcherService) Add(ctx context.Context, issueKeyOrID string, accountId ...string) (*model.ResponseScheme, error) { - return w.internalClient.Add(ctx, issueKeyOrID, accountId...) +func (w *WatcherService) Add(ctx context.Context, issueKeyOrID string, accountId string) (*model.ResponseScheme, error) { + return w.internalClient.Add(ctx, issueKeyOrID, accountId) } // Delete deletes a user as a watcher of an issue. @@ -82,7 +82,7 @@ func (i *internalWatcherImpl) Gets(ctx context.Context, issueKeyOrID string) (*m return watchers, response, nil } -func (i *internalWatcherImpl) Add(ctx context.Context, issueKeyOrID string, accountId ...string) (*model.ResponseScheme, error) { +func (i *internalWatcherImpl) Add(ctx context.Context, issueKeyOrID, accountId string) (*model.ResponseScheme, error) { if issueKeyOrID == "" { return nil, model.ErrNoIssueKeyOrIDError @@ -92,7 +92,7 @@ func (i *internalWatcherImpl) Add(ctx context.Context, issueKeyOrID string, acco var payload []byte = nil // add self user if len(accountId) > 0 { - payload = []byte(accountId[0]) // add another user + payload = []byte(accountId) // 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 3a9acd05..0ce874e7 100644 --- a/jira/internal/watcher_impl_test.go +++ b/jira/internal/watcher_impl_test.go @@ -171,7 +171,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { type args struct { ctx context.Context issueKeyOrID string - accountId []string + accountId string } testCases := []struct { @@ -188,7 +188,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", - accountId: nil, + accountId: "", }, on: func(fields *fields) { @@ -219,7 +219,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", - accountId: []string{"someAccountId"}, + accountId: "someAccountId", }, on: func(fields *fields) { @@ -250,7 +250,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", - accountId: nil, + accountId: "", }, on: func(fields *fields) { @@ -282,7 +282,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", - accountId: []string{"someAccountId"}, + accountId: "someAccountId", }, on: func(fields *fields) { @@ -324,7 +324,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", - accountId: nil, + accountId: "", }, on: func(fields *fields) { @@ -355,7 +355,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { newService, err := NewWatcherService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResponse, err := newService.Add(testCase.args.ctx, testCase.args.issueKeyOrID, testCase.args.accountId...) + gotResponse, err := newService.Add(testCase.args.ctx, testCase.args.issueKeyOrID, testCase.args.accountId) if testCase.wantErr { diff --git a/service/jira/watcher.go b/service/jira/watcher.go index bbf72232..0bfc7dba 100644 --- a/service/jira/watcher.go +++ b/service/jira/watcher.go @@ -23,7 +23,7 @@ type WatcherConnector interface { // POST /rest/api/{2-3}/issue/{issueIdOrKey}/watchers // // https://docs.go-atlassian.io/jira-software-cloud/issues/watcher#add-watcher - Add(ctx context.Context, issueKeyOrId string, accountId ...string) (*model.ResponseScheme, error) + Add(ctx context.Context, issueKeyOrId string, accountId string) (*model.ResponseScheme, error) // Delete deletes a user as a watcher of an issue. // From 98397b1ba1aff2917bc80c85bf59dff1438fa482 Mon Sep 17 00:00:00 2001 From: Maxime LIBS Date: Mon, 22 Jul 2024 11:58:29 +0200 Subject: [PATCH 4/5] Revert "removed variadic" This reverts commit cfe009f860e94b0fb5d0a812bf3e0757f1a39b9a. --- jira/internal/watcher_impl.go | 8 ++++---- jira/internal/watcher_impl_test.go | 14 +++++++------- service/jira/watcher.go | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/jira/internal/watcher_impl.go b/jira/internal/watcher_impl.go index b6270f6c..d9903ef5 100644 --- a/jira/internal/watcher_impl.go +++ b/jira/internal/watcher_impl.go @@ -42,8 +42,8 @@ func (w *WatcherService) Gets(ctx context.Context, issueKeyOrID string) (*model. // POST /rest/api/{2-3}/issue/{issueKeyOrID}/watchers // // https://docs.go-atlassian.io/jira-software-cloud/issues/watcher#add-watcher -func (w *WatcherService) Add(ctx context.Context, issueKeyOrID string, accountId string) (*model.ResponseScheme, error) { - return w.internalClient.Add(ctx, issueKeyOrID, accountId) +func (w *WatcherService) Add(ctx context.Context, issueKeyOrID string, accountId ...string) (*model.ResponseScheme, error) { + return w.internalClient.Add(ctx, issueKeyOrID, accountId...) } // Delete deletes a user as a watcher of an issue. @@ -82,7 +82,7 @@ func (i *internalWatcherImpl) Gets(ctx context.Context, issueKeyOrID string) (*m return watchers, response, nil } -func (i *internalWatcherImpl) Add(ctx context.Context, issueKeyOrID, accountId string) (*model.ResponseScheme, error) { +func (i *internalWatcherImpl) Add(ctx context.Context, issueKeyOrID string, accountId ...string) (*model.ResponseScheme, error) { if issueKeyOrID == "" { return nil, model.ErrNoIssueKeyOrIDError @@ -92,7 +92,7 @@ func (i *internalWatcherImpl) Add(ctx context.Context, issueKeyOrID, accountId s var payload []byte = nil // add self user if len(accountId) > 0 { - payload = []byte(accountId) // add another user + payload = []byte(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 0ce874e7..3a9acd05 100644 --- a/jira/internal/watcher_impl_test.go +++ b/jira/internal/watcher_impl_test.go @@ -171,7 +171,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { type args struct { ctx context.Context issueKeyOrID string - accountId string + accountId []string } testCases := []struct { @@ -188,7 +188,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", - accountId: "", + accountId: nil, }, on: func(fields *fields) { @@ -219,7 +219,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", - accountId: "someAccountId", + accountId: []string{"someAccountId"}, }, on: func(fields *fields) { @@ -250,7 +250,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", - accountId: "", + accountId: nil, }, on: func(fields *fields) { @@ -282,7 +282,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", - accountId: "someAccountId", + accountId: []string{"someAccountId"}, }, on: func(fields *fields) { @@ -324,7 +324,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", - accountId: "", + accountId: nil, }, on: func(fields *fields) { @@ -355,7 +355,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { newService, err := NewWatcherService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResponse, err := newService.Add(testCase.args.ctx, testCase.args.issueKeyOrID, testCase.args.accountId) + gotResponse, err := newService.Add(testCase.args.ctx, testCase.args.issueKeyOrID, testCase.args.accountId...) if testCase.wantErr { diff --git a/service/jira/watcher.go b/service/jira/watcher.go index 0bfc7dba..bbf72232 100644 --- a/service/jira/watcher.go +++ b/service/jira/watcher.go @@ -23,7 +23,7 @@ type WatcherConnector interface { // POST /rest/api/{2-3}/issue/{issueIdOrKey}/watchers // // https://docs.go-atlassian.io/jira-software-cloud/issues/watcher#add-watcher - Add(ctx context.Context, issueKeyOrId string, accountId string) (*model.ResponseScheme, error) + Add(ctx context.Context, issueKeyOrId string, accountId ...string) (*model.ResponseScheme, error) // Delete deletes a user as a watcher of an issue. // From f64b7eb1875201fb20ad1ff5ccfbcf355fd7f747 Mon Sep 17 00:00:00 2001 From: Maxime LIBS Date: Mon, 22 Jul 2024 13:51:57 +0200 Subject: [PATCH 5/5] fix: initialism --- jira/internal/watcher_impl.go | 10 +++++----- jira/internal/watcher_impl_test.go | 18 +++++++++--------- service/jira/watcher.go | 6 +++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/jira/internal/watcher_impl.go b/jira/internal/watcher_impl.go index d9903ef5..9aa84149 100644 --- a/jira/internal/watcher_impl.go +++ b/jira/internal/watcher_impl.go @@ -42,8 +42,8 @@ func (w *WatcherService) Gets(ctx context.Context, issueKeyOrID string) (*model. // POST /rest/api/{2-3}/issue/{issueKeyOrID}/watchers // // https://docs.go-atlassian.io/jira-software-cloud/issues/watcher#add-watcher -func (w *WatcherService) Add(ctx context.Context, issueKeyOrID string, accountId ...string) (*model.ResponseScheme, error) { - return w.internalClient.Add(ctx, issueKeyOrID, accountId...) +func (w *WatcherService) Add(ctx context.Context, issueKeyOrID string, accountID ...string) (*model.ResponseScheme, error) { + return w.internalClient.Add(ctx, issueKeyOrID, accountID...) } // Delete deletes a user as a watcher of an issue. @@ -82,7 +82,7 @@ func (i *internalWatcherImpl) Gets(ctx context.Context, issueKeyOrID string) (*m return watchers, response, nil } -func (i *internalWatcherImpl) Add(ctx context.Context, issueKeyOrID string, accountId ...string) (*model.ResponseScheme, error) { +func (i *internalWatcherImpl) Add(ctx context.Context, issueKeyOrID string, accountID ...string) (*model.ResponseScheme, error) { if issueKeyOrID == "" { return nil, model.ErrNoIssueKeyOrIDError @@ -91,8 +91,8 @@ 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 = nil // add self user - if len(accountId) > 0 { - payload = []byte(accountId[0]) // add another user + if len(accountID) > 0 { + payload = []byte(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 3a9acd05..8f0034c3 100644 --- a/jira/internal/watcher_impl_test.go +++ b/jira/internal/watcher_impl_test.go @@ -171,7 +171,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { type args struct { ctx context.Context issueKeyOrID string - accountId []string + accountID []string } testCases := []struct { @@ -188,7 +188,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", - accountId: nil, + accountID: nil, }, on: func(fields *fields) { @@ -219,7 +219,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", - accountId: []string{"someAccountId"}, + accountID: []string{"someAccountID"}, }, on: func(fields *fields) { @@ -230,7 +230,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { http.MethodPost, "rest/api/3/issue/DUMMY-5/watchers", "", - []byte("someAccountId")). + []byte("someAccountID")). Return(&http.Request{}, nil) client.On("Call", @@ -250,7 +250,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", - accountId: nil, + accountID: nil, }, on: func(fields *fields) { @@ -282,7 +282,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", - accountId: []string{"someAccountId"}, + accountID: []string{"someAccountID"}, }, on: func(fields *fields) { @@ -293,7 +293,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { http.MethodPost, "rest/api/2/issue/DUMMY-5/watchers", "", - []byte("someAccountId")). + []byte("someAccountID")). Return(&http.Request{}, nil) client.On("Call", @@ -324,7 +324,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-5", - accountId: nil, + accountID: nil, }, on: func(fields *fields) { @@ -355,7 +355,7 @@ func Test_internalWatcherImpl_Add(t *testing.T) { newService, err := NewWatcherService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResponse, err := newService.Add(testCase.args.ctx, testCase.args.issueKeyOrID, testCase.args.accountId...) + gotResponse, err := newService.Add(testCase.args.ctx, testCase.args.issueKeyOrID, testCase.args.accountID...) if testCase.wantErr { diff --git a/service/jira/watcher.go b/service/jira/watcher.go index bbf72232..db0609dc 100644 --- a/service/jira/watcher.go +++ b/service/jira/watcher.go @@ -14,7 +14,7 @@ type WatcherConnector interface { // GET /rest/api/{2-3}/issue/{issueIdOrKey}/watchers // // https://docs.go-atlassian.io/jira-software-cloud/issues/watcher#get-issue-watchers - Gets(ctx context.Context, issueKeyOrId string) (*model.IssueWatcherScheme, *model.ResponseScheme, error) + Gets(ctx context.Context, issueKeyOrID string) (*model.IssueWatcherScheme, *model.ResponseScheme, error) // Add adds a user as a watcher of an issue by passing the account ID of the user. // @@ -23,12 +23,12 @@ type WatcherConnector interface { // POST /rest/api/{2-3}/issue/{issueIdOrKey}/watchers // // https://docs.go-atlassian.io/jira-software-cloud/issues/watcher#add-watcher - Add(ctx context.Context, issueKeyOrId string, accountId ...string) (*model.ResponseScheme, error) + Add(ctx context.Context, issueKeyOrID string, accountID ...string) (*model.ResponseScheme, error) // Delete deletes a user as a watcher of an issue. // // DELETE /rest/api/{2-3}/issue/{issueIdOrKey}/watchers // // https://docs.go-atlassian.io/jira-software-cloud/issues/watcher#delete-watcher - Delete(ctx context.Context, issueKeyOrId, accountId string) (*model.ResponseScheme, error) + Delete(ctx context.Context, issueKeyOrID, accountID string) (*model.ResponseScheme, error) }