Skip to content

Commit be4401b

Browse files
committed
Fix fmt and duplicate test declarations
1 parent ec80f51 commit be4401b

File tree

2 files changed

+10
-47
lines changed

2 files changed

+10
-47
lines changed

accounts.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -456,20 +456,20 @@ func (s *AccountsService) GetSSHKey(ctx context.Context, accountID, sshKeyID str
456456
// AddSSHKey adds an SSH key to a user's account.
457457
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#add-ssh-key
458458
func (s *AccountsService) AddSSHKey(ctx context.Context, accountID string, SSHKey string) (*SSHKeyInfo, *Response, error) {
459-
u := fmt.Sprintf("accounts/%s/sshkeys", accountID)
459+
u := fmt.Sprintf("accounts/%s/sshkeys", accountID)
460460

461-
req, err := s.client.NewRequest(ctx, "POST", u, SSHKey)
462-
if err != nil {
463-
return nil, nil, err
464-
}
461+
req, err := s.client.NewRequest(ctx, "POST", u, SSHKey)
462+
if err != nil {
463+
return nil, nil, err
464+
}
465465

466466
req.Header.Set("Content-Type", "text/plain")
467467

468-
var keyInfo SSHKeyInfo
469-
resp, err := s.client.Do(req, &keyInfo)
470-
if err != nil {
471-
return nil, resp, err
472-
}
468+
var keyInfo SSHKeyInfo
469+
resp, err := s.client.Do(req, &keyInfo)
470+
if err != nil {
471+
return nil, resp, err
472+
}
473473

474474
return &keyInfo, resp, nil
475475
}

accounts_test.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,10 @@ import (
55
"fmt"
66
"io"
77
"net/http"
8-
"net/http/httptest"
98
"strings"
109
"testing"
11-
12-
"github.com/andygrunwald/go-gerrit"
13-
)
14-
15-
const (
16-
// testGerritInstanceURL is a test instance url that won`t be called
17-
testGerritInstanceURL = "https://go-review.googlesource.com/"
18-
)
19-
20-
var (
21-
// testMux is the HTTP request multiplexer used with the test server.
22-
testMux *http.ServeMux
23-
24-
// testClient is the gerrit client being tested.
25-
testClient *gerrit.Client
26-
27-
// testServer is a test HTTP server used to provide mock API responses.
28-
testServer *httptest.Server
2910
)
3011

31-
type testValues map[string]string
32-
33-
// setup sets up a test HTTP server along with a gerrit.Client that is configured to talk to that test server.
34-
// Tests should register handlers on mux which provide mock responses for the API method being tested.
35-
func setup() {
36-
// Test server
37-
testMux = http.NewServeMux()
38-
testServer = httptest.NewServer(testMux)
39-
40-
// gerrit client configured to use test server
41-
testClient, _ = gerrit.NewClient(context.Background(), testServer.URL, nil)
42-
}
43-
44-
// teardown closes the test HTTP server.
45-
func teardown() {
46-
testServer.Close()
47-
}
48-
4912
// TestAddSSHKey tests the addition of an SSH key to an account.
5013
func TestAddSSHKey(t *testing.T) {
5114
setup()

0 commit comments

Comments
 (0)