mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-11 22:15:38 +02:00
add integration test for service
This commit is contained in:
parent
1763aef3f7
commit
1cac1828b9
@ -229,3 +229,15 @@ func doGitPull(dstPath string, args ...string) func(*testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// doGitRemoteArchive runs a git archive command requesting an archive from remote
|
||||||
|
// and verifies that the command did not error out and returned only normal output
|
||||||
|
func doGitRemoteArchive(remote string, args ...string) func(*testing.T) {
|
||||||
|
return func(t *testing.T) {
|
||||||
|
stdout, stderr, err := gitcmd.NewCommand("archive").AddOptionValues("--remote", remote).AddArguments(gitcmd.ToTrustedCmdArgs(args)...).
|
||||||
|
RunStdString(t.Context())
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Empty(t, stderr)
|
||||||
|
assert.NotEmpty(t, stdout)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -12,7 +12,6 @@ import (
|
|||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/test"
|
"code.gitea.io/gitea/modules/test"
|
||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@ -21,6 +20,7 @@ func TestGitSmartHTTP(t *testing.T) {
|
|||||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||||
testGitSmartHTTP(t, u)
|
testGitSmartHTTP(t, u)
|
||||||
testRenamedRepoRedirect(t)
|
testRenamedRepoRedirect(t)
|
||||||
|
testGitArchiveRemote(t, u)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,3 +96,10 @@ func testRenamedRepoRedirect(t *testing.T) {
|
|||||||
resp = MakeRequest(t, req, http.StatusOK)
|
resp = MakeRequest(t, req, http.StatusOK)
|
||||||
assert.Contains(t, resp.Body.String(), "65f1bf27bc3bf70f64657658635e66094edbcb4d\trefs/tags/v1.1")
|
assert.Contains(t, resp.Body.String(), "65f1bf27bc3bf70f64657658635e66094edbcb4d\trefs/tags/v1.1")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testGitArchiveRemote(t *testing.T, u *url.URL) {
|
||||||
|
u = u.JoinPath("user27/repo49.git")
|
||||||
|
t.Run("Fetch HEAD archive", doGitRemoteArchive(u.String(), "HEAD"))
|
||||||
|
t.Run("Fetch HEAD archive subpath", doGitRemoteArchive(u.String(), "HEAD", "test"))
|
||||||
|
t.Run("list compression options", doGitRemoteArchive(u.String(), "--list"))
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user