| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,3 +11,4 @@ | |||
| 11 | 11 | /testing.js | |
| 12 | 12 | /out | |
| 13 | 13 | /test.git | |
| 14 | + /test/.reposCache | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,11 +39,12 @@ | |||
| 39 | 39 | "devDependencies": { | |
| 40 | 40 | "nodeunit": "", | |
| 41 | 41 | "rimraf": "1.0.x", | |
| 42 | - "ejs": "0.8.x" | ||
| 42 | + "ejs": "0.8.x", | ||
| 43 | + "ncp": "~0.4.2" | ||
| 43 | 44 | }, | |
| 44 | 45 | "scripts": { | |
| 45 | 46 | "install": "node install.js", | |
| 46 | - "test": "cd test && nodeunit *.js", | ||
| 47 | + "test": "cd test && nodeunit nodegit.js", | ||
| 47 | 48 | "gen": "node gen.js" | |
| 48 | 49 | } | |
| 49 | 50 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ var git = require('../'), | |||
| 4 | 4 | exports.content = function(test) { | |
| 5 | 5 | var testOid = git.Oid.fromString('111dd657329797f6165f52f5085f61ac976dcf04'); | |
| 6 | 6 | test.expect(1); | |
| 7 | - git.Repo.open(path.resolve('../.git'), function(err, repo) { | ||
| 7 | + git.Repo.open(path.resolve('repos/workdir/.git'), function(err, repo) { | ||
| 8 | 8 | repo.getBlob(testOid, function(err, blob) { | |
| 9 | 9 | test.equals(blob.toString().slice(0, 7), "@import"); | |
| 10 | 10 | test.done(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,7 @@ var historyCountKnownSHA = 'fce88902e66c72b5b93e75bdb5ae717038b221f6'; | |||
| 6 | 6 | ||
| 7 | 7 | exports.message = function(test) { | |
| 8 | 8 | test.expect(2); | |
| 9 | - git.Repo.open('../.git', function(error, repository) { | ||
| 9 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 10 | 10 | repository.getCommit(historyCountKnownSHA, function(error, commit) { | |
| 11 | 11 | var message = commit.message(); | |
| 12 | 12 | test.equals(error, null, 'There should be no error'); | |
@@ -18,7 +18,7 @@ exports.message = function(test) { | |||
| 18 | 18 | ||
| 19 | 19 | exports.sha = function(test) { | |
| 20 | 20 | test.expect(2); | |
| 21 | - git.Repo.open('../.git', function(error, repository) { | ||
| 21 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 22 | 22 | repository.getCommit(historyCountKnownSHA, function(error, commit) { | |
| 23 | 23 | var sha = commit.sha(); | |
| 24 | 24 | test.equals(error, null, 'There should be no error'); | |
@@ -30,7 +30,7 @@ exports.sha = function(test) { | |||
| 30 | 30 | ||
| 31 | 31 | exports.time = function(test) { | |
| 32 | 32 | test.expect(2); | |
| 33 | - git.Repo.open('../.git', function(error, repository) { | ||
| 33 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 34 | 34 | repository.getCommit(historyCountKnownSHA, function(error, commit) { | |
| 35 | 35 | var time = commit.timeMs(); | |
| 36 | 36 | test.equals(error, null, 'There should be no error'); | |
@@ -42,7 +42,7 @@ exports.time = function(test) { | |||
| 42 | 42 | ||
| 43 | 43 | exports.date = function(test) { | |
| 44 | 44 | test.expect(2); | |
| 45 | - git.Repo.open('../.git', function(error, repository) { | ||
| 45 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 46 | 46 | repository.getCommit(historyCountKnownSHA, function(error, commit) { | |
| 47 | 47 | var date = commit.date(); | |
| 48 | 48 | test.equals(error, null, 'There should be no error'); | |
@@ -54,7 +54,7 @@ exports.date = function(test) { | |||
| 54 | 54 | ||
| 55 | 55 | exports.offset = function(test) { | |
| 56 | 56 | test.expect(2); | |
| 57 | - git.Repo.open('../.git', function(error, repository) { | ||
| 57 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 58 | 58 | repository.getCommit(historyCountKnownSHA, function(error, commit) { | |
| 59 | 59 | var offset = commit.offset(); | |
| 60 | 60 | test.equals(error, null, 'There should be no error'); | |
@@ -66,7 +66,7 @@ exports.offset = function(test) { | |||
| 66 | 66 | ||
| 67 | 67 | exports.author = function(test) { | |
| 68 | 68 | test.expect(2); | |
| 69 | - git.Repo.open('../.git', function(error, repository) { | ||
| 69 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 70 | 70 | repository.getCommit(historyCountKnownSHA, function(error, commit) { | |
| 71 | 71 | var author = commit.author(); | |
| 72 | 72 | test.equals(error, null, 'There should be no error'); | |
@@ -78,7 +78,7 @@ exports.author = function(test) { | |||
| 78 | 78 | ||
| 79 | 79 | exports.authorName = function(test) { | |
| 80 | 80 | test.expect(1); | |
| 81 | - git.Repo.open('../.git', function(error, repository) { | ||
| 81 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 82 | 82 | repository.getCommit(historyCountKnownSHA, function(error, commit) { | |
| 83 | 83 | var author = commit.author(); | |
| 84 | 84 | var name = author.name(); | |
@@ -90,7 +90,7 @@ exports.authorName = function(test) { | |||
| 90 | 90 | ||
| 91 | 91 | exports.authorEmail = function(test) { | |
| 92 | 92 | test.expect(1); | |
| 93 | - git.Repo.open('../.git', function(error, repository) { | ||
| 93 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 94 | 94 | repository.getCommit(historyCountKnownSHA, function(error, commit) { | |
| 95 | 95 | var author = commit.author(); | |
| 96 | 96 | var email = author.email(); | |
@@ -102,7 +102,7 @@ exports.authorEmail = function(test) { | |||
| 102 | 102 | ||
| 103 | 103 | exports.committerName = function(test) { | |
| 104 | 104 | test.expect(1); | |
| 105 | - git.Repo.open('../.git', function(error, repository) { | ||
| 105 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 106 | 106 | repository.getCommit(historyCountKnownSHA, function(error, commit) { | |
| 107 | 107 | var committer = commit.committer(); | |
| 108 | 108 | var name = committer.name(); | |
@@ -114,7 +114,7 @@ exports.committerName = function(test) { | |||
| 114 | 114 | ||
| 115 | 115 | exports.committerEmail = function(test) { | |
| 116 | 116 | test.expect(1); | |
| 117 | - git.Repo.open('../.git', function(error, repository) { | ||
| 117 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 118 | 118 | repository.getCommit(historyCountKnownSHA, function(error, commit) { | |
| 119 | 119 | var committer = commit.committer(); | |
| 120 | 120 | var email = committer.email(); | |
@@ -129,7 +129,7 @@ exports.committerEmail = function(test) { | |||
| 129 | 129 | */ | |
| 130 | 130 | exports.improperCommitId = function(test) { | |
| 131 | 131 | test.expect(1); | |
| 132 | - git.Repo.open('../.git', function(error, repository) { | ||
| 132 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 133 | 133 | repository.getCommit('not a proper commit sha', function(error, commit) { | |
| 134 | 134 | test.notEqual(error, null, 'Error should occur'); | |
| 135 | 135 | test.done(); | |
@@ -142,7 +142,7 @@ exports.improperCommitId = function(test) { | |||
| 142 | 142 | */ | |
| 143 | 143 | exports.history = function(test) { | |
| 144 | 144 | test.expect(4); | |
| 145 | - git.Repo.open('../.git', function(error, repository) { | ||
| 145 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 146 | 146 | repository.getCommit(historyCountKnownSHA, function(error, commit) { | |
| 147 | 147 | test.equals(null, error, 'Getting latest branch commit should not error'); | |
| 148 | 148 | var historyCount = 0; | |
@@ -167,7 +167,7 @@ exports.history = function(test) { | |||
| 167 | 167 | */ | |
| 168 | 168 | exports.masterHead = function(test) { | |
| 169 | 169 | test.expect(1); | |
| 170 | - git.Repo.open('../.git', function(error, repository) { | ||
| 170 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 171 | 171 | repository.getBranch('master', function(error, branch) { | |
| 172 | 172 | var sha = branch.sha(); | |
| 173 | 173 | repository.getCommit(sha, function(error, commit) { | |
@@ -185,7 +185,7 @@ exports.masterHead = function(test) { | |||
| 185 | 185 | */ | |
| 186 | 186 | exports.parents = function(test) { | |
| 187 | 187 | test.expect(3); | |
| 188 | - git.Repo.open('../.git', function(error, repository) { | ||
| 188 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 189 | 189 | repository.getCommit(historyCountKnownSHA, function(error, commit) { | |
| 190 | 190 | commit.getParents(function(error, parents) { | |
| 191 | 191 | test.equals(parents.length, 1, 'Commit should have exactly one parent'); | |
@@ -203,7 +203,7 @@ exports.parents = function(test) { | |||
| 203 | 203 | */ | |
| 204 | 204 | exports.tree = function(test) { | |
| 205 | 205 | test.expect(2); | |
| 206 | - git.Repo.open('../.git', function(error, repository) { | ||
| 206 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 207 | 207 | repository.getCommit(historyCountKnownSHA, function(error, commit) { | |
| 208 | 208 | test.equals(error, null, 'Getting latest branch commit should not error'); | |
| 209 | 209 | ||
@@ -226,7 +226,7 @@ exports.tree = function(test) { | |||
| 226 | 226 | */ | |
| 227 | 227 | exports.getDiff = function(test) { | |
| 228 | 228 | test.expect(1); | |
| 229 | - git.Repo.open('../.git', function(error, repository) { | ||
| 229 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 230 | 230 | repository.getCommit(historyCountKnownSHA, function(error, commit) { | |
| 231 | 231 | commit.getDiff(function(error, diff) { | |
| 232 | 232 | test.equals(diff.length, 1, 'Should be one item in parents diff trees'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ var historyCountKnownSHA = 'fce88902e66c72b5b93e75bdb5ae717038b221f6'; | |||
| 11 | 11 | */ | |
| 12 | 12 | exports.walkingDiffs = function(test) { | |
| 13 | 13 | test.expect(16); | |
| 14 | - git.Repo.open('../.git', function(error, repository) { | ||
| 14 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 15 | 15 | repository.getCommit(historyCountKnownSHA, function(error, commit) { | |
| 16 | 16 | commit.getDiff(function(error, diffList) { | |
| 17 | 17 | test.equal(null, error, 'Should not error'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,45 @@ | |||
| 1 | + var fs = require('fs'); | ||
| 2 | + var rimraf = require('rimraf'); | ||
| 3 | + var ncp = require('ncp').ncp; | ||
| 4 | + var exec = require('child_process').exec; | ||
| 5 | + var path = require('path'); | ||
| 6 | + var async = require('async'); | ||
| 7 | + | ||
| 8 | + var testFiles = ['blob','difflist','oid','repo','tree_entry','commit','reference','revwalk','tree']; | ||
| 9 | + | ||
| 10 | + function setupReposCache(cb) { | ||
| 11 | + fs.mkdir('.reposCache',function() { | ||
| 12 | + async.series([ | ||
| 13 | + function empty(cb) { exec('git init .reposCache/empty',cb); }, | ||
| 14 | + function workdir(cb) { exec('git clone https://github.com/nodegit/nodegit.git .reposCache/workdir',cb); }, | ||
| 15 | + function nonrepo(cb) { | ||
| 16 | + fs.mkdir('.reposCache/nonrepo',function() { | ||
| 17 | + fs.writeFile('.reposCache/nonrepo/file.txt','This is a bogus file',cb); | ||
| 18 | + }); | ||
| 19 | + } | ||
| 20 | + ],cb); | ||
| 21 | + }); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + module.exports = { | ||
| 25 | + setUp: function(cb) { | ||
| 26 | + fs.exists('.reposCache',function(exists) { | ||
| 27 | + if (exists) { | ||
| 28 | + ncp('.reposCache','repos',cb); | ||
| 29 | + } else { | ||
| 30 | + setupReposCache(function(err) { | ||
| 31 | + if (err) { return cb(err); } | ||
| 32 | + ncp('.reposCache','repos',cb); | ||
| 33 | + }); | ||
| 34 | + } | ||
| 35 | + }); | ||
| 36 | + }, | ||
| 37 | + tearDown: function(cb) { | ||
| 38 | + rimraf('repos',cb); | ||
| 39 | + } | ||
| 40 | + }; | ||
| 41 | + | ||
| 42 | + for(var i in testFiles) { | ||
| 43 | + var testFile = testFiles[i]; | ||
| 44 | + module.exports[testFile] = require('./'+testFile); | ||
| 45 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,7 @@ var git = require('../'), | |||
| 5 | 5 | exports.lookup = function(test) { | |
| 6 | 6 | test.expect(1); | |
| 7 | 7 | ||
| 8 | - git.Repo.open('../.git', function(error, repo) { | ||
| 8 | + git.Repo.open('repos/workdir/.git', function(error, repo) { | ||
| 9 | 9 | repo.getReference('refs/heads/master', function(error, reference) { | |
| 10 | 10 | test.ok(reference instanceof git.Reference); | |
| 11 | 11 | test.done(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,18 +7,23 @@ var git = require('../'), | |||
| 7 | 7 | * Ensure the repo method can handle opening repositories with async/sync | |
| 8 | 8 | * signatures properly. | |
| 9 | 9 | */ | |
| 10 | - exports.open = function(test){ | ||
| 11 | - test.expect(2); | ||
| 10 | + exports.openInvalidRepo = function(test){ | ||
| 11 | + test.expect(1); | ||
| 12 | 12 | ||
| 13 | 13 | // Test invalid repository | |
| 14 | - git.Repo.open('../templates', function(error, repository) { | ||
| 15 | - test.equals(error.message, "Could not find repository from '../templates'"); | ||
| 14 | + git.Repo.open('repos/nonrepo', function(error, repository) { | ||
| 15 | + test.equals(error.message, "Could not find repository from 'repos/nonrepo'"); | ||
| 16 | + test.done(); | ||
| 17 | + }); | ||
| 18 | + }; | ||
| 16 | 19 | ||
| 17 | - // Test valid repository | ||
| 18 | - git.Repo.open('../.git', function(error, repository) { | ||
| 19 | - test.equals(null, error, 'Valid repository error code'); | ||
| 20 | - test.done(); | ||
| 21 | - }); | ||
| 20 | + exports.openValidRepo = function(test){ | ||
| 21 | + test.expect(1); | ||
| 22 | + | ||
| 23 | + // Test valid repository | ||
| 24 | + git.Repo.open('repos/workdir/.git', function(error, repository) { | ||
| 25 | + test.equals(null, error, 'Valid repository error code'); | ||
| 26 | + test.done(); | ||
| 22 | 27 | }); | |
| 23 | 28 | }; | |
| 24 | 29 | ||
@@ -40,18 +45,13 @@ exports.nonexistentDirectory = function(test) { | |||
| 40 | 45 | */ | |
| 41 | 46 | exports.init = function(test) { | |
| 42 | 47 | test.expect(2); | |
| 43 | - // Cleanup, remove test repo directory - if it exists | ||
| 44 | - rimraf('./test.git', function() { | ||
| 45 | - // Create bare repo and test for creation | ||
| 46 | - git.Repo.init('./test.git', true, function(error, path, isBare) { | ||
| 47 | - test.equals(null, error, 'Successfully created bare repository'); | ||
| 48 | - // Verify repo exists | ||
| 49 | - git.Repo.open('./test.git', function(error, path, repo) { | ||
| 50 | - test.equals(null, error, 'Valid repository created'); | ||
| 51 | - | ||
| 52 | - // Cleanup, remove test repo directory | ||
| 53 | - rimraf('./test.git', test.done); | ||
| 54 | - }); | ||
| 48 | + // Create bare repo and test for creation | ||
| 49 | + git.Repo.init('repos/newrepo', true, function(error, path, isBare) { | ||
| 50 | + test.equals(null, error, 'Successfully created bare repository'); | ||
| 51 | + // Verify repo exists | ||
| 52 | + git.Repo.open('repos/newrepo', function(error, path, repo) { | ||
| 53 | + test.equals(null, error, 'Valid repository created'); | ||
| 54 | + test.done(); | ||
| 55 | 55 | }); | |
| 56 | 56 | }); | |
| 57 | 57 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,7 @@ var fileCount = 512; // Number of blob & blob executabless | |||
| 8 | 8 | exports.walk = function(test) { | |
| 9 | 9 | test.expect(515); | |
| 10 | 10 | ||
| 11 | - git.Repo.open('../.git', function(error, repo) { | ||
| 11 | + git.Repo.open('repos/workdir/.git', function(error, repo) { | ||
| 12 | 12 | repo.getCommit(sha, function(error, commit) { | |
| 13 | 13 | var entryCount = 0; | |
| 14 | 14 | commit.getTree(function(error, tree) { | |
@@ -29,8 +29,8 @@ exports.walk = function(test) { | |||
| 29 | 29 | exports.insert = function(test) { | |
| 30 | 30 | test.expect(1); | |
| 31 | 31 | ||
| 32 | - git.Repo.open('../.git', function(error, repo) { | ||
| 33 | - repo.getCommit('1e7bc7fba93aabc8c76ebea41918f9ad892141ed', function(error, commit) { | ||
| 32 | + git.Repo.open('repos/workdir/.git', function(error, repo) { | ||
| 33 | + repo.getCommit(sha, function(error, commit) { | ||
| 34 | 34 | commit.getTree(function(error, tree) { | |
| 35 | 35 | var text = "this is a file\n", | |
| 36 | 36 | buffer = new Buffer(text); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments