Skip to content

Commit

Permalink
fix: fix unit tests and increased debuging
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Oct 10, 2023
1 parent 5dfce0f commit dd31253
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lib/transport/rest/protocol/deserializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function deserializeDocument (serialized) {
return res;
}
catch (e) {
throw new errors.Request(serialized);
throw new errors.Request(serialized + " error:" + e);
}
}

Expand Down
12 changes: 6 additions & 6 deletions test/database/database-record-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ describe("ODatabaseSession API - Record", function () {
name: 'othertestuser',
password: 'testpassword',
status: 'ACTIVE',
linkedTest1: "#5:0", // defined link field
linkedTest2: "#5:1" // dynamic field
linkedTest1: "#6:0", // defined link field
linkedTest2: "#6:1" // dynamic field
})
.bind(this)
.then(function (obj) {
Expand All @@ -160,13 +160,13 @@ describe("ODatabaseSession API - Record", function () {
var serType = this.db.session().server.network.serializationType;

if (version >= 33 && serType === 'onet_ser_v0') {
expect(record.linkedTest1.cluster).to.equal(5);
expect(record.linkedTest1.cluster).to.equal(6);
expect(record.linkedTest1.position).to.equal(0);
} else {
expect(record.linkedTest1).to.equal(null);
}
expect(typeof record.linkedTest2).to.equal('string'); // because we did not pass a RID, this is not a link
record.linkedTest2.should.equal('#5:1');
record.linkedTest2.should.equal('#6:1');
});
});

Expand Down Expand Up @@ -235,15 +235,15 @@ describe("ODatabaseSession API - Record", function () {
// Fixed with binary protocol

if (version >= 33 && serType === 'onet_ser_v0') {
expect(record.linkedTest1.cluster).to.equal(5);
expect(record.linkedTest1.cluster).to.equal(6);
expect(record.linkedTest1.position).to.equal(0);
} else {
expect(record.linkedTest1).to.equal(null);
}


expect(typeof record.linkedTest2).to.equal('string'); // because we did not pass a RID, this is not a link
record.linkedTest2.should.equal('#5:1');
record.linkedTest2.should.equal('#6:1');
});
});

Expand Down
32 changes: 16 additions & 16 deletions test/db/record-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ describe("Database API - Record", function () {

describe('Db::record.get()', function () {
it('should get the record with the given rid', function () {
return this.db.record.get('#5:0')
return this.db.record.get('#6:0')
.then(function (record) {
record['@class'].should.equal('OUser');
record['@rid'].should.have.properties({
cluster: 5,
cluster: 6,
position: 0
});
});
});
it('should get the record with a fetch plan', function () {
return this.db.record.get({'@rid': '#5:0'}, {fetchPlan: '*:-1'})
return this.db.record.get({'@rid': '#6:0'}, {fetchPlan: '*:-1'})
.then(function (record) {
record['@class'].should.equal('OUser');
record['@rid'].should.have.properties({
cluster: 5,
cluster: 6,
position: 0
});
record.roles.length.should.be.above(0);
Expand All @@ -47,24 +47,24 @@ describe("Database API - Record", function () {

describe('Db::record.get()', function () {
it('should get records with the given rids', function () {
return this.db.record.get(['#5:0', '#5:1'])
return this.db.record.get(['#6:0', '#6:1'])
.then(function (records) {
records.forEach(function(record, i){
record['@class'].should.equal('OUser');
record['@rid'].should.have.properties({
cluster: 5,
cluster: 6,
position: i
});
});
});
});
it('should get records with a fetch plan', function () {
return this.db.record.get([{'@rid': '#5:0'},{'@rid': '#5:1'}], {fetchPlan: '*:-1'})
return this.db.record.get([{'@rid': '#6:0'},{'@rid': '#6:1'}], {fetchPlan: '*:-1'})
.then(function (records) {
records.forEach(function(record, i){
record['@class'].should.equal('OUser');
record['@rid'].should.have.properties({
cluster: 5,
cluster: 6,
position: i
});
record.roles.length.should.be.above(0);
Expand Down Expand Up @@ -135,8 +135,8 @@ describe("Database API - Record", function () {
name: 'othertestuser',
password: 'testpassword',
status: 'ACTIVE',
linkedTest1: "#5:0", // defined link field
linkedTest2: "#5:1" // dynamic field
linkedTest1: "#6:0", // defined link field
linkedTest2: "#6:1" // dynamic field
})
.bind(this)
.then(function (obj) {
Expand All @@ -153,13 +153,13 @@ describe("Database API - Record", function () {
var serType = this.db.server.transport.connection.protocol.constants.SERIALIZATION_FORMAT;

if (version >= 33 && serType === 'onet_ser_v0') {
expect(record.linkedTest1.cluster).to.equal(5);
expect(record.linkedTest1.cluster).to.equal(6);
expect(record.linkedTest1.position).to.equal(0);
} else {
expect(record.linkedTest1).to.equal(null);
}
expect(typeof record.linkedTest2).to.equal('string'); // because we did not pass a RID, this is not a link
record.linkedTest2.should.equal('#5:1');
record.linkedTest2.should.equal('#6:1');
});
});

Expand All @@ -169,8 +169,8 @@ describe("Database API - Record", function () {
name: 'othertestuser2',
password: 'testpassword',
status: 'ACTIVE',
linkedTest1: new LIB.RID("#5:0"), // defined field
linkedTest2: new LIB.RID("#5:1") // dynamic field
linkedTest1: new LIB.RID("#6:0"), // defined field
linkedTest2: new LIB.RID("#6:1") // dynamic field
})
.bind(this)
.then(function (obj) {
Expand Down Expand Up @@ -228,15 +228,15 @@ describe("Database API - Record", function () {
// Fixed with binary protocol

if (version >= 33 && serType === 'onet_ser_v0') {
expect(record.linkedTest1.cluster).to.equal(5);
expect(record.linkedTest1.cluster).to.equal(6);
expect(record.linkedTest1.position).to.equal(0);
} else {
expect(record.linkedTest1).to.equal(null);
}


expect(typeof record.linkedTest2).to.equal('string'); // because we did not pass a RID, this is not a link
record.linkedTest2.should.equal('#5:1');
record.linkedTest2.should.equal('#6:1');
});
});

Expand Down

0 comments on commit dd31253

Please sign in to comment.