summaryrefslogtreecommitdiff
path: root/internal/cli/description_sync_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-28 10:16:18 +0200
committerPaul Buetow <paul@buetow.org>2026-03-28 10:16:18 +0200
commit73c6a37ecf0aac04711e5624455743b3493a7ef5 (patch)
treeac58cce0dcd03ccac3f5f3e313a46ebe9d352b30 /internal/cli/description_sync_test.go
parent1615abaacccdbb5002404a77270fd333ce8ad718 (diff)
feat(sync): auto-sync full backups and showcase cgit linksv0.17.0
Diffstat (limited to 'internal/cli/description_sync_test.go')
-rw-r--r--internal/cli/description_sync_test.go57
1 files changed, 57 insertions, 0 deletions
diff --git a/internal/cli/description_sync_test.go b/internal/cli/description_sync_test.go
new file mode 100644
index 0000000..8f92349
--- /dev/null
+++ b/internal/cli/description_sync_test.go
@@ -0,0 +1,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")
+ }
+}