Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
Test detect module.
Test buildkite service detector.
Edit snap service detector test to cover all paths.
  • Loading branch information
Bjørn authored and Bjørn committed Dec 8, 2015
1 parent 2aeb508 commit dcf3a00
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
25 changes: 25 additions & 0 deletions test/detect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

var detect = require("../lib/detect");
var execSync = require('child_process').execSync;
if (!execSync) {
var exec = require('execSync').exec;
var execSync = function(cmd){
return exec(cmd).stdout;
};
}

describe("Codecov", function(){

it("can detect existing appveyor service", function(){
process.env.APPVEYOR = "true";

expect(detect().service).to.eql("appveyor");
});

it("can select local git service if no service is found", function(){
process.env.APPVEYOR = "";

expect(detect().commit).to.match(/^\w{40}$/);
expect(detect().commit).to.eql(execSync("git rev-parse HEAD || hg id -i --debug | tr -d '+'").toString().trim());
})
});
27 changes: 27 additions & 0 deletions test/services/buildkite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var buildkite = require("../../lib/services/buildkite");

describe("Buildkite CI Provider", function(){

it ("can detect buildkite", function(){
process.env.BUILDKITE = "true";
expect(buildkite.detect()).to.be(true);
});

it ("can get buildkite env info", function(){
process.env.BUILDKITE_BUILD_NUMBER = "1";
process.env.BUILDKITE_BUILD_URL = "url";
process.env.BUILDKITE_COMMIT = "commit";
process.env.BUILDKITE_BRANCH = "branch";
process.env.BUILDKITE_PROJECT_SLUG = "slug";

expect(buildkite.configuration()).to.eql({
service : 'buildkite',
build : "1",
build_url : "url",
commit : "commit",
branch : "branch",
slug : "slug"
});
});

});
3 changes: 2 additions & 1 deletion test/services/snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ describe("Snap CI Provider", function(){
});

it ("can get snap env info get_commit_status for pull requests", function(){
process.env.SNAP_COMMIT = '';
process.env.SNAP_BRANCH = '';
process.env.SNAP_CI = "true";
process.env.SNAP_PIPELINE_COUNTER = '1234';
process.env.SNAP_COMMIT = '5678';
process.env.SNAP_UPSTREAM_COMMIT = '5678';
process.env.SNAP_UPSTREAM_BRANCH = 'upstream-branch';
process.env.SNAP_PULL_REQUEST_NUMBER = 'blah';
expect(snap.configuration()).to.eql({
Expand Down

0 comments on commit dcf3a00

Please sign in to comment.