package emitter import ( "strings" "testing" "git.cloudinit.dev/coreci/orca/internal/jobspec" ) func TestSyncthingEmitter_TwoReplicatedVolumes_TwoFiles(t *testing.T) { spec := &jobspec.WorkloadSpec{ Kind: "Service", Name: "team-alpha", Volumes: []jobspec.VolumeSpec{ {Name: "data", Source: "replicate:peer-b,peer-c", Target: "/var/lib/orca/data"}, {Name: "logs", Source: "replicate:peer-b", Target: "/var/lib/orca/logs"}, {Name: "cache", Source: "/local/cache", Target: "/cache"}, // not replicated }, } node := &Node{Hostname: "peer-a", Runtime: []string{"process"}} files, err := (SyncthingEmitter{}).Render(spec, node) if err != nil { t.Fatalf("Render: %v", err) } if len(files) != 2 { t.Fatalf("expected 2 files (only replicated volumes), got %d", len(files)) } for _, f := range files { if !strings.HasPrefix(f.Path, "/etc/syncthing/orca-team-alpha-") { t.Errorf("path %q does not start with /etc/syncthing/orca-team-alpha-", f.Path) } if !strings.HasSuffix(f.Path, ".xml") { t.Errorf("path %q does not end with .xml", f.Path) } if f.Mode != "0644" { t.Errorf("mode = %q, want 0644", f.Mode) } if !strings.Contains(f.Content, "