git-module

fork of https://git.lin.moe/gogs/git-module

git clone git://git.lin.moe/fork/git-module.git

 1package git
 2
 3import (
 4	"context"
 5	"os"
 6	"path/filepath"
 7	"strconv"
 8	"testing"
 9	"time"
10
11	"github.com/stretchr/testify/assert"
12)
13
14func tempPath() string {
15	return filepath.Join(os.TempDir(), strconv.Itoa(int(time.Now().UnixNano())))
16}
17
18func TestCommit_Archive(t *testing.T) {
19	ctx := context.Background()
20	for _, format := range []ArchiveFormat{
21		ArchiveZip,
22		ArchiveTarGz,
23	} {
24		t.Run(string(format), func(t *testing.T) {
25			c, err := testrepo.CatFileCommit(ctx, testrepoMarks[1].String())
26			if err != nil {
27				t.Fatal(err)
28			}
29
30			dst := tempPath()
31			defer func() {
32				_ = os.Remove(dst)
33			}()
34
35			assert.Nil(t, c.Archive(ctx, format, dst))
36		})
37	}
38}