feat(orchestrator): build copy plan from per-account mapping + exclusions
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package orchestrator
|
||||
|
||||
import "testing"
|
||||
|
||||
func names(ps []folderPlan) []string {
|
||||
out := make([]string, len(ps))
|
||||
for i, p := range ps {
|
||||
out[i] = p.src + "->" + p.dst
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func TestPlanFolders(t *testing.T) {
|
||||
folders := []string{"INBOX", "Спам", "Trash", "Sent"}
|
||||
|
||||
// Empty config: every folder syncs to its own name, in order.
|
||||
got := planFolders(folders, nil, nil)
|
||||
if len(got) != 4 || got[0].src != "INBOX" || got[0].dst != "INBOX" {
|
||||
t.Fatalf("empty config: %v", names(got))
|
||||
}
|
||||
|
||||
// Rename + exclusion.
|
||||
got = planFolders(folders,
|
||||
map[string]string{"Спам": "Spam"},
|
||||
[]string{"Trash"})
|
||||
if len(got) != 3 {
|
||||
t.Fatalf("want 3 plans (Trash excluded), got %v", names(got))
|
||||
}
|
||||
for _, p := range got {
|
||||
if p.src == "Trash" {
|
||||
t.Fatalf("excluded folder present: %v", names(got))
|
||||
}
|
||||
if p.src == "Спам" && p.dst != "Spam" {
|
||||
t.Fatalf("rename not applied: %v", names(got))
|
||||
}
|
||||
if p.src == "INBOX" && p.dst != "INBOX" {
|
||||
t.Fatalf("unmapped folder should keep its name: %v", names(got))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user