PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/test/raw-error.js

https://github.com/zippo445/nodegit
JavaScript | 67 lines | 50 code | 9 blank | 8 comment | 0 complexity | 3dd0b4fa7d108e86a03abe688ad3c32b MD5 | raw file
Possible License(s): AGPL-3.0
  1. var git = require('../').raw,
  2. rimraf = require('rimraf');
  3. // Helper functions
  4. var helper = {
  5. // Test if obj is a true function
  6. testFunction: function(test, obj, label) {
  7. // The object reports itself as a function
  8. test(typeof obj, 'function', label +' reports as a function.');
  9. // This ensures the repo is actually a derivative of the Function [[Class]]
  10. test(toString.call(obj), '[object Function]', label +' [[Class]] is of type function.');
  11. },
  12. // Test code and handle exception thrown
  13. testException: function(test, fun, label) {
  14. try {
  15. fun();
  16. test(false, label);
  17. }
  18. catch (ex) {
  19. test(true, label);
  20. }
  21. }
  22. };
  23. // Error
  24. exports.constructor = function(test){
  25. test.expect(3);
  26. // Test for function
  27. helper.testFunction(test.equals, git.Error, 'Error');
  28. // Ensure we get an instance of Error
  29. test.ok(new git.Error() instanceof git.Error, 'Invocation returns an instance of Error');
  30. test.done();
  31. };
  32. exports.codes = function(test) {
  33. test.expect(23);
  34. test.equals(git.Error.returnCodes.GIT_OK, 0, 'GIT_OK should equal 0'),
  35. test.equals(git.Error.returnCodes.GIT_ERROR, -1, 'GIT_ERROR should equal -1'),
  36. test.equals(git.Error.returnCodes.GIT_ENOTFOUND, -3, 'GIT_ENOTFOUND should equal -3'),
  37. test.equals(git.Error.returnCodes.GIT_EEXISTS, -4, 'GIT_EEXISTS should equal -4'),
  38. test.equals(git.Error.returnCodes.GIT_EAMBIGUOUS, -5, 'GIT_EAMBIGUOUS should equal -5'),
  39. test.equals(git.Error.returnCodes.GIT_EBUFS, -6, 'GIT_EBUFS should equal -6'),
  40. test.equals(git.Error.returnCodes.GIT_PASSTHROUGH, -30, 'GIT_PASSTHROUGH should equal -30'),
  41. test.equals(git.Error.returnCodes.GIT_ITEROVER, -31, 'GIT_ITEROVER should equal -31'),
  42. test.equals(git.Error.codes.GITERR_NOMEMORY, 0, 'GITERR_NOMEMORY should equal 0');
  43. test.equals(git.Error.codes.GITERR_OS, 1, 'GITERR_OS should equal 1');
  44. test.equals(git.Error.codes.GITERR_INVALID, 2, 'GITERR_INVALID should equal 2');
  45. test.equals(git.Error.codes.GITERR_REFERENCE, 3, 'GITERR_REFERENCE should equal 3');
  46. test.equals(git.Error.codes.GITERR_ZLIB, 4, 'GITERR_ZLIB should equal 4');
  47. test.equals(git.Error.codes.GITERR_REPOSITORY, 5, 'GITERR_REPOSITORY should equal 5');
  48. test.equals(git.Error.codes.GITERR_CONFIG, 6, 'GITERR_CONFIG should equal 6');
  49. test.equals(git.Error.codes.GITERR_REGEX, 7, 'GITERR_REGEX should equal 7');
  50. test.equals(git.Error.codes.GITERR_ODB, 8, 'GITERR_ODB should equal 8');
  51. test.equals(git.Error.codes.GITERR_INDEX, 9, 'GITERR_INDEX should equal 9');
  52. test.equals(git.Error.codes.GITERR_OBJECT, 10, 'GITERR_OBJECT should equal 10');
  53. test.equals(git.Error.codes.GITERR_NET, 11, 'GITERR_NET should equal 11');
  54. test.equals(git.Error.codes.GITERR_TAG, 12, 'GITERR_TAG should equal 12');
  55. test.equals(git.Error.codes.GITERR_TREE, 13, 'GITERR_TREE should equal 13');
  56. test.equals(git.Error.codes.GITERR_INDEXER, 14, 'GITERR_INDEXER should equal 14');
  57. test.done();
  58. };