Skip to content

Commit

Permalink
fix(errors): include new error for 1.2.21 on osx, update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Dec 16, 2015
1 parent 548a2c9 commit 0341bff
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@
"dependencies": {
"bindings": "^1.2.1",
"bluebird": "^2.9.34",
"nan": "^2.0.9"
"nan": "^2.1.0"
},
"devDependencies": {
"chai": "^3.2.0",
"jshint": "^2.8.0",
"mocha": "^2.2.5",
"segfault-handler": "^0.2.5",
"semver": "^5.0.1",
"xpath": "~0.0.9",
"xmldom": "~0.1.19"
"chai": "^3.4.1",
"jshint": "^2.9.1-rc1",
"mocha": "^2.3.4",
"segfault-handler": "^1.0.0",
"semver": "^5.1.0",
"xpath": "^0.0.9",
"xmldom": "^0.1.19"
}
}
4 changes: 4 additions & 0 deletions src/error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ void Error::Initialize(Handle<Object> exports)
NODE_DEFINE_CONSTANT(exports, VIR_ERR_INVALID_DOMAIN_SNAPSHOT);
NODE_DEFINE_CONSTANT(exports, VIR_ERR_NO_DOMAIN_SNAPSHOT);

#if LIBVIR_CHECK_VERSION(1,2,21)
NODE_DEFINE_CONSTANT(exports, VIR_ERR_ARGUMENT_UNSUPPORTED);
#endif

//virErrorDomain
NODE_DEFINE_CONSTANT(exports, VIR_FROM_NONE);
NODE_DEFINE_CONSTANT(exports, VIR_FROM_XEN);
Expand Down
8 changes: 1 addition & 7 deletions src/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
#ifndef ERROR_H
#define ERROR_H

#include <nan.h>

#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>

using namespace v8;
using namespace node;
#include "node_libvirt.h"

namespace NLV {

Expand Down
4 changes: 4 additions & 0 deletions src/node_libvirt.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ using namespace node;
#define NLV_WARN_UNFINISHED(Method) \
fprintf(stderr, "WARNING: " #Method " is still synchronous and needs to be ported\n");

#ifndef LIBVIR_CHECK_VERSION
# define LIBVIR_CHECK_VERSION(major, minor, micro) false
#endif

#endif // NODE_LIBVIRT_H
15 changes: 11 additions & 4 deletions test/domain.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,13 @@ describe('Domain', function() {
test.domain.migrate({ dest_uri: 'test:///default', dest_name: 'test2', bandwidth: 100, flags: flags }, function(err) {
expect(err).to.exist;
// some libvirt versions report different error codes.
var expected = err.code === libvirt.VIR_ERR_OPERATION_INVALID ? libvirt.VIR_ERR_OPERATION_INVALID : libvirt.VIR_ERR_NO_SUPPORT;
expect(err.code).to.be.equal(expected);
var possibleErrors = [
libvirt.VIR_ERR_OPERATION_INVALID,
libvirt.VIR_ERR_NO_SUPPORT,
libvirt.VIR_ERR_ARGUMENT_UNSUPPORTED
];

expect(possibleErrors).to.include(err.code);
// NOTE: not supported by test driver
// expect(err).to.not.exist;

Expand Down Expand Up @@ -342,17 +346,20 @@ describe('Domain', function() {
var physical = [test.domain.VIR_MEMORY_PHYSICAL];
var virtual = [test.domain.VIR_MEMORY_VIRTUAL];

// support different errors for different libvirt versions
var possibleErrors = [ libvirt.VIR_ERR_INVALID_ARG, libvirt.VIR_ERR_NO_SUPPORT ];

test.domain.memoryPeek(0, 1024, physical, function(err, res) {
expect(err).to.exist;
expect(err.code).to.be.equal(libvirt.VIR_ERR_INVALID_ARG);
expect(possibleErrors).to.include(err.code);

// NOTE: not supported by test driver
// expect(err).to.not.exist;
// expect(res).to.be.instanceof(Buffer);

test.domain.memoryPeek(0, 1024, virtual, function(err, res) {
expect(err).to.exist;
expect(err.code).to.be.equal(libvirt.VIR_ERR_INVALID_ARG);
expect(possibleErrors).to.include(err.code);

// NOTE: not supported by test driver
//expect(err).to.not.exist;
Expand Down

0 comments on commit 0341bff

Please sign in to comment.