Compare commits

..

No commits in common. "65e8a972e4f318d30d6363f7e5a1616e6bb2b557" and "405cf05341030c6f0de10fab982008d9f4d0c4cc" have entirely different histories.

5 changed files with 4 additions and 40 deletions

View File

@ -38,6 +38,9 @@ func (ml *LocalID) Find(id string) (int, error) {
}
func (ml *LocalID) FindOrNext(id string) (int, error) {
ml.mutex.Lock()
defer ml.mutex.Unlock()
lid, err := ml.Find(id)
switch {
case errors.Is(err, storage.ErrNotFound):

View File

@ -45,14 +45,6 @@ func TestLocalID(t *testing.T) {
if actLid != 1 {
t.Errorf("exp 1, git %v", actLid)
}
t.Log("retrieve unknown")
actLid, actErr = repo.FindOrNext("new")
if actErr != nil {
t.Errorf("exp nil, got %v", actErr)
}
if actLid != 2 {
t.Errorf("exp 2, got %v", actLid)
}
actIDs, actErr = repo.FindAll()
if actErr != nil {

View File

@ -3,7 +3,6 @@ package memory
import (
"sort"
"sync"
"time"
"go-mod.ewintr.nl/planner/item"
)
@ -51,17 +50,3 @@ func (r *Sync) DeleteAll() error {
return nil
}
func (r *Sync) LastUpdate() (time.Time, error) {
r.mutex.RLock()
defer r.mutex.RUnlock()
var last time.Time
for _, i := range r.items {
if i.Updated.After(last) {
last = i.Updated
}
}
return last, nil
}

View File

@ -3,7 +3,6 @@ package memory_test
import (
"fmt"
"testing"
"time"
"go-mod.ewintr.nl/planner/item"
"go-mod.ewintr.nl/planner/plan/storage/memory"
@ -15,15 +14,11 @@ func TestSync(t *testing.T) {
mem := memory.NewSync()
t.Log("store")
now := time.Now()
ts := now
count := 3
for i := 0; i < count; i++ {
mem.Store(item.Item{
ID: fmt.Sprintf("id-%d", i),
Updated: ts,
})
ts = ts.Add(-1 * time.Minute)
}
t.Log("find all")
@ -35,15 +30,6 @@ func TestSync(t *testing.T) {
t.Errorf("exp %v, got %v", count, len(actItems))
}
t.Log("last update")
actLU, actErr := mem.LastUpdate()
if actErr != nil {
t.Errorf("exp nil, got %v", actErr)
}
if !actLU.Equal(now) {
t.Errorf("exp %v, got %v", now, actLU)
}
t.Log("delete all")
if err := mem.DeleteAll(); err != nil {
t.Errorf("exp nil, got %v", err)

View File

@ -3,7 +3,6 @@ package storage
import (
"errors"
"sort"
"time"
"go-mod.ewintr.nl/planner/item"
)
@ -24,7 +23,6 @@ type Sync interface {
FindAll() ([]item.Item, error)
Store(i item.Item) error
DeleteAll() error
LastUpdate() (time.Time, error)
}
type Event interface {