code.gitea.io/gitea@v1.22.3/tests/integration/repo_archive_test.go (about) 1 // Copyright 2024 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package integration 5 6 import ( 7 "io" 8 "net/http" 9 "testing" 10 11 "code.gitea.io/gitea/modules/setting" 12 "code.gitea.io/gitea/modules/test" 13 "code.gitea.io/gitea/routers" 14 "code.gitea.io/gitea/routers/web" 15 "code.gitea.io/gitea/tests" 16 17 "github.com/stretchr/testify/assert" 18 ) 19 20 func TestRepoDownloadArchive(t *testing.T) { 21 defer tests.PrepareTestEnv(t)() 22 defer test.MockVariableValue(&setting.EnableGzip, true)() 23 defer test.MockVariableValue(&web.GzipMinSize, 10)() 24 defer test.MockVariableValue(&testWebRoutes, routers.NormalRoutes())() 25 26 req := NewRequest(t, "GET", "/user2/repo1/archive/master.zip") 27 req.Header.Set("Accept-Encoding", "gzip") 28 resp := MakeRequest(t, req, http.StatusOK) 29 bs, err := io.ReadAll(resp.Body) 30 assert.NoError(t, err) 31 assert.Empty(t, resp.Header().Get("Content-Encoding")) 32 assert.Equal(t, 320, len(bs)) 33 }