add removal test
This commit is contained in:
parent
48711af1d9
commit
9ce35aeb45
2 changed files with 55 additions and 3 deletions
22
cayley.go
22
cayley.go
|
|
@ -191,6 +191,28 @@ func main() {
|
|||
}
|
||||
|
||||
func load(qw graph.QuadWriter, cfg *config.Config, path, typ string) error {
|
||||
return decompressAndLoad(qw, cfg, path, typ, db.Load)
|
||||
}
|
||||
|
||||
func removeAll(qw graph.QuadWriter, cfg *config.Config, path, typ string) error {
|
||||
return decompressAndLoad(qw, cfg, path, typ, remove)
|
||||
}
|
||||
|
||||
func remove(qw graph.QuadWriter, cfg *config.Config, dec quad.Unmarshaler) error {
|
||||
for {
|
||||
t, err := dec.Unmarshal()
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
return err
|
||||
}
|
||||
qw.RemoveQuad(t)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func decompressAndLoad(qw graph.QuadWriter, cfg *config.Config, path, typ string, loadFn func(graph.QuadWriter, *config.Config, quad.Unmarshaler) error) error {
|
||||
var r io.Reader
|
||||
|
||||
if path == "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue