Compare commits
2 Commits
4e37009599
...
6fe7fe009e
Author | SHA1 | Date |
---|---|---|
Erik Winter | 6fe7fe009e | |
Erik Winter | 5ab5505d2b |
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
var SyncCmd = &cli.Command{
|
||||
Name: "sync",
|
||||
Usage: "Synchonize with server",
|
||||
Usage: "Synchronize with server",
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "full",
|
||||
|
@ -26,6 +26,10 @@ func NewSyncCmd(client *client.Client, localRepo storage.LocalID, eventRepo stor
|
|||
}
|
||||
|
||||
func Sync(client *client.Client, localRepo storage.LocalID, eventRepo storage.Event, full bool) error {
|
||||
// find local new and updated
|
||||
|
||||
// send new and updated
|
||||
//
|
||||
// get new/updated items
|
||||
|
||||
// delete deleted
|
||||
|
@ -34,9 +38,5 @@ func Sync(client *client.Client, localRepo storage.LocalID, eventRepo storage.Ev
|
|||
|
||||
// localid and add new
|
||||
|
||||
// find local new and updated
|
||||
|
||||
// send new and updated
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,14 +1,45 @@
|
|||
package memory_test
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"go-mod.ewintr.nl/planner/item"
|
||||
"go-mod.ewintr.nl/planner/plan/storage/memory"
|
||||
)
|
||||
|
||||
func TestSync(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
mem := memory.NewSync()
|
||||
|
||||
t.Log("store")
|
||||
count := 3
|
||||
for i := 0; i < count; i++ {
|
||||
mem.Store(item.Item{
|
||||
ID: fmt.Sprintf("id-%d", i),
|
||||
})
|
||||
}
|
||||
|
||||
t.Log("find all")
|
||||
actItems, actErr := mem.FindAll()
|
||||
if actErr != nil {
|
||||
t.Errorf("exp nil, got %v", actErr)
|
||||
}
|
||||
if len(actItems) != count {
|
||||
t.Errorf("exp %v, got %v", count, len(actItems))
|
||||
}
|
||||
|
||||
t.Log("delete all")
|
||||
if err := mem.DeleteAll(); err != nil {
|
||||
t.Errorf("exp nil, got %v", err)
|
||||
}
|
||||
actItems, actErr = mem.FindAll()
|
||||
if actErr != nil {
|
||||
t.Errorf("exp nil, got %v", actErr)
|
||||
}
|
||||
if len(actItems) != 0 {
|
||||
t.Errorf("exp 0, got %v", len(actItems))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go-mod.ewintr.nl/planner/item"
|
||||
)
|
||||
|
||||
type Memory struct {
|
||||
}
|
||||
|
||||
func NewMemory() *Memory {
|
||||
return &Memory{}
|
||||
}
|
||||
|
||||
func (m *Memory) Update(items []item.Item) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Memory) Updated(kw []item.Kind, ts time.Time) ([]item.Item, error) {
|
||||
return nil, nil
|
||||
}
|
Loading…
Reference in New Issue