small medium large xlarge

07 May 2017, 16:48
Robert J. Peek (1 post)

This is what I get when I run “node –harmony $(which nodeunit) test/”

test-rdf-parser ✖ testRDFParser

AssertionError: { _id: ‘132’ } deepEqual { _id: ‘132’, title: ‘The Art of War’, authors: [ ‘Sunzi (6th cent. BC)’, ‘Giles, Lionel’ ], subjects: [ ‘Military art and science – Early works to 1800’, ‘War – Early works to 1800’ ] } at Object.deepEqual (/usr/local/lib/node_modules/nodeunit/lib/types.js:83:39) at /home/rjpeek/nodeTutorials/NodeTheRightWay/databases/test/test-rdf-parser.js:9:10 at /home/rjpeek/nodeTutorials/NodeTheRightWay/databases/lib/rdf-parser.js:15:5 at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:439:3)

FAILURES: 1/2 assertions failed (153ms)

Here is my code for test-rdf-parser.js

{ “_id”: “132”, “title”: “The Art of War”, “authors”: [ “Sunzi (6th cent. BC)”, “Giles, Lionel” ], “subjects”: [ “Military art and science – Early works to 1800”, “War – Early works to 1800” ] }

Here is my code for test_-rdf-parser.js

‘use strict’; const rdfParser = require(‘../lib/rdf-parser.js’), expectedValue = require(‘./pg132.json’); exports.testRDFParser = function(test) { rdfParser(__dirname + ‘/pg132.rdf’, function(err, book) { test.expect(2); test.ifError(err); test.deepEqual(book, expectedValue, “book should match expected”); test.done(); }); };

09 May 2017, 09:50
Jim R. Wilson (87 posts)

It looks like the object produced by calling rdfParser() on the pd132.rdf file has only the _id field. It seems to be missing the title, authors, and subjects fields.

My guess is that the problem is in the implementation of rdfParser() as opposed to the test.

You must be logged in to comment