-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathserver_test.go
executable file
·42 lines (36 loc) · 1.36 KB
/
server_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2023 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package git
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestUpdateServerInfo(t *testing.T) {
err := os.RemoveAll(filepath.Join(repoPath, "info"))
require.NoError(t, err)
err = UpdateServerInfo(repoPath, UpdateServerInfoOptions{Force: true})
require.NoError(t, err)
assert.True(t, isFile(filepath.Join(repoPath, "info", "refs")))
}
func TestReceivePack(t *testing.T) {
got, err := ReceivePack(repoPath, ReceivePackOptions{HTTPBackendInfoRefs: true})
require.NoError(t, err)
const contains = "report-status report-status-v2 delete-refs side-band-64k quiet atomic ofs-delta object-format=sha1 agent=git/"
assert.Contains(t, string(got), contains)
}
func TestUploadPack(t *testing.T) {
got, err := UploadPack(repoPath,
UploadPackOptions{
StatelessRPC: true,
Strict: true,
HTTPBackendInfoRefs: true,
},
)
require.NoError(t, err)
const contains = "multi_ack thin-pack side-band side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag multi_ack_detailed no-done symref=HEAD:refs/heads/master object-format=sha1 agent=git/"
assert.Contains(t, string(got), contains)
}