aboutsummaryrefslogtreecommitdiffsponsor
path: root/internal/github/github_test.go
blob: 5f3a27026979ff92469d6b5b4c331f8370865196 (plain)
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
package github

import (
	"os"
	"path"
	"testing"

	"git.server.ky/slackcoder/mirror/internal"
	"github.com/stretchr/testify/require"
)

func TestMirrorDendrite(t *testing.T) {
	d := t.TempDir()

	dst := internal.MustURL(d)
	src := internal.MustURL("https://github.com/matrix-org/dendrite")
	oldFile := "random_file.txt"

	f, cErr := os.Create(path.Join(dst.Path, oldFile))
	require.NoError(t, cErr)
	f.Close()

	c := NewClient()
	err := c.MirrorAssets(dst, src)
	require.NoError(t, err, "dendrite assets")

	require.FileExists(t, path.Join(dst.Path, "v0.13.7", "dendrite-0.13.7.tar.gz"))
	require.FileExists(t, path.Join(dst.Path, "v0.13.7", "dendrite-0.13.7.zip"))

	err = c.MirrorAssets(dst, src)
	require.NoError(t, err, "dendrite assets")

	require.NoFileExists(t, path.Join(dst.Path, oldFile), "only files from mirror should exist")
}