42 lines
937 B
Go
42 lines
937 B
Go
|
package command_test
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
"time"
|
||
|
|
||
|
"github.com/google/go-cmp/cmp"
|
||
|
"go-mod.ewintr.nl/planner/item"
|
||
|
"go-mod.ewintr.nl/planner/plan/command"
|
||
|
"go-mod.ewintr.nl/planner/plan/storage/memory"
|
||
|
"go-mod.ewintr.nl/planner/sync/client"
|
||
|
)
|
||
|
|
||
|
func TestSync(t *testing.T) {
|
||
|
t.Parallel()
|
||
|
|
||
|
syncClient := client.NewMemory()
|
||
|
syncRepo := memory.NewSync()
|
||
|
localIDRepo := memory.NewLocalID()
|
||
|
eventRepo := memory.NewEvent()
|
||
|
|
||
|
// now := time.Now()
|
||
|
|
||
|
it := item.Item{
|
||
|
ID: "a",
|
||
|
Kind: item.KindEvent,
|
||
|
Body: `{}`,
|
||
|
}
|
||
|
syncClient.Update([]item.Item{it})
|
||
|
|
||
|
if err := command.Sync(syncClient, syncRepo, localIDRepo, eventRepo, false); err != nil {
|
||
|
t.Errorf("exp nil, got %v", err)
|
||
|
}
|
||
|
actItems, actErr := syncClient.Updated([]item.Kind{item.KindEvent}, time.Time{})
|
||
|
if actErr != nil {
|
||
|
t.Errorf("exp nil, got %v", actErr)
|
||
|
}
|
||
|
if diff := cmp.Diff([]item.Item{it}, actItems); diff != "" {
|
||
|
t.Errorf("(exp +, got -)\n%s", diff)
|
||
|
}
|
||
|
}
|