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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inserted := 0
|
||||||
|
|
||||||
var errIn error
|
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 {
|
if err != nil {
|
||||||
errIn = err
|
errIn = err
|
||||||
return
|
return
|
||||||
|
|
@ -66,6 +68,8 @@ func portPost(g storage.Graph, w http.ResponseWriter, r *http.Request) error {
|
||||||
errIn = err
|
errIn = err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inserted += 1
|
||||||
}, namespace)
|
}, namespace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -74,5 +78,5 @@ func portPost(g storage.Graph, w http.ResponseWriter, r *http.Request) error {
|
||||||
return errIn
|
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 (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"local/dndex/storage"
|
"local/dndex/storage"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -102,10 +103,24 @@ func TestPort(t *testing.T) {
|
||||||
if w.Code != http.StatusOK {
|
if w.Code != http.StatusOK {
|
||||||
t.Fatalf("%d: %s", w.Code, w.Body.Bytes())
|
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 {
|
if ones, err := g.List(context.TODO(), "col"); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else if len(ones) < 10 {
|
} else if len(ones) != n {
|
||||||
t.Fatal(len(ones))
|
t.Fatal(len(ones))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue