1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-23 01:48:27 +00:00

Return 400 but not 500 when request archive with wrong format (#17691) (#17700)

* Return 400 but not 500 when request archive with wrong format (#17691)
* Remove bundle because it's not in this version
This commit is contained in:
Lunny Xiao
2021-11-20 00:31:29 +08:00
committed by GitHub
parent 7be2d7b136
commit a08856606e
4 changed files with 72 additions and 9 deletions

View File

@@ -5,6 +5,7 @@
package archiver
import (
"errors"
"path/filepath"
"testing"
"time"
@@ -19,10 +20,6 @@ func TestMain(m *testing.M) {
models.MainTest(m, filepath.Join("..", ".."))
}
func waitForCount(t *testing.T, num int) {
}
func TestArchive_Basic(t *testing.T) {
assert.NoError(t, models.PrepareTestDatabase())
@@ -83,11 +80,8 @@ func TestArchive_Basic(t *testing.T) {
inFlight[2] = secondReq
ArchiveRepository(zipReq)
waitForCount(t, 1)
ArchiveRepository(tgzReq)
waitForCount(t, 2)
ArchiveRepository(secondReq)
waitForCount(t, 3)
// Make sure sending an unprocessed request through doesn't affect the queue
// count.
@@ -132,3 +126,8 @@ func TestArchive_Basic(t *testing.T) {
assert.NotEqual(t, zipReq.GetArchiveName(), tgzReq.GetArchiveName())
assert.NotEqual(t, zipReq.GetArchiveName(), secondReq.GetArchiveName())
}
func TestErrUnknownArchiveFormat(t *testing.T) {
var err = ErrUnknownArchiveFormat{RequestFormat: "master"}
assert.True(t, errors.Is(err, ErrUnknownArchiveFormat{}))
}