mirror of
https://github.com/go-gitea/gitea.git
synced 2025-01-13 16:32:25 +00:00
Fix test
This commit is contained in:
parent
ae4a882223
commit
5f34fac3b7
@ -175,7 +175,7 @@ func getExpectedFileResponseForRepofilesCreate(commitID, lastCommitSHA string) *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getExpectedFileResponseForRepofilesUpdate(commitID, filename, lastCommitSHA string) *api.FileResponse {
|
func getExpectedFileResponseForRepofilesUpdate(commitID, filename, lastCommitSHA string, lastCommitWhen time.Time) *api.FileResponse {
|
||||||
encoding := "base64"
|
encoding := "base64"
|
||||||
content := "VGhpcyBpcyBVUERBVEVEIGNvbnRlbnQgZm9yIHRoZSBSRUFETUUgZmlsZQ=="
|
content := "VGhpcyBpcyBVUERBVEVEIGNvbnRlbnQgZm9yIHRoZSBSRUFETUUgZmlsZQ=="
|
||||||
selfURL := setting.AppURL + "api/v1/repos/user2/repo1/contents/" + filename + "?ref=master"
|
selfURL := setting.AppURL + "api/v1/repos/user2/repo1/contents/" + filename + "?ref=master"
|
||||||
@ -184,18 +184,19 @@ func getExpectedFileResponseForRepofilesUpdate(commitID, filename, lastCommitSHA
|
|||||||
downloadURL := setting.AppURL + "user2/repo1/raw/branch/master/" + filename
|
downloadURL := setting.AppURL + "user2/repo1/raw/branch/master/" + filename
|
||||||
return &api.FileResponse{
|
return &api.FileResponse{
|
||||||
Content: &api.ContentsResponse{
|
Content: &api.ContentsResponse{
|
||||||
Name: filename,
|
Name: filename,
|
||||||
Path: filename,
|
Path: filename,
|
||||||
SHA: "dbf8d00e022e05b7e5cf7e535de857de57925647",
|
SHA: "dbf8d00e022e05b7e5cf7e535de857de57925647",
|
||||||
LastCommitSHA: lastCommitSHA,
|
LastCommitSHA: lastCommitSHA,
|
||||||
Type: "file",
|
LastCommitWhen: lastCommitWhen,
|
||||||
Size: 43,
|
Type: "file",
|
||||||
Encoding: &encoding,
|
Size: 43,
|
||||||
Content: &content,
|
Encoding: &encoding,
|
||||||
URL: &selfURL,
|
Content: &content,
|
||||||
HTMLURL: &htmlURL,
|
URL: &selfURL,
|
||||||
GitURL: &gitURL,
|
HTMLURL: &htmlURL,
|
||||||
DownloadURL: &downloadURL,
|
GitURL: &gitURL,
|
||||||
|
DownloadURL: &downloadURL,
|
||||||
Links: &api.FileLinksResponse{
|
Links: &api.FileLinksResponse{
|
||||||
Self: &selfURL,
|
Self: &selfURL,
|
||||||
GitURL: &gitURL,
|
GitURL: &gitURL,
|
||||||
@ -305,7 +306,7 @@ func TestChangeRepoFilesForUpdate(t *testing.T) {
|
|||||||
|
|
||||||
commit, _ := gitRepo.GetBranchCommit(opts.NewBranch)
|
commit, _ := gitRepo.GetBranchCommit(opts.NewBranch)
|
||||||
lastCommit, _ := commit.GetCommitByPath(opts.Files[0].TreePath)
|
lastCommit, _ := commit.GetCommitByPath(opts.Files[0].TreePath)
|
||||||
expectedFileResponse := getExpectedFileResponseForRepofilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String())
|
expectedFileResponse := getExpectedFileResponseForRepofilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String(), lastCommit.Committer.When)
|
||||||
assert.EqualValues(t, expectedFileResponse.Content, filesResponse.Files[0])
|
assert.EqualValues(t, expectedFileResponse.Content, filesResponse.Files[0])
|
||||||
assert.EqualValues(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
|
assert.EqualValues(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
|
||||||
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
|
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
|
||||||
@ -341,7 +342,7 @@ func TestChangeRepoFilesForUpdateWithFileMove(t *testing.T) {
|
|||||||
|
|
||||||
commit, _ := gitRepo.GetBranchCommit(opts.NewBranch)
|
commit, _ := gitRepo.GetBranchCommit(opts.NewBranch)
|
||||||
lastCommit, _ := commit.GetCommitByPath(opts.Files[0].TreePath)
|
lastCommit, _ := commit.GetCommitByPath(opts.Files[0].TreePath)
|
||||||
expectedFileResponse := getExpectedFileResponseForRepofilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String())
|
expectedFileResponse := getExpectedFileResponseForRepofilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String(), lastCommit.Committer.When)
|
||||||
// assert that the old file no longer exists in the last commit of the branch
|
// assert that the old file no longer exists in the last commit of the branch
|
||||||
fromEntry, err := commit.GetTreeEntryByPath(opts.Files[0].FromTreePath)
|
fromEntry, err := commit.GetTreeEntryByPath(opts.Files[0].FromTreePath)
|
||||||
switch err.(type) {
|
switch err.(type) {
|
||||||
@ -392,7 +393,7 @@ func TestChangeRepoFilesWithoutBranchNames(t *testing.T) {
|
|||||||
|
|
||||||
commit, _ := gitRepo.GetBranchCommit(repo.DefaultBranch)
|
commit, _ := gitRepo.GetBranchCommit(repo.DefaultBranch)
|
||||||
lastCommit, _ := commit.GetCommitByPath(opts.Files[0].TreePath)
|
lastCommit, _ := commit.GetCommitByPath(opts.Files[0].TreePath)
|
||||||
expectedFileResponse := getExpectedFileResponseForRepofilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String())
|
expectedFileResponse := getExpectedFileResponseForRepofilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String(), lastCommit.Committer.When)
|
||||||
assert.EqualValues(t, expectedFileResponse.Content, filesResponse.Files[0])
|
assert.EqualValues(t, expectedFileResponse.Content, filesResponse.Files[0])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user