smartgit/test/test.ts

94 lines
3.1 KiB
TypeScript
Raw Normal View History

2016-06-12 14:46:59 +00:00
import "typings-test";
import beautylog = require("beautylog");
2016-07-03 22:00:04 +00:00
let shelljs = require("shelljs");
2016-06-12 14:46:59 +00:00
import path = require("path");
import "should"
import smartgit = require("../dist/index");
2016-07-03 22:00:04 +00:00
let paths = {
temp: path.resolve("./test/temp/"),
temp2: path.resolve("./test/temp2/"),
temp3: path.resolve("./test/temp3"),
temp4: path.resolve("./test/temp4"),
noGit: path.resolve("./test/")
}
2016-03-30 23:59:45 +00:00
describe("smartgit",function(){
describe(".clone",function(){
2016-06-12 14:46:59 +00:00
it("should clone a repository using ssh and sshkey",function(done){
2016-07-04 01:49:24 +00:00
this.timeout(40000);
2016-03-30 23:59:45 +00:00
smartgit.clone({
2016-06-25 17:13:19 +00:00
from:"git@gitlab.com:sandboxzone/sandbox-testrepo.git",
2016-07-03 22:00:04 +00:00
to:paths.temp
2016-03-30 23:59:45 +00:00
}).then(function(){
done();
});
});
2016-06-12 14:46:59 +00:00
it("should clone a repository using https",function(done){
2016-07-04 01:49:24 +00:00
this.timeout(40000);
2016-06-12 14:46:59 +00:00
smartgit.clone({
2016-06-25 17:13:19 +00:00
from:"https://gitlab.com/sandboxzone/sandbox-testrepo.git",
2016-07-03 22:00:04 +00:00
to:paths.temp2
2016-06-12 14:46:59 +00:00
}).then(function(){
done();
});
});
2016-03-30 23:59:45 +00:00
});
2016-07-03 22:00:04 +00:00
describe(".add",function(){
it("should error for noGit",function(){
smartgit.add.addAll(paths.noGit);
})
it("should add a file to an existing repository",function(){
shelljs.exec(`(cd ${paths.temp} && cp ../test.js .)`)
smartgit.add.addAll(paths.temp);
})
2016-03-30 23:59:45 +00:00
});
describe("commit",function(){
2016-07-03 22:00:04 +00:00
it("should error for noGit",function(){
smartgit.commit(paths.noGit,"some commit message");
})
it("should commit a new file to an existing repository",function(){
smartgit.commit(paths.temp,"added a new file");
})
2016-03-30 23:59:45 +00:00
});
describe("init",function(){
2016-07-03 22:00:04 +00:00
it("should error for noGit",function(){
smartgit.init(paths.noGit);
});
it("should init a new git",function(){
smartgit.init(paths.temp3);
})
});
describe("pull",function(){
2016-07-04 01:49:24 +00:00
this.timeout(40000);
2016-07-03 22:00:04 +00:00
it("should error for noGit",function(){
smartgit.pull(paths.noGit);
});
it("should pull from origin",function(){
smartgit.pull(paths.temp);
})
2016-03-30 23:59:45 +00:00
});
2016-07-05 01:47:38 +00:00
describe("push",function(){
this.timeout(40000);
it("should error for noGit",function(){
smartgit.push(paths.noGit);
});
it("should push to origin",function(){
smartgit.push(paths.temp,"origin","master");
})
});
2016-07-04 01:49:24 +00:00
describe("remote",function(){
it("should error for noGit",function(){
smartgit.remote.add(paths.noGit,null,null);
});
it("should error for no remote name",function(){
smartgit.remote.add(paths.temp,null,null);
});
it("should error for no remote link",function(){
smartgit.remote.add(paths.temp,"origin",null);
});
it("should add a remote",function(){
smartgit.remote.add(paths.temp,"origin2","https://github.com/pushrocks/somerepo");
});
});
2016-03-30 23:59:45 +00:00
});