First commit Go counter service
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package counting
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/colinmarc/cdb"
|
||||
|
||||
"migadu_counters/internal/domains"
|
||||
)
|
||||
|
||||
func TestReview_MalformedRowFailsWholeRequest(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "d.cdb")
|
||||
w, err := cdb.Create(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
w.Put([]byte("good.example"), []byte("7|A/o=5,A/i=5"))
|
||||
w.Put([]byte("bad.example"), []byte("|A/i=5")) // org id missing (malformed row)
|
||||
if _, err := w.Freeze(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
db, err := domains.Open(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer db.Close()
|
||||
p := &Planner{Lookup: db, Now: time.Now}
|
||||
plan, err := p.PlanOut("t", "x@good.example", "x@good.example", "y@bad.example")
|
||||
t.Logf("PlanOut(good sender -> malformed-row recipient): plan=%v err=%v", plan, err)
|
||||
plan, err = p.PlanIn("t", "s@gmail.com", "y@bad.example", false)
|
||||
t.Logf("PlanIn(malformed-row recipient): plan=%v err=%v", plan, err)
|
||||
}
|
||||
Reference in New Issue
Block a user