Skip to content

Commit ed57927

Browse files
committed
Use NewRequestWithJSON for POST tests
1 parent 51befcf commit ed57927

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

integrations/api_repo_lfs_locks_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
package integrations
66

77
import (
8-
"io/ioutil"
8+
"fmt"
99
"net/http"
10-
"strings"
1110
"testing"
1211
"time"
1312

@@ -102,10 +101,9 @@ func TestAPILFSLocksLogged(t *testing.T) {
102101
//create locks
103102
for _, test := range tests {
104103
session := loginUser(t, test.user.Name)
105-
req := NewRequestf(t, "POST", "/%s/info/lfs/locks", test.repo.FullName())
104+
req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/%s/info/lfs/locks", test.repo.FullName()), map[string]string{"path": test.path})
106105
req.Header.Set("Accept", "application/vnd.git-lfs+json")
107106
req.Header.Set("Content-Type", "application/vnd.git-lfs+json")
108-
req.Body = ioutil.NopCloser(strings.NewReader("{\"path\": \"" + test.path + "\"}"))
109107
session.MakeRequest(t, req, test.httpResult)
110108
if len(test.addTime) > 0 {
111109
for _, id := range test.addTime {
@@ -129,10 +127,9 @@ func TestAPILFSLocksLogged(t *testing.T) {
129127
assert.WithinDuration(t, test.locksTimes[i], lock.LockedAt, 1*time.Second)
130128
}
131129

132-
req = NewRequestf(t, "POST", "/%s/info/lfs/locks/verify", test.repo.FullName())
130+
req = NewRequestWithJSON(t, "POST", fmt.Sprintf("/%s/info/lfs/locks/verify", test.repo.FullName()), map[string]string{})
133131
req.Header.Set("Accept", "application/vnd.git-lfs+json")
134132
req.Header.Set("Content-Type", "application/vnd.git-lfs+json")
135-
req.Body = ioutil.NopCloser(strings.NewReader("{}"))
136133
resp = session.MakeRequest(t, req, http.StatusOK)
137134
var lfsLocksVerify api.LFSLockListVerify
138135
DecodeJSON(t, resp, &lfsLocksVerify)
@@ -154,10 +151,9 @@ func TestAPILFSLocksLogged(t *testing.T) {
154151
//remove all locks
155152
for _, test := range deleteTests {
156153
session := loginUser(t, test.user.Name)
157-
req := NewRequestf(t, "POST", "/%s/info/lfs/locks/%s/unlock", test.repo.FullName(), test.lockID)
154+
req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/%s/info/lfs/locks/%s/unlock", test.repo.FullName(), test.lockID), map[string]string{})
158155
req.Header.Set("Accept", "application/vnd.git-lfs+json")
159156
req.Header.Set("Content-Type", "application/vnd.git-lfs+json")
160-
req.Body = ioutil.NopCloser(strings.NewReader("{}"))
161157
resp := session.MakeRequest(t, req, http.StatusOK)
162158
var lfsLockRep api.LFSLockResponse
163159
DecodeJSON(t, resp, &lfsLockRep)

0 commit comments

Comments
 (0)