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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
package cli
import (
"os"
"path/filepath"
"testing"
"codeberg.org/snonux/gitsyncer/internal/config"
)
func TestSyncBackupDescription_FileURLWritesDescription(t *testing.T) {
t.Parallel()
rootDir := t.TempDir()
repoDir := filepath.Join(rootDir, "sample.git")
if err := os.MkdirAll(repoDir, 0755); err != nil {
t.Fatalf("mkdir repo dir: %v", err)
}
org := &config.Organization{
Host: "file://" + rootDir,
BackupLocation: true,
}
supported, err := syncBackupDescription(org, "sample", "Sample description", false)
if err != nil {
t.Fatalf("syncBackupDescription() error = %v", err)
}
if !supported {
t.Fatal("expected file backup description sync to be supported")
}
content, err := os.ReadFile(filepath.Join(repoDir, "description"))
if err != nil {
t.Fatalf("read description: %v", err)
}
if string(content) != "Sample description\n" {
t.Fatalf("description = %q, want %q", string(content), "Sample description\n")
}
}
func TestSyncBackupDescription_SSHWithoutDescriptionSyncConfigIsUnsupported(t *testing.T) {
t.Parallel()
org := &config.Organization{
Host: "ssh://git@example.com/repos",
BackupLocation: true,
}
supported, err := syncBackupDescription(org, "sample", "Sample description", false)
if err != nil {
t.Fatalf("syncBackupDescription() error = %v", err)
}
if supported {
t.Fatal("expected SSH backup description sync without config to be unsupported")
}
}
|