Permalink
Browse files

locking: update schemas correctly

1 parent 40f02da commit 2e1cae8ee646d3d19e097ef0594f367c99d93d2b @ttaylorr ttaylorr committed Dec 14, 2017
Showing with 23 additions and 6 deletions.
  1. +3 −3 locking/api.go
  2. +6 −1 locking/api_test.go
  3. +7 −1 locking/schemas/http-lock-create-request-schema.json
  4. +7 −1 locking/schemas/http-lock-delete-request-schema.json
View
@@ -22,7 +22,7 @@ type lockRef struct {
type lockRequest struct {
// Path is the path that the client would like to obtain a lock against.
Path string `json:"path"`
- Ref *lockRef `json:"ref"`
+ Ref *lockRef `json:"ref,omitempty"`
}
// LockResponse encapsulates the information sent over the API in response to
@@ -72,7 +72,7 @@ type unlockRequest struct {
// unlocked; that is to say whether or not a given individual should be
// able to break a different individual's lock.
Force bool `json:"force"`
- Ref *lockRef `json:"ref"`
+ Ref *lockRef `json:"ref,omitempty"`
}
// UnlockResponse is the result sent back from the API when asked to remove a
@@ -208,7 +208,7 @@ func (c *lockClient) Search(remote string, searchReq *lockSearchRequest) (*lockL
// lockVerifiableRequest encapsulates the request sent to the server when the
// client would like a list of locks to verify a Git push.
type lockVerifiableRequest struct {
- Ref *lockRef `json:"ref"`
+ Ref *lockRef `json:"ref,omitempty"`
// Cursor is an optional field used to tell the server which lock was
// seen last, if scanning through multiple pages of results.
View
@@ -10,6 +10,7 @@ import (
"strings"
"testing"
+ "github.com/git-lfs/git-lfs/git"
"github.com/git-lfs/git-lfs/lfsapi"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -107,7 +108,11 @@ func TestAPIUnlock(t *testing.T) {
require.Nil(t, err)
lc := &lockClient{Client: c}
- unlockRes, res, err := lc.Unlock(nil, "", "123", true)
+ unlockRes, res, err := lc.Unlock(&git.Ref{
+ Name: "master",
+ Sha: "6161616161616161616161616161616161616161",
+ Type: git.RefTypeLocalBranch,
+ }, "", "123", true)
require.Nil(t, err)
assert.Equal(t, 200, res.StatusCode)
assert.Equal(t, "123", unlockRes.Lock.Id)
@@ -7,7 +7,13 @@
"type": "string"
},
"ref": {
- "type": "string"
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ }
+ },
+ "required": ["name"]
}
},
"required": ["path"]
@@ -7,7 +7,13 @@
"type": "boolean"
},
"ref": {
- "type": "string"
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ }
+ },
+ "required": ["name"]
}
}
}

0 comments on commit 2e1cae8

Please sign in to comment.