Copy DeleteFileOptions struct fields into UpdateFileOptions struct (#330)
This commit is contained in:
parent
b4696d5416
commit
3c36bd251b
4 changed files with 17 additions and 20 deletions
|
@ -134,14 +134,12 @@ func preparePullTest(t *testing.T, c *Client, repoName, forkOrg string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
updatedFile, err := c.UpdateFile(forkRepo.Owner.UserName, forkRepo.Name, "LICENSE", UpdateFileOptions{
|
updatedFile, err := c.UpdateFile(forkRepo.Owner.UserName, forkRepo.Name, "LICENSE", UpdateFileOptions{
|
||||||
DeleteFileOptions: DeleteFileOptions{
|
|
||||||
FileOptions: FileOptions{
|
FileOptions: FileOptions{
|
||||||
Message: "Overwrite",
|
Message: "Overwrite",
|
||||||
BranchName: "master",
|
BranchName: "master",
|
||||||
NewBranchName: "overwrite_licence",
|
NewBranchName: "overwrite_licence",
|
||||||
},
|
},
|
||||||
SHA: masterLicence.SHA,
|
SHA: masterLicence.SHA,
|
||||||
},
|
|
||||||
Content: "Tk9USElORyBJUyBIRVJFIEFOWU1PUkUKSUYgWU9VIExJS0UgVE8gRklORCBTT01FVEhJTkcKV0FJVCBGT1IgVEhFIEZVVFVSRQo=",
|
Content: "Tk9USElORyBJUyBIRVJFIEFOWU1PUkUKSUYgWU9VIExJS0UgVE8gRklORCBTT01FVEhJTkcKV0FJVCBGT1IgVEhFIEZVVFVSRQo=",
|
||||||
})
|
})
|
||||||
if !assert.NoError(t, err) || !assert.NotNil(t, updatedFile) {
|
if !assert.NoError(t, err) || !assert.NotNil(t, updatedFile) {
|
||||||
|
|
|
@ -61,14 +61,12 @@ func prepareBranchTest(t *testing.T, c *Client, repoName string) *Repository {
|
||||||
}
|
}
|
||||||
|
|
||||||
updatedFile, err := c.UpdateFile(origRepo.Owner.UserName, origRepo.Name, "README.md", UpdateFileOptions{
|
updatedFile, err := c.UpdateFile(origRepo.Owner.UserName, origRepo.Name, "README.md", UpdateFileOptions{
|
||||||
DeleteFileOptions: DeleteFileOptions{
|
|
||||||
FileOptions: FileOptions{
|
FileOptions: FileOptions{
|
||||||
Message: "update it",
|
Message: "update it",
|
||||||
BranchName: "master",
|
BranchName: "master",
|
||||||
NewBranchName: "update",
|
NewBranchName: "update",
|
||||||
},
|
},
|
||||||
SHA: masterLicence.SHA,
|
SHA: masterLicence.SHA,
|
||||||
},
|
|
||||||
Content: "Tk9USElORyBJUyBIRVJFIEFOWU1PUkUKSUYgWU9VIExJS0UgVE8gRklORCBTT01FVEhJTkcKV0FJVCBGT1IgVEhFIEZVVFVSRQo=",
|
Content: "Tk9USElORyBJUyBIRVJFIEFOWU1PUkUKSUYgWU9VIExJS0UgVE8gRklORCBTT01FVEhJTkcKV0FJVCBGT1IgVEhFIEZVVFVSRQo=",
|
||||||
})
|
})
|
||||||
if !assert.NoError(t, err) || !assert.NotNil(t, updatedFile) {
|
if !assert.NoError(t, err) || !assert.NotNil(t, updatedFile) {
|
||||||
|
|
|
@ -46,7 +46,10 @@ type DeleteFileOptions struct {
|
||||||
// UpdateFileOptions options for updating files
|
// UpdateFileOptions options for updating files
|
||||||
// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
|
// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
|
||||||
type UpdateFileOptions struct {
|
type UpdateFileOptions struct {
|
||||||
DeleteFileOptions
|
FileOptions
|
||||||
|
// sha is the SHA for the file that already exists
|
||||||
|
// required: true
|
||||||
|
SHA string `json:"sha"`
|
||||||
// content must be base64 encoded
|
// content must be base64 encoded
|
||||||
// required: true
|
// required: true
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
|
|
|
@ -35,12 +35,10 @@ func TestFileCreateUpdateGet(t *testing.T) {
|
||||||
assert.EqualValues(t, "ZmlsZUEK", base64.StdEncoding.EncodeToString(raw))
|
assert.EqualValues(t, "ZmlsZUEK", base64.StdEncoding.EncodeToString(raw))
|
||||||
|
|
||||||
updatedFile, err := c.UpdateFile(repo.Owner.UserName, repo.Name, "A", UpdateFileOptions{
|
updatedFile, err := c.UpdateFile(repo.Owner.UserName, repo.Name, "A", UpdateFileOptions{
|
||||||
DeleteFileOptions: DeleteFileOptions{
|
|
||||||
FileOptions: FileOptions{
|
FileOptions: FileOptions{
|
||||||
Message: "add a new line",
|
Message: "add a new line",
|
||||||
},
|
},
|
||||||
SHA: newFile.Content.SHA,
|
SHA: newFile.Content.SHA,
|
||||||
},
|
|
||||||
Content: "ZmlsZUEKCmFuZCBhIG5ldyBsaW5lCg==",
|
Content: "ZmlsZUEKCmFuZCBhIG5ldyBsaW5lCg==",
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
Loading…
Reference in a new issue