Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
var levelgraph = require('../lib/levelgraph') | ||
, multilevel = require('multilevel') | ||
, level = require('level-test')() | ||
, osenv = require('osenv'); | ||
|
||
describe('a multileveled triple store', function() { | ||
|
||
var db, graph, leveldb, server, client; | ||
|
||
beforeEach(function() { | ||
db = level(); | ||
server = multilevel.server(db); | ||
client = multilevel.client(); | ||
graph = levelgraph(client); | ||
|
||
server.pipe(client.createRpcStream()).pipe(server); | ||
}); | ||
|
||
it('should put a triple', function(done) { | ||
var triple = { subject: 'a', predicate: 'b', object: 'c' }; | ||
graph.put(triple, done); | ||
}); | ||
|
||
it('should get a triple', function(done) { | ||
var triple = { subject: 'a', predicate: 'b', object: 'c' }; | ||
graph.put(triple, function() { | ||
graph.get({ subject: 'a' }, function(err, list) { | ||
expect(list).to.eql([triple]); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should search a triple', function(done) { | ||
var triple = { subject: 'a', predicate: 'b', object: 'c' }; | ||
graph.put(triple, function() { | ||
graph.search([{ subject: { name: 'x' }, predicate: 'b', object: 'c' }], function(err, list) { | ||
expect(list).to.eql([{ x: 'a' }]); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should put a triple with a stream', function(done) { | ||
var triple = { subject: 'a', predicate: 'b', object: 'c' }; | ||
var stream = graph.putStream(); | ||
stream.on('end', done); | ||
stream.end(triple); | ||
}); | ||
|
||
it('should not close anything', function(done) { | ||
graph.close(done); | ||
}); | ||
}); |