feat(store): per-account folder_mapping + excluded_folders columns
This commit is contained in:
@@ -64,3 +64,31 @@ func TestResetAccountCounters(t *testing.T) {
|
||||
a.Copied, a.Skipped, a.Errors)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetAccountFolderMapping(t *testing.T) {
|
||||
s := testStore(t)
|
||||
ctx := context.Background()
|
||||
epSrc, _ := s.CreateEndpoint(ctx, Endpoint{RoleLabel: "src", Host: "a", Port: 993, TLSMode: "ssl"})
|
||||
epDst, _ := s.CreateEndpoint(ctx, Endpoint{RoleLabel: "dst", Host: "b", Port: 993, TLSMode: "ssl"})
|
||||
taskID, _ := s.CreateTask(ctx, Task{Name: "t", SrcEndpointID: epSrc, DstEndpointID: epDst})
|
||||
accID, _ := s.CreateAccount(ctx, Account{TaskID: taskID, SrcLogin: "u", SrcPassEnc: "x", DstLogin: "u2", DstPassEnc: "y"})
|
||||
|
||||
// Fresh account defaults: empty map, empty exclusions (not nil after scan).
|
||||
accs, _ := s.ListAccountsByTask(ctx, taskID)
|
||||
if len(accs) != 1 || len(accs[0].FolderMapping) != 0 || len(accs[0].ExcludedFolders) != 0 {
|
||||
t.Fatalf("defaults: map=%v excl=%v", accs[0].FolderMapping, accs[0].ExcludedFolders)
|
||||
}
|
||||
|
||||
if err := s.SetAccountFolderMapping(ctx, accID,
|
||||
map[string]string{"Спам": "Spam"}, []string{"Trash"}); err != nil {
|
||||
t.Fatalf("set: %v", err)
|
||||
}
|
||||
accs, _ = s.ListAccountsByTask(ctx, taskID)
|
||||
a := accs[0]
|
||||
if a.FolderMapping["Спам"] != "Spam" {
|
||||
t.Fatalf("mapping not persisted: %v", a.FolderMapping)
|
||||
}
|
||||
if len(a.ExcludedFolders) != 1 || a.ExcludedFolders[0] != "Trash" {
|
||||
t.Fatalf("excluded not persisted: %v", a.ExcludedFolders)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user