Compare commits
No commits in common. "6fe7fe009e24ac868a31f3670df11840542ad5ed" and "4e37009599c53b82527d31dadf37a8b8daa51271" have entirely different histories.
6fe7fe009e
...
4e37009599
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
var SyncCmd = &cli.Command{
|
var SyncCmd = &cli.Command{
|
||||||
Name: "sync",
|
Name: "sync",
|
||||||
Usage: "Synchronize with server",
|
Usage: "Synchonize with server",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "full",
|
Name: "full",
|
||||||
|
@ -26,10 +26,6 @@ func NewSyncCmd(client *client.Client, localRepo storage.LocalID, eventRepo stor
|
||||||
}
|
}
|
||||||
|
|
||||||
func Sync(client *client.Client, localRepo storage.LocalID, eventRepo storage.Event, full bool) error {
|
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
|
// get new/updated items
|
||||||
|
|
||||||
// delete deleted
|
// delete deleted
|
||||||
|
@ -38,5 +34,9 @@ func Sync(client *client.Client, localRepo storage.LocalID, eventRepo storage.Ev
|
||||||
|
|
||||||
// localid and add new
|
// localid and add new
|
||||||
|
|
||||||
|
// find local new and updated
|
||||||
|
|
||||||
|
// send new and updated
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +1,14 @@
|
||||||
package memory_test
|
package memory_test
|
||||||
|
|
||||||
import (
|
import "testing"
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"go-mod.ewintr.nl/planner/item"
|
|
||||||
"go-mod.ewintr.nl/planner/plan/storage/memory"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestSync(t *testing.T) {
|
func TestSync(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
mem := memory.NewSync()
|
|
||||||
|
|
||||||
t.Log("store")
|
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")
|
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")
|
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))
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
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