Test for export offset and fix
parent
b423adde4a
commit
6ca0a90134
|
|
@ -49,8 +49,10 @@ func portPost(g storage.Graph, w http.ResponseWriter, r *http.Request) error {
|
|||
return err
|
||||
}
|
||||
|
||||
inserted := 0
|
||||
|
||||
var errIn error
|
||||
n, err := jsonparser.ArrayEach(b, func(b []byte, _ jsonparser.ValueType, _ int, err error) {
|
||||
_, err = jsonparser.ArrayEach(b, func(b []byte, _ jsonparser.ValueType, _ int, err error) {
|
||||
if err != nil {
|
||||
errIn = err
|
||||
return
|
||||
|
|
@ -66,6 +68,8 @@ func portPost(g storage.Graph, w http.ResponseWriter, r *http.Request) error {
|
|||
errIn = err
|
||||
return
|
||||
}
|
||||
|
||||
inserted += 1
|
||||
}, namespace)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -74,5 +78,5 @@ func portPost(g storage.Graph, w http.ResponseWriter, r *http.Request) error {
|
|||
return errIn
|
||||
}
|
||||
|
||||
return json.NewEncoder(w).Encode(map[string]int{namespace: n})
|
||||
return json.NewEncoder(w).Encode(map[string]int{namespace: inserted})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package view
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"local/dndex/storage"
|
||||
"net/http"
|
||||
|
|
@ -102,10 +103,24 @@ func TestPort(t *testing.T) {
|
|||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("%d: %s", w.Code, w.Body.Bytes())
|
||||
}
|
||||
var resp map[string]int
|
||||
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
n := 0
|
||||
for k, v := range resp {
|
||||
if k != "col" || v == 0 {
|
||||
t.Fatal(resp)
|
||||
}
|
||||
n = v
|
||||
}
|
||||
if n == 0 {
|
||||
t.Fatal(n, resp, string(w.Body.Bytes()))
|
||||
}
|
||||
|
||||
if ones, err := g.List(context.TODO(), "col"); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if len(ones) < 10 {
|
||||
} else if len(ones) != n {
|
||||
t.Fatal(len(ones))
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue