Copy DeleteFileOptions struct fields into UpdateFileOptions struct (#330)

This commit is contained in:
6543 2020-05-21 10:13:32 +00:00
parent b4696d5416
commit 3c36bd251b
4 changed files with 17 additions and 20 deletions

View file

@ -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{
DeleteFileOptions: DeleteFileOptions{
FileOptions: FileOptions{
Message: "Overwrite",
BranchName: "master",
NewBranchName: "overwrite_licence",
},
SHA: masterLicence.SHA,
FileOptions: FileOptions{
Message: "Overwrite",
BranchName: "master",
NewBranchName: "overwrite_licence",
},
SHA: masterLicence.SHA,
Content: "Tk9USElORyBJUyBIRVJFIEFOWU1PUkUKSUYgWU9VIExJS0UgVE8gRklORCBTT01FVEhJTkcKV0FJVCBGT1IgVEhFIEZVVFVSRQo=",
})
if !assert.NoError(t, err) || !assert.NotNil(t, updatedFile) {

View file

@ -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{
DeleteFileOptions: DeleteFileOptions{
FileOptions: FileOptions{
Message: "update it",
BranchName: "master",
NewBranchName: "update",
},
SHA: masterLicence.SHA,
FileOptions: FileOptions{
Message: "update it",
BranchName: "master",
NewBranchName: "update",
},
SHA: masterLicence.SHA,
Content: "Tk9USElORyBJUyBIRVJFIEFOWU1PUkUKSUYgWU9VIExJS0UgVE8gRklORCBTT01FVEhJTkcKV0FJVCBGT1IgVEhFIEZVVFVSRQo=",
})
if !assert.NoError(t, err) || !assert.NotNil(t, updatedFile) {

View file

@ -46,7 +46,10 @@ type DeleteFileOptions struct {
// 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)
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
// required: true
Content string `json:"content"`

View file

@ -35,12 +35,10 @@ func TestFileCreateUpdateGet(t *testing.T) {
assert.EqualValues(t, "ZmlsZUEK", base64.StdEncoding.EncodeToString(raw))
updatedFile, err := c.UpdateFile(repo.Owner.UserName, repo.Name, "A", UpdateFileOptions{
DeleteFileOptions: DeleteFileOptions{
FileOptions: FileOptions{
Message: "add a new line",
},
SHA: newFile.Content.SHA,
FileOptions: FileOptions{
Message: "add a new line",
},
SHA: newFile.Content.SHA,
Content: "ZmlsZUEKCmFuZCBhIG5ldyBsaW5lCg==",
})
assert.NoError(t, err)