Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

moved more Repository tests over to Mocha.

  • Loading branch information...
commit 8a9a6d4b3b4e549df0322c94859f99529a142a9b 1 parent 05abff8
@samcday samcday authored
View
32 oldtest/repository.test.js
@@ -35,18 +35,6 @@ var existingBareRepoVows = function(topic) {
/*"Commits are not redundant": function(repo) {
assert.isTrue(repo.getCommit(fixtureValues.FIRST_COMMIT.id) === repo.getCommit(fixtureValues.FIRST_COMMIT.id));
},*/
- "Exists() *asynchronously*": {
- topic: function(repo) {
- repo.exists(fixtureValues.FIRST_COMMIT.id, this.callback);
- },
-
- "works correctly": function(result) {
- assert.isTrue(result);
- }
- },
- "Exists() *synchronously*": function(repo) {
- assert.isTrue(repo.exists(fixtureValues.FIRST_COMMIT.id));
- }
}
}
@@ -78,24 +66,4 @@ var existingBareRepoVows = function(topic) {
assert.equal(repo.path, fixtureValues.WORKING_DIR.gitDirectory);
}
}*/
-
- // TODO: probably nice to clean these up afterwards even though they're temp
- "Initializing a new bare repository *asynchronously*": {
- topic: function() {
- var path = this.context.path = temp.path() + "/";
- gitteh.initRepository(path, true, this.callback);
- },
-
- "gives us a Repository": function(repo) {
- assert.instanceOf(repo, gitteh.Repository);
- },
-
- "is bare": function(repo) {
- assert.isTrue(repo.bare);
- },
-
- "has the correct path": function(repo) {
- assert.equal(repo.path, this.context.path);
- }
- }
}).export(module);
View
3  package.json
@@ -13,7 +13,8 @@
"async": ">= 0.1.8",
"temp": "~0.4.0",
"should": "~0.6.3",
- "mocha": "~1.0.3"
+ "mocha": "~1.0.3",
+ "wrench": "~1.3.9"
},
"repository": {
"type": "git",
View
75 test/test.repository.coffee
@@ -1,35 +1,70 @@
path = require "path"
should = require "should"
temp = require "temp"
+wrench = require "wrench"
gitteh = require "../lib/gitteh"
selfRepo = path.join __dirname, ".."
+selfRepoGitPath = path.join selfRepo, ".git/"
describe "Gitteh", ->
- describe "#openRepository", ->
+ describe "#openRepository()", ->
+ describe "on an invalid path", ->
+ it "should fail with an Exception", (done) ->
+ gitteh.openRepository "/i/shouldnt/exist", (err) ->
+ err.should.be.an.instanceof Error
+ done()
describe "on project repo", ->
+ repo = null
it "should open correctly", (done) ->
- gitteh.openRepository selfRepo, done
- it "should not be bare", (done) ->
- gitteh.openRepository selfRepo, (err, repo) ->
- repo.bare.should.be.false
- done()
- it "should have immutable bare property", (done) ->
- gitteh.openRepository selfRepo, (err, repo) ->
- repo.bare = 123
- repo.bare.should.be.false
- done()
- it "should have correct path to git dir", (done) ->
- gitteh.openRepository selfRepo, (err, repo) ->
- repo.path.should.equal path.join selfRepo, ".git/"
- done()
- it "should have an immutable git path", (done) ->
- gitteh.openRepository selfRepo, (err, repo) ->
- repo.path = "foo"
- repo.path.should.equal path.join selfRepo, ".git/"
+ gitteh.openRepository selfRepo, (err, _repo) ->
+ repo = _repo
+ repo.should.be.an.instanceof gitteh.Repository
done()
+ describe "#initRepository()", ->
describe "on an invalid path", ->
it "should fail with an Exception", (done) ->
- gitteh.openRepository "/i/shouldnt/exist", (err) ->
+ gitteh.initRepository "/i/shouldnt/exist", (err) ->
err.should.be.an.instanceof Error
done()
+ describe "initializing a bare repository", ->
+ tempPath = "#{temp.path()}/"
+ repo = null
+ describe "to temp location #{tempPath}", ->
+ after ->
+ wrench.rmdirSyncRecursive tempPath, true
+ it "should initialize correctly", (done) ->
+ gitteh.initRepository tempPath, true, (err, _repo) ->
+ repo = _repo
+ repo.should.be.an.instanceof gitteh.Repository
+ done()
+ it "should definitely be bare", ->
+ repo.bare.should.be.true
+ it "should be in the right place", ->
+ repo.path.should.be.equal tempPath
+
+ describe "Repository", ->
+ describe "Using the project repo...", ->
+ repo = null
+ it "opens correctly", (done) ->
+ gitteh.openRepository selfRepo, (err, _repo) ->
+ repo = _repo
+ repo.should.be.an.instanceof gitteh.Repository
+ done()
+ describe "#bare", ->
+ it "should be false for this repo", ->
+ repo.bare.should.be.false
+ it "should be immutable", ->
+ repo.bare = 123
+ repo.bare.should.be.false
+ describe "#path", ->
+ it "should point to #{selfRepoGitPath}", ->
+ repo.path.should.equal selfRepoGitPath
+ it "should be immutable", ->
+ repo.path = "foo"
+ repo.path.should.equal selfRepoGitPath
+ describe "#exists()", ->
+ it "should return true for first commit in repo :)", (done) ->
+ repo.exists "1f4425ce2a14f21b96b9c8dde5bcfd3733467b14", (err, exists) ->
+ exists.should.be.true
+ done()
Please sign in to comment.
Something went wrong with that request. Please try again.