appveyorStatus

.getLastBuild

queries last build for options.project
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testProject = 'foo/bar';
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/${testProject}`)
  .query(true)
  .reply(200, apiResponses.getProjectBuild({ status: testStatus }));
options.project = testProject;
return appveyorStatus.getLastBuild(options)
  .then((projectBuild) => {
    assert.strictEqual(projectBuildToStatus(projectBuild), testStatus);
    ne.done();
  });
queries last build for project with named branch
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testBranch = 'testb';
const testProject = 'foo/bar';
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/${testProject}/branch/${testBranch}`)
  .query(true)
  .reply(200, apiResponses.getProjectBuild({ status: testStatus }));
options.branch = testBranch;
options.project = testProject;
return appveyorStatus.getLastBuild(options)
  .then((projectBuild) => {
    assert.strictEqual(projectBuildToStatus(projectBuild), testStatus);
    ne.done();
  });
queries last build for named branch by remote
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testBranch = 'testb';
const testRemote = 'testr';
const testRemoteUrl = 'git://foo.bar/baz';
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote')
  .once().withArgs(testBranch, matchOptionsCwd).resolves(testRemote);
gitUtilsMock.expects('getRemoteUrl')
  .once().withArgs(testRemote, matchOptionsCwd).resolves(testRemoteUrl);
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get('/api/projects')
  .query(true)
  .reply(200, [
    apiResponses.getProject({
      branch: testBranch,
      repositoryType: 'git',
      repositoryName: testRemoteUrl,
      status: testStatus,
    }),
  ]);
options.branch = testBranch;
return appveyorStatus.getLastBuild(options)
  .then((projectBuild) => {
    assert.strictEqual(projectBuildToStatus(projectBuild), testStatus);
    ne.done();
  });
queries non-last build for named branch by remote
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testBranch = 'testb';
const testProject = ['foo', 'bar'];
const testRemote = 'testr';
const testRemoteUrl = 'git://foo.bar/baz';
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote')
  .once().withArgs(testBranch, matchOptionsCwd).resolves(testRemote);
gitUtilsMock.expects('getRemoteUrl')
  .once().withArgs(testRemote, matchOptionsCwd).resolves(testRemoteUrl);
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get('/api/projects')
  .query(true)
  .reply(200, [
    apiResponses.getProject({
      accountName: testProject[0],
      branch: `${testBranch}5`,
      repositoryType: 'git',
      repositoryName: testRemoteUrl,
      slug: testProject[1],
      status: testStatus,
    }),
  ])
  .get(`/api/projects/${testProject.join('/')}/branch/${testBranch}`)
  .query(true)
  .reply(200, apiResponses.getProjectBuild({
    branch: testBranch,
    repositoryType: 'git',
    repositoryName: testRemoteUrl,
    status: testStatus,
  }));
options.branch = testBranch;
return appveyorStatus.getLastBuild(options)
  .then((projectBuild) => {
    assert.strictEqual(projectBuildToStatus(projectBuild), testStatus);
    ne.done();
  });
uses commit hash without resolving
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testCommit = 'adc83b19e793491b1c6ea0fd8b46cd9f32e592a1';
const testProject = 'foo/bar';
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/${testProject}`)
  .query(true)
  .reply(200, apiResponses.getProjectBuild({
    commitId: testCommit,
    status: testStatus,
  }));
options.commit = testCommit;
options.project = testProject;
return appveyorStatus.getLastBuild(options)
  .then((projectBuild) => {
    assert.strictEqual(projectBuildToStatus(projectBuild), testStatus);
    ne.done();
  });
rejects with CommitMismatchError if commit does not match
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testCommit = 'testtag';
const testProject = 'foo/bar';
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit')
  .once().withArgs(testCommit, matchOptionsCwd).resolves('abcde');
const ne = nock(apiUrl)
  .get(`/api/projects/${testProject}`)
  .query(true)
  .reply(200, apiResponses.getProjectBuild({
    commitId: '12345',
    status: testStatus,
  }));
options.commit = testCommit;
options.project = testProject;
return appveyorStatus.getLastBuild(options).then(
  sinon.mock().never(),
  (err) => {
    assert.strictEqual(err.name, 'CommitMismatchError');
    ne.done();
  },
);
returns queued status as-is without wait
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testProject = 'foo/bar';
const testStatus = 'queued';
const ne = nock(apiUrl)
  .get(`/api/projects/${testProject}`)
  .query(true)
  .reply(200, apiResponses.getProjectBuild({ status: testStatus }));
options.project = testProject;
return appveyorStatus.getLastBuild(options)
  .then((projectBuild) => {
    assert.strictEqual(projectBuildToStatus(projectBuild), testStatus);
    ne.done();
  });
queries repo in cwd by default
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testBranch = 'testb';
const testRemote = 'testr';
const testRemoteUrl = 'git://foo.bar/baz';
const testStatus = 'success';
gitUtilsMock.expects('getBranch')
  .once().withArgs(matchOptionsCwd).resolves(testBranch);
gitUtilsMock.expects('getRemote')
  .once().withArgs(testBranch, matchOptionsCwd).resolves(testRemote);
gitUtilsMock.expects('getRemoteUrl')
  .once().withArgs(testRemote, matchOptionsCwd).resolves(testRemoteUrl);
const ne = nock(apiUrl)
  .get('/api/projects')
  .reply(200, [
    apiResponses.getProject({
      repositoryType: 'git',
      repositoryName: testRemoteUrl,
      status: testStatus,
    }),
  ]);
return appveyorStatus.getLastBuild(options)
  .then((projectBuild) => {
    assert.strictEqual(projectBuildToStatus(projectBuild), testStatus);
    ne.done();
  });
resolves branch, commit, and remote URL in local repo
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testBranch = 'testb';
const testCommit = 'testtag';
const testCommitHash = '4b482f89ef23e06ad6a9c01adaece30943bf434c';
const testRemote = 'testr';
const testRemoteUrl = 'git://foo.bar/baz';
const testRepo = 'foo/bar';
const testStatus = 'success';
const matchRepoCwd = match({ cwd: testRepo });
gitUtilsMock.expects('getBranch')
  .once().withArgs(matchRepoCwd).resolves(testBranch);
gitUtilsMock.expects('getRemote')
  .once().withArgs(testBranch, matchRepoCwd).resolves(testRemote);
gitUtilsMock.expects('getRemoteUrl')
  .once().withArgs(testRemote, matchRepoCwd).resolves(testRemoteUrl);
gitUtilsMock.expects('resolveCommit')
  .once().withArgs(testCommit, matchRepoCwd).resolves(testCommitHash);
const ne = nock(apiUrl)
  .get('/api/projects')
  .reply(200, [
    apiResponses.getProject({
      branch: testBranch,
      commitId: testCommitHash,
      repositoryType: 'git',
      repositoryName: testRemoteUrl,
      status: testStatus,
    }),
  ]);
options.branch = true;
options.commit = testCommit;
options.repo = testRepo;
return appveyorStatus.getLastBuild(options)
  .then((projectBuild) => {
    assert.strictEqual(projectBuildToStatus(projectBuild), testStatus);
    ne.done();
  });
falls back to origin if not on a branch
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testRemoteUrl = 'git://foo.bar/baz';
const testStatus = 'success';
gitUtilsMock.expects('getBranch')
  .once().withArgs(matchOptionsCwd).rejects(new Error());
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl')
  .once().withArgs('origin', matchOptionsCwd).resolves(testRemoteUrl);
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get('/api/projects')
  .reply(200, [
    apiResponses.getProject({
      repositoryType: 'git',
      repositoryName: testRemoteUrl,
      status: testStatus,
    }),
  ]);
return appveyorStatus.getLastBuild(options)
  .then((projectBuild) => {
    assert.strictEqual(options.err.read(), null);
    assert.strictEqual(projectBuildToStatus(projectBuild), testStatus);
    ne.done();
  });
falls back to origin if branch has no remote
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testBranch = 'testb';
const testRemoteUrl = 'git://foo.bar/baz';
const testStatus = 'success';
gitUtilsMock.expects('getBranch')
  .once().withArgs(matchOptionsCwd).resolves(testBranch);
gitUtilsMock.expects('getRemote')
  .once().withArgs(testBranch, matchOptionsCwd).rejects(new Error());
gitUtilsMock.expects('getRemoteUrl')
  .once().withArgs('origin', matchOptionsCwd).resolves(testRemoteUrl);
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get('/api/projects')
  .reply(200, [
    apiResponses.getProject({
      repositoryType: 'git',
      repositoryName: testRemoteUrl,
      status: testStatus,
    }),
  ]);
options.verbosity = 1;
return appveyorStatus.getLastBuild(options)
  .then((projectBuild) => {
    const errStr = String(options.err.read());
    assert.match(errStr, /\bremote\b/i);
    assert.match(errStr, /\borigin\b/i);
    assert.strictEqual(projectBuildToStatus(projectBuild), testStatus);
    ne.done();
  });
rejects with Error if no project matches repo
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testRepo = 'git://foo.bar/baz';
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get('/api/projects')
  .query(true)
  .reply(200, [
    apiResponses.getProject({
      repositoryType: 'git',
      repositoryName: `${testRepo}/quux`,
      status: testStatus,
    }),
  ]);
options.repo = testRepo;
return appveyorStatus.getLastBuild(options).then(
  sinon.mock().never(),
  (err) => {
    assert.instanceOf(err, Error);
    assert.include(err.message, testRepo);
    ne.done();
  },
);
AmbiguousProjectError if multiple projects match repo
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testProject1 = ['myacct', 'proj1'];
const testProject2 = ['youracct', 'proj2'];
const testRepo = 'git://foo.bar/baz';
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get('/api/projects')
  .query(true)
  .reply(200, [
    apiResponses.getProject({
      accountName: testProject1[0],
      repositoryType: 'git',
      repositoryName: testRepo,
      slug: testProject1[1],
      status: testStatus,
    }),
    apiResponses.getProject({
      accountName: testProject2[0],
      repositoryType: 'git',
      repositoryName: testRepo,
      slug: testProject2[1],
      status: testStatus,
    }),
  ]);
options.repo = testRepo;
return appveyorStatus.getLastBuild(options).then(
  sinon.mock().never(),
  (err) => {
    assert.instanceOf(err, AmbiguousProjectError);
    assert.deepEqual(
      err.projects,
      [testProject1.join('/'), testProject2.join('/')],
    );
    ne.done();
  },
);
rejects with Error for non-200 responses
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testErrMsg = 'bad dead bodies';
const testProject = 'foo/bar';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/${testProject}`)
  .query(true)
  .reply(400, { message: testErrMsg });
options.project = testProject;
return appveyorStatus.getLastBuild(options).then(
  sinon.mock().never(),
  (err) => {
    assert.match(err.message, /400|Bad Request/i);
    assert.include(err.message, testErrMsg);
    assert.strictEqual(err.status, 400);
    ne.done();
  },
);
rejects with Error for non-JSON responses
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testProject = 'foo/bar';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/${testProject}`)
  .query(true)
  .reply(200, 'invalid', { 'Content-Type': 'text/plain' });
options.project = testProject;
return appveyorStatus.getLastBuild(options).then(
  sinon.mock().never(),
  (err) => {
    assert.include(err.message, 'JSON');
    ne.done();
  },
);
rejects with Error for request error
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testErrMsg = 'something bad happened';
const testProject = 'foo/bar';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/${testProject}`)
  .query(true)
  .replyWithError(testErrMsg);
options.project = testProject;
return appveyorStatus.getLastBuild(options).then(
  sinon.mock().never(),
  (err) => {
    assert.include(err.message, testErrMsg);
    ne.done();
  },
);
passes options.token as bearer token
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testRepo = 'git://foo.bar/baz';
const testStatus = 'success';
const testToken = 'testtoken';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  // IMPORTANT: Must be path which requires auth
  .get('/api/projects')
  .query(true)
  .reply(200, function(uri, requestBody) {
    assert.deepEqual(
      this.req.headers.authorization,
      [`Bearer ${testToken}`],
    );
    return [
      apiResponses.getProject({
        repositoryType: 'git',
        repositoryName: testRepo,
        status: testStatus,
      }),
    ];
  });
options.repo = testRepo;
options.token = testToken;
return appveyorStatus.getLastBuild(options)
  .then((projectBuild) => {
    assert.strictEqual(projectBuildToStatus(projectBuild), testStatus);
    ne.done();
  });
ignores options.token when appveyorClient is given
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testRepo = 'git://foo.bar/baz';
const testStatus = 'success';
const testToken1 = 'testtoken1';
const testToken2 = 'testtoken2';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  // IMPORTANT: Must be path which requires auth
  .get('/api/projects')
  .query(true)
  .reply(200, function(uri, requestBody) {
    assert.deepEqual(
      this.req.headers.authorization,
      [`Bearer ${testToken2}`],
    );
    return [
      apiResponses.getProject({
        repositoryType: 'git',
        repositoryName: testRepo,
        status: testStatus,
      }),
    ];
  });
options.appveyorClient = new SwaggerClient({
  authorizations: {
    apiToken: `Bearer ${testToken2}`,
  },
  spec: appveyorSwagger,
});
options.repo = testRepo;
options.token = testToken1;
return appveyorStatus.getLastBuild(options)
  .then((projectBuild) => {
    assert.strictEqual(projectBuildToStatus(projectBuild), testStatus);
    ne.done();
  });
rejects with Error for statusBadgeId
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
options.statusBadgeId = 'abcde';
return appveyorStatus.getLastBuild(options).then(
  sinon.mock().never(),
  (err) => {
    assert.match(err.message, /required|supported/i);
  },
);
rejects with Error for webhookId
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
options.webhookId = 'abcde';
return appveyorStatus.getLastBuild(options).then(
  sinon.mock().never(),
  (err) => {
    assert.match(err.message, /required|supported/i);
  },
);

with wait

true retries queued status
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testProject = 'foo/bar';
const testStatus = 'success';
const expectQueued = nock(apiUrl)
  .get(`/api/projects/${testProject}`)
  .query(true)
  .reply(200, apiResponses.getProjectBuild({ status: 'queued' }));
const expectSuccess = nock(apiUrl)
  .get(`/api/projects/${testProject}`)
  .query(true)
  .reply(200, apiResponses.getProjectBuild({ status: testStatus }));
let retriesDone = false;
afterFirstRequest(() => {
  assert(expectQueued.isDone(), 'First call is made immediately.');
  assert(!expectSuccess.isDone(), 'Retry is not done immediately.');
  clock.tick(900);
  assert(!expectSuccess.isDone(), 'Retry is not done less than 1 sec.');
  clock.tick(60000);
  assert(expectSuccess.isDone(), 'Retry is done less than 1 minute.');
  retriesDone = true;
});
options.project = testProject;
options.wait = true;
return appveyorStatus.getLastBuild(options)
  .then((projectBuild) => {
    assert.strictEqual(projectBuildToStatus(projectBuild), testStatus);
    assert(retriesDone, 'Retries completed');
    assert.strictEqual(
      options.err.read(),
      null,
      'does not print wait messages by default',
    );
  });
true retries running status from project
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testProjectParts = ['foo', 'bar'];
const testRepoUrl = 'git://foo.bar/baz';
const testStatus = 'success';
const expectQueued = nock(apiUrl)
  .get('/api/projects')
  .query(true)
  .reply(200, [
    apiResponses.getProject({
      accountName: testProjectParts[0],
      repositoryType: 'git',
      repositoryName: testRepoUrl,
      slug: testProjectParts[1],
      status: 'running',
    }),
  ]);
const expectSuccess = nock(apiUrl)
  .get(`/api/projects/${testProjectParts.join('/')}`)
  .query(true)
  .reply(200, apiResponses.getProjectBuild({ status: testStatus }));
let retriesDone = false;
afterFirstRequest(() => {
  assert(expectQueued.isDone(), 'First call is made immediately.');
  assert(!expectSuccess.isDone(), 'Retry is not done immediately.');
  clock.tick(900);
  assert(!expectSuccess.isDone(), 'Retry is not done less than 1 sec.');
  clock.tick(60000);
  assert(expectSuccess.isDone(), 'Retry is done less than 1 minute.');
  retriesDone = true;
});
options.repo = testRepoUrl;
options.wait = true;
options.verbosity = 1;
return appveyorStatus.getLastBuild(options)
  .then((projectBuild) => {
    assert.strictEqual(projectBuildToStatus(projectBuild), testStatus);
    assert(retriesDone, 'Retries completed');
    assert.match(
      String(options.err.read()),
      /\bwait/i,
      'prints wait message when verbose',
    );
  });
is stopped on error
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testErrMsg = 'something bad';
const testProject = 'foo/bar';
const expectQueued = nock(apiUrl)
  .get(`/api/projects/${testProject}`)
  .query(true)
  .reply(200, apiResponses.getProjectBuild({ status: 'queued' }));
const expectSuccess = nock(apiUrl)
  .get(`/api/projects/${testProject}`)
  .query(true)
  .replyWithError(testErrMsg);
let retriesDone = false;
afterFirstRequest(() => {
  assert(expectQueued.isDone(), 'First call is made immediately.');
  assert(!expectSuccess.isDone(), 'Retry is not done immediately.');
  clock.tick(900);
  assert(!expectSuccess.isDone(), 'Retry is not done less than 1 sec.');
  clock.tick(60000);
  assert(expectSuccess.isDone(), 'Retry is done less than 1 minute.');
  retriesDone = true;
});
options.project = testProject;
options.wait = true;
return appveyorStatus.getLastBuild(options).then(
  sinon.mock().never(),
  (err) => {
    assert.include(err.message, testErrMsg);
    assert(retriesDone, 'Retries completed');
  },
);
returns queued status if wait elapses
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testProject = 'foo/bar';
const expectQueued1 = nock(apiUrl)
  .get(`/api/projects/${testProject}`)
  .query(true)
  .reply(200, apiResponses.getProjectBuild({ status: 'queued' }));
const expectQueued2 = nock(apiUrl)
  .get(`/api/projects/${testProject}`)
  .query(true)
  .reply(200, apiResponses.getProjectBuild({ status: 'queued' }));
// This test does not specify specifics of exponential backoff
nock(apiUrl)
  .persist()
  .get(`/api/projects/${testProject}`)
  .query(true)
  .reply(200, apiResponses.getProjectBuild({ status: 'queued' }));
let retriesDone = false;
afterFirstRequest(() => {
  assert(expectQueued1.isDone(), 'First call is made immediately.');
  assert(!expectQueued2.isDone(), 'Retry is not done immediately.');
  clock.tick(900);
  assert(!expectQueued2.isDone(), 'Retry is not done less than 1 sec.');
  clock.tick(60000);
  assert(expectQueued2.isDone(), 'Retry is done less than 1 minute.');
  retriesDone = true;
});
options.project = testProject;
options.wait = 8000;
return appveyorStatus.getLastBuild(options)
  .then((projectBuild) => {
    assert.strictEqual(projectBuildToStatus(projectBuild), 'queued');
    assert(retriesDone, 'Retries completed');
  });

.getStatusBadge

queries badge by repo URL
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testBadgeUrlPath = 'gitHub/foo/bar';
const testRepoUrl = 'git@github.com:foo/bar.git';
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/status/${testBadgeUrlPath}`)
  .query(true)
  .reply(
    200,
    apiResponses.getStatusBadge(testStatus),
    { 'Content-Type': 'image/svg+xml' },
  );
options.repo = testRepoUrl;
return appveyorStatus.getStatusBadge(options)
  .then((badge) => {
    assert.strictEqual(badgeToStatus(badge), testStatus);
    ne.done();
  });
queries badge by repo URL and branch
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testBadgeUrlPath = 'gitHub/foo/bar';
const testBranch = 'testb';
const testRepoUrl = 'git@github.com:foo/bar.git';
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/status/${testBadgeUrlPath}`)
  .query((query) => query.branch === testBranch && query.svg === 'true')
  .reply(
    200,
    apiResponses.getStatusBadge(testStatus),
    { 'Content-Type': 'image/svg+xml' },
  );
options.branch = testBranch;
options.repo = testRepoUrl;
return appveyorStatus.getStatusBadge(options)
  .then((badge) => {
    assert.strictEqual(badgeToStatus(badge), testStatus);
    ne.done();
  });
queries badge by statusBadgeId
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testStatusBadgeId = 'abcde';
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/status/${testStatusBadgeId}`)
  .query(true)
  .reply(
    200,
    apiResponses.getStatusBadge(testStatus),
    { 'Content-Type': 'image/svg+xml' },
  );
options.statusBadgeId = testStatusBadgeId;
return appveyorStatus.getStatusBadge(options)
  .then((badge) => {
    assert.strictEqual(badgeToStatus(badge), testStatus);
    ne.done();
  });
queries badge by webhookId
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testWebhookId = 'abcde';
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/status/${testWebhookId}`)
  .query(true)
  .reply(
    200,
    apiResponses.getStatusBadge(testStatus),
    { 'Content-Type': 'image/svg+xml' },
  );
options.webhookId = testWebhookId;
return appveyorStatus.getStatusBadge(options)
  .then((badge) => {
    assert.strictEqual(badgeToStatus(badge), testStatus);
    ne.done();
  });
queries badge by statusBadgeId and branch
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testBranch = 'testb';
const testStatusBadgeId = 'abcde';
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/status/${testStatusBadgeId}/branch/${testBranch}`)
  .query(true)
  .reply(
    200,
    apiResponses.getStatusBadge(testStatus),
    { 'Content-Type': 'image/svg+xml' },
  );
options.branch = testBranch;
options.statusBadgeId = testStatusBadgeId;
return appveyorStatus.getStatusBadge(options)
  .then((badge) => {
    assert.strictEqual(badgeToStatus(badge), testStatus);
    ne.done();
  });
queries badge by webhookId and branch
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testBranch = 'testb';
const testWebhookId = 'abcde';
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/status/${testWebhookId}/branch/${testBranch}`)
  .query(true)
  .reply(
    200,
    apiResponses.getStatusBadge(testStatus),
    { 'Content-Type': 'image/svg+xml' },
  );
options.branch = testBranch;
options.webhookId = testWebhookId;
return appveyorStatus.getStatusBadge(options)
  .then((badge) => {
    assert.strictEqual(badgeToStatus(badge), testStatus);
    ne.done();
  });
rejects with Error for non-200 response
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testWebhookId = 'abcde';
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/status/${testWebhookId}`)
  .query(true)
  .reply(
    400,
    apiResponses.getStatusBadge(testStatus),
    { 'Content-Type': 'image/svg+xml' },
  );
options.statusBadgeId = testWebhookId;
return appveyorStatus.getStatusBadge(options).then(
  sinon.mock().never(),
  (err) => {
    assert.match(err.message, /400|Bad Request/i);
    assert.strictEqual(err.status, 400);
    ne.done();
  },
);
rejects with Error for non-SVG response
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testWebhookId = 'abcde';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/status/${testWebhookId}`)
  .query(true)
  .reply(200, 'invalid', { 'Content-Type': 'text/plain' });
options.statusBadgeId = testWebhookId;
return appveyorStatus.getStatusBadge(options).then(
  sinon.mock().never(),
  (err) => {
    assert.match(err.message, /svg/i);
    ne.done();
  },
);
rejects with Error for response without Content-Type
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testStatusBadgeId = 'abcde';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/status/${testStatusBadgeId}`)
  .query(true)
  .reply(200, 'invalid', { 'Content-Type': undefined });
options.statusBadgeId = testStatusBadgeId;
return appveyorStatus.getStatusBadge(options).then(
  sinon.mock().never(),
  (err) => {
    assert.match(err.message, /svg/i);
    ne.done();
  },
);
rejects with Error for options.project
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
options.project = 'foo/bar';
return appveyorStatus.getStatusBadge(options).then(
  sinon.mock().never(),
  (err) => {
    assert.match(err.message, /required|supported/i);
  },
);

.getStatus

returns status from last build for project
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testProject = 'foo/bar';
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/${testProject}`)
  .reply(200, apiResponses.getProjectBuild({ status: testStatus }));
options.project = testProject;
return appveyorStatus.getStatus(options)
  .then((status) => {
    assert.strictEqual(status, testStatus);
    ne.done();
  });
returns status from badge for GitHub repo
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testProject = 'foo/bar';
const testRepo = `https://github.com/${testProject}.git`;
const testStatus = 'success';
gitUtilsMock.expects('getBranch').never();
gitUtilsMock.expects('getRemote').never();
gitUtilsMock.expects('getRemoteUrl').never();
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/status/gitHub/${testProject}`)
  .query(true)
  .reply(
    200,
    apiResponses.getStatusBadge(testStatus),
    { 'Content-Type': 'image/svg+xml' },
  );
options.repo = testRepo;
return appveyorStatus.getStatus(options)
  .then((status) => {
    assert.strictEqual(status, testStatus);
    ne.done();
  });
can be called with callback without options
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
const testBranch = 'testb';
const testProject = 'foo/bar';
const testRemote = 'testr';
const testRemoteUrl = `https://github.com/${testProject}.git`;
const testStatus = 'success';
gitUtilsMock.expects('getBranch')
  .once().withArgs(matchOptionsCwd).resolves(testBranch);
gitUtilsMock.expects('getRemote')
  .once().withArgs(testBranch, matchOptionsCwd).resolves(testRemote);
gitUtilsMock.expects('getRemoteUrl')
  .once().withArgs(testRemote, matchOptionsCwd).resolves(testRemoteUrl);
gitUtilsMock.expects('resolveCommit').never();
const ne = nock(apiUrl)
  .get(`/api/projects/status/gitHub/${testProject}`)
  .query(true)
  .reply(
    200,
    apiResponses.getStatusBadge(testStatus),
    { 'Content-Type': 'image/svg+xml' },
  );
appveyorStatus.getStatus((err, status) => {
  assert.ifError(err);
  assert.strictEqual(status, testStatus);
  ne.done();
  done();
});
throws TypeError for non-function callback
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
assert.throws(
  () => { appveyorStatus.getStatus(options, true); },
  TypeError,
);
rejects non-object options with TypeError
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
appveyorStatus.getStatus(true).then(
        sinon.mock().never(),
        (err) => {
          assert.instanceOf(err, TypeError);
          assert.match(err.message, /\boptions\b/);
        },
      )
rejects project and repo with Error
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
options.project = 'foo/bar';
options.repo = '.';
return appveyorStatus.getStatus(options).then(
  sinon.mock().never(),
  (err) => {
    assert.instanceOf(err, Error);
    assert.match(err.message, /\bproject\b/);
    assert.match(err.message, /\brepo\b/);
  },
);
rejects project and statusBadgeId with Error
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
options.project = 'foo/bar';
options.statusBadgeId = 'abcde';
return appveyorStatus.getStatus(options).then(
  sinon.mock().never(),
  (err) => {
    assert.instanceOf(err, Error);
    assert.match(err.message, /\bproject\b/);
    assert.match(err.message, /\bstatusBadgeId\b/);
  },
);
rejects repo and statusBadgeId with Error
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
options.repo = '.';
options.statusBadgeId = 'abcde';
return appveyorStatus.getStatus(options).then(
  sinon.mock().never(),
  (err) => {
    assert.instanceOf(err, Error);
    assert.match(err.message, /\brepo\b/);
    assert.match(err.message, /\bstatusBadgeId\b/);
  },
);
rejects project and webhookId with Error
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
options.project = 'foo/bar';
options.webhookId = 'abcde';
return appveyorStatus.getStatus(options).then(
  sinon.mock().never(),
  (err) => {
    assert.instanceOf(err, Error);
    assert.match(err.message, /\bproject\b/);
    assert.match(err.message, /\bwebhookId\b/);
  },
);
rejects repo and webhookId with Error
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
options.repo = '.';
options.webhookId = 'abcde';
return appveyorStatus.getStatus(options).then(
  sinon.mock().never(),
  (err) => {
    assert.instanceOf(err, Error);
    assert.match(err.message, /\brepo\b/);
    assert.match(err.message, /\bwebhookId\b/);
  },
);
rejects non-Writable err with TypeError
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
appveyorStatus.getStatus({ err: new stream.Readable() }).then(
        sinon.mock().never(),
        (err) => {
          assert.instanceOf(err, TypeError);
          assert.match(err.message, /\berr\b/);
        },
      )
rejects non-numeric wait with TypeError
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
options.wait = 'forever';
return appveyorStatus.getStatus(options).then(
  sinon.mock().never(),
  (err) => {
    assert.instanceOf(err, TypeError);
    assert.match(err.message, /\bwait\b/);
  },
);
rejects negative wait with RangeError
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
options.wait = -1;
return appveyorStatus.getStatus(options).then(
  sinon.mock().never(),
  (err) => {
    assert.instanceOf(err, RangeError);
    assert.match(err.message, /\bwait\b/);
  },
);
rejects project without accountName with Error
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
options.project = {
  slug: 'foo',
};
return appveyorStatus.getStatus(options).then(
  sinon.mock().never(),
  (err) => {
    assert.instanceOf(err, Error);
    assert.match(err.message, /\bproject\b/);
    assert.match(err.message, /\baccountName\b/);
  },
);
rejects project without slug with Error
/home/kevin/src/node-projects/appveyor-status/test/appveyor-status.js
options.project = {
  accountName: 'foo',
};
return appveyorStatus.getStatus(options).then(
  sinon.mock().never(),
  (err) => {
    assert.instanceOf(err, Error);
    assert.match(err.message, /\bproject\b/);
    assert.match(err.message, /\bslug\b/);
  },
);

appveyor-status command

returns undefined when called with a function
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once()
  .withArgs(
    match.object,
    match.func,
  );
const result = appveyorStatusCmd(RUNTIME_ARGS, sinon.mock().never());
appveyorStatusMock.verify();
assert.strictEqual(result, undefined);
prints error and exits for --badge
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
prints error and exits for -B
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
interprets --badge foo as match(statusBadgeId: foo)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -B foo as match(statusBadgeId: foo)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets --branch as match(branch: true)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -b as match(branch: true)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets --branch foo as match(branch: foo)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -b foo as match(branch: foo)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets --color as match(color: true)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets --no-color as match(color: false)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets --commit as match(commit: HEAD)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -c as match(commit: HEAD)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets --commit foo as match(commit: foo)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets --commit 123 as match(commit: 123)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -c foo as match(commit: foo)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
prints error and exits for --help
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
prints error and exits for -h
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
prints error and exits for -?
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
prints error and exits for --project
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
prints error and exits for -p
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
interprets --project foo as match(project: foo)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -p foo as match(project: foo)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets --quiet as match(verbosity: -1)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -q as match(verbosity: -1)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -qq as match(verbosity: -2)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets --quiet -q as match(verbosity: -2)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
prints error and exits for --repo
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
prints error and exits for -r
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
interprets --repo foo as match(repo: foo)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -r foo as match(repo: foo)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
prints error and exits for --token
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
prints error and exits for -t
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
interprets as match(token: env-token)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets --token foo as match(token: foo)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -t foo as match(token: foo)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
prints error and exits for --token-file
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
prints error and exits for -T
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
interprets --token-file /home/kevin/src/node-projects/appveyor-status/test-data/token.txt as match(token: file-token)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -T /home/kevin/src/node-projects/appveyor-status/test-data/token.txt as match(token: file-token)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
prints error and exits for --token-file badfile
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
prints error and exits for -T badfile
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
interprets --verbose as match(verbosity: 1)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -v as match(verbosity: 1)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -vv as match(verbosity: 2)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets --verbose -v as match(verbosity: 2)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets --wait as match(wait: Infinity)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -w as match(wait: Infinity)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets --wait 10 as match(wait: 10000)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -w 10 as match(wait: 10000)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
prints error and exits for --wait foo
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
prints error and exits for -w foo
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
prints error and exits for --webhook
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
prints error and exits for -W
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
interprets --webhook foo as match(webhookId: foo)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -W foo as match(webhookId: foo)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
prints error and exits for -t foo -T bar
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
interprets -q -v as match(verbosity: 0)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -v -q as match(verbosity: 0)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
interprets -v -q -v as match(verbosity: 1)
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    expectObj,
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
prints error and exits for --version
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
prints error and exits for -V
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
prints error and exits for foo
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const allArgs = RUNTIME_ARGS.concat(args);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  if (expectOutMsg instanceof RegExp) {
    assert.match(String(options.out.read()), expectOutMsg);
  } else {
    assert.strictEqual(options.out.read(), expectOutMsg);
  }
  if (expectErrMsg instanceof RegExp) {
    assert.match(String(options.err.read()), expectErrMsg);
  } else {
    assert.strictEqual(options.err.read(), expectErrMsg);
  }
  appveyorStatusMock.verify();
  done();
});
interprets -T - as reading token from stdin
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').once()
  .withArgs(
    match({ token: 'file-token' }),
    match.func,
  )
  .yields(null, 'success');
const allArgs = RUNTIME_ARGS.concat('-T', '-');
options.in = fs.createReadStream(TEST_TOKEN_PATH);
appveyorStatusCmd(allArgs, options, (err) => {
  assert.ifError(err);
  appveyorStatusMock.verify();
  done();
});
exits with code 2 for build cancelled
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  done();
});
exits with code 2 for build cancelling
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  done();
});
exits with code 2 for build failed
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  done();
});
exits with code 2 for build queued
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  done();
});
exits with code 2 for build running
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  done();
});
exits with code 2 for build starting
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  done();
});
exits with code 0 for build success
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  done();
});
exits with code 2 for build unrecognized
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, expectCode);
  done();
});
prints status to stdout by default
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, 'success');
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, 0);
  assert.strictEqual(
    String(options.out.read()),
    // Be strict about this format since other programs may use it
    'AppVeyor build status: success\n',
  );
  assert.strictEqual(options.err.read(), null);
  done();
});
-q exits without printing status
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, 'failed');
const allArgs = RUNTIME_ARGS.concat(arg);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, 2);
  assert.strictEqual(options.out.read(), null);
  assert.strictEqual(options.err.read(), null);
  done();
});
--quiet exits without printing status
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, 'failed');
const allArgs = RUNTIME_ARGS.concat(arg);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, 2);
  assert.strictEqual(options.out.read(), null);
  assert.strictEqual(options.err.read(), null);
  done();
});
allows callback errors to propagate
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const errTest = new Error('test');
let caughtError = false;
let called = false;
// Note:  Chai assert.throws does not accept comparison function like node
try {
  const allArgs = RUNTIME_ARGS.concat(['foo']);
  appveyorStatusCmd(allArgs, options, () => {
    assert(!called, 'callback called exactly once');
    called = true;
    throw errTest;
  });
} catch (err) {
  caughtError = true;
  assert.strictEqual(err, errTest);
}
assert(caughtError, 'Missing expected exception.');
throws for non-function callback
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
assert.throws(
  () => { appveyorStatusCmd(RUNTIME_ARGS, {}, true); },
  TypeError,
  /\bcallback\b/,
);
can be called without arguments
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once()
  .withArgs(
    match.object,
    match.func,
  );
appveyorStatusCmd(null, sinon.mock().never());
appveyorStatusMock.verify();
yields TypeError for non-Array-like args
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
appveyorStatusCmd(true, options, (err) => {
  assert.instanceOf(err, TypeError);
  assert.match(err.message, /\bArray\b/);
  done();
});
yields RangeError for less than 2 args
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
appveyorStatusCmd([], options, (err) => {
  assert.instanceOf(err, RangeError);
  assert.match(err.message, /\bargs\b/);
  done();
});
yields Error for non-object options
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
appveyorStatusCmd(RUNTIME_ARGS, true, (err) => {
  assert.instanceOf(err, TypeError);
  assert.match(err.message, /\boptions\b/);
  done();
});
yields Error for non-Readable in
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
appveyorStatusCmd(RUNTIME_ARGS, { in: true }, (err) => {
  assert.instanceOf(err, TypeError);
  assert.match(err.message, /\boptions.in\b/);
  done();
});
yields Error for non-Writable out
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const badOptions = { out: new stream.Readable() };
appveyorStatusCmd(RUNTIME_ARGS, badOptions, (err) => {
  assert.instanceOf(err, TypeError);
  assert.match(err.message, /\boptions.out\b/);
  done();
});
yields Error for non-Writable err
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const badOptions = { err: new stream.Readable() };
appveyorStatusCmd(RUNTIME_ARGS, badOptions, (err) => {
  assert.instanceOf(err, TypeError);
  assert.match(err.message, /\boptions.err\b/);
  done();
});
exit code 1 and prints message on Error
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
const errMsg = 'super duper test error';
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(new Error(errMsg));
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, 1);
  assert.strictEqual(options.out.read(), null);
  const errString = String(options.err.read());
  assert.include(errString, errMsg);
  done();
});
exit code 3 and prints message on CommitMismatchError
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
const testCommit = '123';
const errTest = new CommitMismatchError({
  actual: 'foo',
  expected: testCommit,
});
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(errTest);
const allArgs = RUNTIME_ARGS.concat(['-c', testCommit]);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, 3);
  assert.strictEqual(options.out.read(), null);
  const errString = String(options.err.read());
  assert.include(errString, errTest.actual);
  assert.include(errString, errTest.expected);
  done();
});
CommitMismatchError prints both given and resolved
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
const testCommit = '123';
const testTag = 'tagname';
const errTest = new CommitMismatchError({
  actual: 'abc',
  expected: testCommit,
});
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(errTest);
const allArgs = RUNTIME_ARGS.concat(['-c', testTag]);
appveyorStatusCmd(allArgs, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, 3);
  assert.strictEqual(options.out.read(), null);
  const errString = String(options.err.read());
  assert.include(errString, errTest.actual);
  assert.include(errString, errTest.expected);
  assert.include(errString, testTag);
  done();
});
returns a Promise when called without a function
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func);
const result = appveyorStatusCmd(RUNTIME_ARGS);
assert(result instanceof Promise);
returned Promise is resolved with exit code
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, 'success');
const result = appveyorStatusCmd(RUNTIME_ARGS, options);
return result.then((code) => {
  assert.strictEqual(code, 0);
});
returned Promise is rejected with Error
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus').never();
const result = appveyorStatusCmd(RUNTIME_ARGS, true);
return result.then(
  sinon.mock().never(),
  (err) => { assert.instanceOf(err, TypeError); },
);

with $TERM=xterm

prints cancelled in gray to TTY
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
options.out.isTTY = true;
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, status === 'success' ? 0 : 2);
  const outString = String(options.out.read());
  const ansiStyle = ansiStyles[colorName];
  assert.include(
    outString,
    `${ansiStyle.open}status${ansiStyle.close}`,
  );
  assert.strictEqual(options.err.read(), null);
  done();
});
prints cancelling in gray to TTY
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
options.out.isTTY = true;
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, status === 'success' ? 0 : 2);
  const outString = String(options.out.read());
  const ansiStyle = ansiStyles[colorName];
  assert.include(
    outString,
    `${ansiStyle.open}status${ansiStyle.close}`,
  );
  assert.strictEqual(options.err.read(), null);
  done();
});
prints failed in red to TTY
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
options.out.isTTY = true;
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, status === 'success' ? 0 : 2);
  const outString = String(options.out.read());
  const ansiStyle = ansiStyles[colorName];
  assert.include(
    outString,
    `${ansiStyle.open}status${ansiStyle.close}`,
  );
  assert.strictEqual(options.err.read(), null);
  done();
});
prints queued in gray to TTY
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
options.out.isTTY = true;
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, status === 'success' ? 0 : 2);
  const outString = String(options.out.read());
  const ansiStyle = ansiStyles[colorName];
  assert.include(
    outString,
    `${ansiStyle.open}status${ansiStyle.close}`,
  );
  assert.strictEqual(options.err.read(), null);
  done();
});
prints running in gray to TTY
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
options.out.isTTY = true;
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, status === 'success' ? 0 : 2);
  const outString = String(options.out.read());
  const ansiStyle = ansiStyles[colorName];
  assert.include(
    outString,
    `${ansiStyle.open}status${ansiStyle.close}`,
  );
  assert.strictEqual(options.err.read(), null);
  done();
});
prints starting in gray to TTY
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
options.out.isTTY = true;
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, status === 'success' ? 0 : 2);
  const outString = String(options.out.read());
  const ansiStyle = ansiStyles[colorName];
  assert.include(
    outString,
    `${ansiStyle.open}status${ansiStyle.close}`,
  );
  assert.strictEqual(options.err.read(), null);
  done();
});
prints success in green to TTY
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
options.out.isTTY = true;
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, status === 'success' ? 0 : 2);
  const outString = String(options.out.read());
  const ansiStyle = ansiStyles[colorName];
  assert.include(
    outString,
    `${ansiStyle.open}status${ansiStyle.close}`,
  );
  assert.strictEqual(options.err.read(), null);
  done();
});

with $TERM=dumb

prints cancelled without color to TTY
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
options.out.isTTY = true;
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, status === 'success' ? 0 : 2);
  const outString = String(options.out.read());
  assert(!hasAnsi(outString), 'does not have color escapes');
  assert.strictEqual(options.err.read(), null);
  done();
});
prints cancelling without color to TTY
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
options.out.isTTY = true;
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, status === 'success' ? 0 : 2);
  const outString = String(options.out.read());
  assert(!hasAnsi(outString), 'does not have color escapes');
  assert.strictEqual(options.err.read(), null);
  done();
});
prints failed without color to TTY
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
options.out.isTTY = true;
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, status === 'success' ? 0 : 2);
  const outString = String(options.out.read());
  assert(!hasAnsi(outString), 'does not have color escapes');
  assert.strictEqual(options.err.read(), null);
  done();
});
prints queued without color to TTY
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
options.out.isTTY = true;
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, status === 'success' ? 0 : 2);
  const outString = String(options.out.read());
  assert(!hasAnsi(outString), 'does not have color escapes');
  assert.strictEqual(options.err.read(), null);
  done();
});
prints running without color to TTY
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
options.out.isTTY = true;
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, status === 'success' ? 0 : 2);
  const outString = String(options.out.read());
  assert(!hasAnsi(outString), 'does not have color escapes');
  assert.strictEqual(options.err.read(), null);
  done();
});
prints starting without color to TTY
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
options.out.isTTY = true;
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, status === 'success' ? 0 : 2);
  const outString = String(options.out.read());
  assert(!hasAnsi(outString), 'does not have color escapes');
  assert.strictEqual(options.err.read(), null);
  done();
});
prints success without color to TTY
/home/kevin/src/node-projects/appveyor-status/test/bin/appveyor-status.js
appveyorStatusMock.expects('getStatus')
  .once().withArgs(match.object, match.func).yields(null, status);
options.out.isTTY = true;
appveyorStatusCmd(RUNTIME_ARGS, options, (err, code) => {
  assert.ifError(err);
  assert.strictEqual(code, status === 'success' ? 0 : 2);
  const outString = String(options.out.read());
  assert(!hasAnsi(outString), 'does not have color escapes');
  assert.strictEqual(options.err.read(), null);
  done();
});

AmbiguousProjectError

sets .message and .projects from arguments
/home/kevin/src/node-projects/appveyor-status/test/lib/ambiguous-project-error.js
const testMsg = 'test message';
const testProjects = [];
const a = new AmbiguousProjectError(testMsg, testProjects);
assert.strictEqual(a.message, testMsg);
assert.strictEqual(a.projects, testProjects);
can be instantiated without arguments
/home/kevin/src/node-projects/appveyor-status/test/lib/ambiguous-project-error.js
const a = new AmbiguousProjectError();
assert(a.message, 'has default message');
assert.strictEqual(a.projects, undefined);
can be instantiated without new
/home/kevin/src/node-projects/appveyor-status/test/lib/ambiguous-project-error.js
const testMsg = 'test message';
const testProjects = [];
// eslint-disable-next-line new-cap
const a = AmbiguousProjectError(testMsg, testProjects);
assert(a instanceof AmbiguousProjectError);
assert.strictEqual(a.message, testMsg);
assert.strictEqual(a.projects, testProjects);
inherits from Error
/home/kevin/src/node-projects/appveyor-status/test/lib/ambiguous-project-error.js
const testMsg = 'test message';
const testProjects = [];
const a = new AmbiguousProjectError(testMsg, testProjects);
assert(a instanceof Error);

appveyorUtils

.badgeToStatus

extracts success status
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const badge = apiResponses.getStatusBadge(status);
const result = appveyorUtils.badgeToStatus(badge);
assert.strictEqual(result, status);
extracts failed status
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const badge = apiResponses.getStatusBadge(status);
const result = appveyorUtils.badgeToStatus(badge);
assert.strictEqual(result, status);
throws for unrecognized status
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const badge = apiResponses.getStatusBadge('whatever');
assert.throws(
  () => { appveyorUtils.badgeToStatus(badge); },
  Error,
);
throws for ambiguous status
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const badge = apiResponses.getStatusBadge('success failed');
assert.throws(
  () => { appveyorUtils.badgeToStatus(badge); },
  Error,
);
throws for non-string
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
assert.throws(
  () => { appveyorUtils.badgeToStatus(null); },
  Error,
);

.projectBuildToStatus

returns any status of ProjectBuild
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testStatus = 'foo';
const projectBuild = apiResponses.getProjectBuild({ status: testStatus });
const result = appveyorUtils.projectBuildToStatus(projectBuild);
assert.strictEqual(result, testStatus);

.parseAppveyorRepoUrl

parses bitBucket HTTPS URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testProject = 'foo/bar';
const testUrl = `https://bitbucket.org/${testProject}.git`;
assert.deepStrictEqual(
  appveyorUtils.parseAppveyorRepoUrl(testUrl),
  {
    repositoryType: 'bitBucket',
    repositoryName: testProject,
  },
);
parses bitBucket SSH URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testProject = 'foo/bar';
const testUrl = `git@bitbucket.org:${testProject}.git`;
assert.deepStrictEqual(
  appveyorUtils.parseAppveyorRepoUrl(testUrl),
  {
    repositoryType: 'bitBucket',
    repositoryName: testProject,
  },
);
parses gitHub HTTPS URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testProject = 'foo/bar';
const testUrl = `https://github.com/${testProject}.git`;
assert.deepStrictEqual(
  appveyorUtils.parseAppveyorRepoUrl(testUrl),
  {
    repositoryType: 'gitHub',
    repositoryName: testProject,
  },
);
parses gitHub SSH URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testProject = 'foo/bar';
const testUrl = `git@github.com:${testProject}.git`;
assert.deepStrictEqual(
  appveyorUtils.parseAppveyorRepoUrl(testUrl),
  {
    repositoryType: 'gitHub',
    repositoryName: testProject,
  },
);
parses gitLab HTTPS URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testProject = 'foo/bar';
const testUrl = `https://gitlab.com/${testProject}.git`;
assert.deepStrictEqual(
  appveyorUtils.parseAppveyorRepoUrl(testUrl),
  {
    repositoryType: 'gitLab',
    repositoryName: testProject,
  },
);
parses gitLab SSH URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testProject = 'foo/bar';
const testUrl = `git@gitlab.com:${testProject}.git`;
assert.deepStrictEqual(
  appveyorUtils.parseAppveyorRepoUrl(testUrl),
  {
    repositoryType: 'gitLab',
    repositoryName: testProject,
  },
);
parses vso project git HTTPS URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testUrl = 'https://kevinoid.visualstudio.com/_git/TestProj';
assert.deepStrictEqual(
  appveyorUtils.parseAppveyorRepoUrl(testUrl),
  {
    repositoryType: 'vso',
    repositoryName: 'git/kevinoid/TestProj/TestProj',
  },
);
parses vso project git SSH URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testUrl =
  'ssh://kevinoid@kevinoid.visualstudio.com:22/_git/TestProj';
assert.deepStrictEqual(
  appveyorUtils.parseAppveyorRepoUrl(testUrl),
  {
    repositoryType: 'vso',
    repositoryName: 'git/kevinoid/TestProj/TestProj',
  },
);
parses vso sub-project git HTTPS URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testUrl = 'https://kevinoid.visualstudio.com/TestProj/_git/repo2';
assert.deepStrictEqual(
  appveyorUtils.parseAppveyorRepoUrl(testUrl),
  {
    repositoryType: 'vso',
    repositoryName: 'git/kevinoid/TestProj/repo2',
  },
);
parses vso sub-project git SSH URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testUrl =
  'ssh://kevinoid@kevinoid.visualstudio.com:22/TestProj/_git/repo2';
assert.deepStrictEqual(
  appveyorUtils.parseAppveyorRepoUrl(testUrl),
  {
    repositoryType: 'vso',
    repositoryName: 'git/kevinoid/TestProj/repo2',
  },
);
returns unknown HTTPS URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testUrl = 'https://example.com/foo.git';
assert.deepStrictEqual(
  appveyorUtils.parseAppveyorRepoUrl(testUrl),
  { repositoryName: testUrl },
);
returns unknown SCP-like URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testUrl = 'user@example.com:foo.git';
assert.deepStrictEqual(
  appveyorUtils.parseAppveyorRepoUrl(testUrl),
  { repositoryName: testUrl },
);

.repoUrlToBadgeParams

parses bitBucket HTTPS URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testAccount = 'foo';
const testProject = 'bar';
const testUrl =
  `https://bitbucket.org/${testAccount}/${testProject}.git`;
assert.deepStrictEqual(
  appveyorUtils.repoUrlToBadgeParams(testUrl),
  {
    badgeRepoProvider: 'bitBucket',
    repoAccountName: testAccount,
    repoSlug: testProject,
  },
);
parses bitBucket SSH URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testAccount = 'foo';
const testProject = 'bar';
const testUrl =
  `git@bitbucket.org:${testAccount}/${testProject}.git`;
assert.deepStrictEqual(
  appveyorUtils.repoUrlToBadgeParams(testUrl),
  {
    badgeRepoProvider: 'bitBucket',
    repoAccountName: testAccount,
    repoSlug: testProject,
  },
);
throws for bitBucket URL with 3 path parts
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testUrl = 'https://bitbucket.org/foo/bar/baz.git';
assert.throws(
  () => { appveyorUtils.repoUrlToBadgeParams(testUrl); },
  Error,
);
parses gitHub HTTPS URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testAccount = 'foo';
const testProject = 'bar';
const testUrl =
  `https://github.com/${testAccount}/${testProject}.git`;
assert.deepStrictEqual(
  appveyorUtils.repoUrlToBadgeParams(testUrl),
  {
    badgeRepoProvider: 'gitHub',
    repoAccountName: testAccount,
    repoSlug: testProject,
  },
);
parses gitHub SSH URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testAccount = 'foo';
const testProject = 'bar';
const testUrl =
  `git@github.com:${testAccount}/${testProject}.git`;
assert.deepStrictEqual(
  appveyorUtils.repoUrlToBadgeParams(testUrl),
  {
    badgeRepoProvider: 'gitHub',
    repoAccountName: testAccount,
    repoSlug: testProject,
  },
);
throws for gitLab HTTPS URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testUrl = 'https://gitlab.com/foo/bar.git';
assert.throws(
  () => { appveyorUtils.repoUrlToBadgeParams(testUrl); },
  Error,
);
throws for gitLab HTTPS URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testUrl = 'git@gitlab.com:foo/bar.git';
assert.throws(
  () => { appveyorUtils.repoUrlToBadgeParams(testUrl); },
  Error,
);
throws for vso HTTPS URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testUrl = 'https://kevinoid.visualstudio.com/_git/TestProj';
assert.throws(
  () => { appveyorUtils.repoUrlToBadgeParams(testUrl); },
  Error,
);
throws for vso SSH URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testUrl =
  'ssh://kevinoid@kevinoid.visualstudio.com:22/_git/TestProj';
assert.throws(
  () => { appveyorUtils.repoUrlToBadgeParams(testUrl); },
  Error,
);
throws for other git HTTPS URLs
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testUrl = 'https://example.com/foo.git';
assert.throws(
  () => { appveyorUtils.repoUrlToBadgeParams(testUrl); },
  Error,
);
returns unknown git SSH URL
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testUrl = 'user@example.com:foo.git';
assert.throws(
  () => { appveyorUtils.repoUrlToBadgeParams(testUrl); },
  Error,
);

.projectFromString

splits account name and slug to object
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const accountName = 'foo';
const slug = 'bar';
assert.deepStrictEqual(
  appveyorUtils.projectFromString(`${accountName}/${slug}`),
  {
    accountName,
    slug,
  },
);
throws for string with 1 path part
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
assert.throws(
  () => { appveyorUtils.projectFromString('foo'); },
  Error,
);
throws for string with 3 path part
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
assert.throws(
  () => { appveyorUtils.projectFromString('foo/bar/baz'); },
  Error,
);
throws for non-string
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
assert.throws(
  () => { appveyorUtils.projectFromString(null); },
  Error,
);

.projectToString

joins account name and slug
/home/kevin/src/node-projects/appveyor-status/test/lib/appveyor-utils.js
const testProj = {
  accountName: 'foo',
  slug: 'bar',
};
assert.deepStrictEqual(
  appveyorUtils.projectToString(testProj),
  'foo/bar',
);

CommitMismatchError

sets .actual and .expected from arguments
/home/kevin/src/node-projects/appveyor-status/test/lib/commit-mismatch-error.js
const testOptions = {
  actual: 'abc',
  expected: '123',
};
const err = new CommitMismatchError(testOptions);
assert.strictEqual(err.actual, testOptions.actual);
assert.strictEqual(err.expected, testOptions.expected);
assert.strictEqual(err.operator, '===');
assert(
  err.message.includes(testOptions.actual),
  'constructs message with actual',
);
assert(
  err.message.includes(testOptions.expected),
  'constructs message with expected',
);
can set .message from arguments
/home/kevin/src/node-projects/appveyor-status/test/lib/commit-mismatch-error.js
const testOptions = {
  actual: 'abc',
  expected: '123',
  message: 'test',
};
const err = new CommitMismatchError(testOptions);
assert.strictEqual(err.actual, testOptions.actual);
assert.strictEqual(err.expected, testOptions.expected);
assert.strictEqual(err.operator, '===');
assert.strictEqual(err.message, testOptions.message);
can be instantiated without new
/home/kevin/src/node-projects/appveyor-status/test/lib/commit-mismatch-error.js
const testOptions = {
  actual: 'abc',
  expected: '123',
};
// eslint-disable-next-line new-cap
const err = CommitMismatchError(testOptions);
assert.strictEqual(err.actual, testOptions.actual);
assert.strictEqual(err.expected, testOptions.expected);
assert.strictEqual(err.operator, '===');
assert(
  err.message.includes(testOptions.actual),
  'constructs message with actual',
);
assert(
  err.message.includes(testOptions.expected),
  'constructs message with expected',
);
inherits from Error
/home/kevin/src/node-projects/appveyor-status/test/lib/commit-mismatch-error.js
const testOptions = {
  actual: 'abc',
  expected: '123',
};
const err = new CommitMismatchError(testOptions);
assert(err instanceof Error);

execFileOut

returns a Promise with stdout
/home/kevin/src/node-projects/appveyor-status/test/lib/exec-file-out.js
const testOut = 'stdout content';
const testArgs = ['-e', makeScript(testOut)];
return execFileOut(process.execPath, testArgs)
  .then((stdout) => {
    assert.strictEqual(stdout, testOut);
  });
returns a Promise with stdout as Buffer
/home/kevin/src/node-projects/appveyor-status/test/lib/exec-file-out.js
const testOut = 'stdout content';
const testArgs = ['-e', makeScript(testOut)];
const options = { encoding: 'buffer' };
return execFileOut(process.execPath, testArgs, options)
  .then((stdout) => {
    assert.deepStrictEqual(stdout, Buffer.from(testOut));
  });
rejects Promise with Error for non-0 exit code
/home/kevin/src/node-projects/appveyor-status/test/lib/exec-file-out.js
const testOut = 'stdout content';
const testCode = 2;
const testArgs = ['-e', makeScript(testOut, null, testCode)];
return execFileOut(process.execPath, testArgs).then(
  neverCalled,
  (err) => {
    assert.strictEqual(
      err.cmd,
      [process.execPath].concat(testArgs).join(' '),
    );
    assert.strictEqual(err.code, testCode);
    assert.strictEqual(err.stderr, '');
    assert.strictEqual(err.stdout, testOut);
  },
);
rejects Promise with Error for non-empty stderr
/home/kevin/src/node-projects/appveyor-status/test/lib/exec-file-out.js
const testOut = 'stdout content';
const testErr = 'stderr content';
const testArgs = ['-e', makeScript(testOut, testErr)];
return execFileOut(process.execPath, testArgs).then(
  neverCalled,
  (err) => {
    assert(err.message.includes(testErr), 'stderr is in message');
    assert.strictEqual(
      err.cmd,
      [process.execPath].concat(testArgs).join(' '),
    );
    assert.strictEqual(err.code, 0);
    assert.strictEqual(err.stderr, testErr);
    assert.strictEqual(err.stdout, testOut);
  },
);
rejects Promise with Error for non-empty stderr Buffer
/home/kevin/src/node-projects/appveyor-status/test/lib/exec-file-out.js
const testOut = 'stdout content';
const testErr = 'stderr content';
const testArgs = ['-e', makeScript(testOut, testErr)];
const options = { encoding: 'buffer' };
return execFileOut(process.execPath, testArgs, options).then(
  neverCalled,
  (err) => {
    assert(err.message.includes(testErr), 'stderr is in message');
    assert.strictEqual(
      err.cmd,
      [process.execPath].concat(testArgs).join(' '),
    );
    assert.strictEqual(err.code, 0);
    assert.deepStrictEqual(err.stderr, Buffer.from(testErr));
    assert.deepStrictEqual(err.stdout, Buffer.from(testOut));
  },
);
does not reject stderr with only whitespace
/home/kevin/src/node-projects/appveyor-status/test/lib/exec-file-out.js
const testOut = 'stdout content';
const testErr = '\n\t\t  \n';
const testArgs = ['-e', makeScript(testOut, testErr)];
return execFileOut(process.execPath, testArgs)
  .then((stdout) => {
    assert.strictEqual(stdout, testOut);
  });
closes stdin to prevent hanging
/home/kevin/src/node-projects/appveyor-status/test/lib/exec-file-out.js
execFileOut(process.execPath)

gitUtils

.getBranch

resolves master on master
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.getBranch(options)
      .then((branch) => {
        assert.strictEqual(branch, 'master');
      })
resolves branch1 on branch1
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
execFileOut('git', ['checkout', '-q', 'branch1'], options)
        .then(() => gitUtils.getBranch(options))
        .then((branch) => {
          assert.strictEqual(branch, 'branch1');
        })
rejects with Error not on branch
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
execFileOut('git', ['checkout', '-q', 'HEAD^'], options)
        .then(() => gitUtils.getBranch(options))
        .then(
          neverCalled,
          (err) => {
            assert.instanceOf(err, Error);
            assert.match(err.message, /branch/i);
          },
        )

.getRemote

resolves master to origin
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.getRemote(branch, options).then((result) => {
          assert.strictEqual(result, remote);
        })
resolves branch1 to remote1
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.getRemote(branch, options).then((result) => {
          assert.strictEqual(result, remote);
        })
resolves branch2 to remote2
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.getRemote(branch, options).then((result) => {
          assert.strictEqual(result, remote);
        })
resolves branchnourl to nourl
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.getRemote(branch, options).then((result) => {
          assert.strictEqual(result, remote);
        })
resolves branchnotslug to notslug
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.getRemote(branch, options).then((result) => {
          assert.strictEqual(result, remote);
        })
rejects branch without remote with Error
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.getRemote('branchnoremote', options).then(
        neverCalled,
        (err) => {
          assert.instanceOf(err, Error);
        },
      )

.getRemoteUrl

resolves notslug to foo
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.getRemoteUrl(remoteName, options)
          .then((resultUrl) => {
            assert.strictEqual(resultUrl, remoteUrl);
          })
resolves origin to https://github.com/owner/repo
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.getRemoteUrl(remoteName, options)
          .then((resultUrl) => {
            assert.strictEqual(resultUrl, remoteUrl);
          })
resolves remote1 to git@github.com:owner1/repo1.git
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.getRemoteUrl(remoteName, options)
          .then((resultUrl) => {
            assert.strictEqual(resultUrl, remoteUrl);
          })
resolves remote2 to https://github.com/owner2/repo2.git
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.getRemoteUrl(remoteName, options)
          .then((resultUrl) => {
            assert.strictEqual(resultUrl, remoteUrl);
          })
rejects invalid remote with Error
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.getRemoteUrl('invalidremote', options).then(
        neverCalled,
        (err) => {
          assert.instanceOf(err, Error);
        },
      )
uses ls-remote default for unspecified remote
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.getRemoteUrl(null, options)
        .then((resultUrl) => {
          assert.strictEqual(resultUrl, REMOTES.origin);
        })

.gitUrlIsLocalNotSsh

. is true
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
assert.strictEqual(
  gitUtils.gitUrlIsLocalNotSsh(testCase.url),
  testCase.result,
);
/foo/bar is true
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
assert.strictEqual(
  gitUtils.gitUrlIsLocalNotSsh(testCase.url),
  testCase.result,
);
http://example.com is false
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
assert.strictEqual(
  gitUtils.gitUrlIsLocalNotSsh(testCase.url),
  testCase.result,
);
git://example.com is false
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
assert.strictEqual(
  gitUtils.gitUrlIsLocalNotSsh(testCase.url),
  testCase.result,
);
git@example.com:foo is false
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
assert.strictEqual(
  gitUtils.gitUrlIsLocalNotSsh(testCase.url),
  testCase.result,
);
file:///foo/bar is false
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
assert.strictEqual(
  gitUtils.gitUrlIsLocalNotSsh(testCase.url),
  testCase.result,
);
/foo:bar is true
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
assert.strictEqual(
  gitUtils.gitUrlIsLocalNotSsh(testCase.url),
  testCase.result,
);
foo:bar is false
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
assert.strictEqual(
  gitUtils.gitUrlIsLocalNotSsh(testCase.url),
  testCase.result,
);
C:/foo is false on non-Windows
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
assert.strictEqual(
  gitUtils.gitUrlIsLocalNotSsh(drivePath),
  false,
);

.parseGitUrl

parses http: like url module
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
const testUrl = 'http://user@example.com/foo/bar';
assert.deepStrictEqual(
  gitUtils.parseGitUrl(testUrl),
  Object.assign(new URL(testUrl), { helper: undefined }),
);
parses git: like url module
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
const testUrl = 'git://user@example.com/foo/bar';
assert.deepStrictEqual(
  gitUtils.parseGitUrl(testUrl),
  Object.assign(new URL(testUrl), { helper: undefined }),
);
parses SCP-like URL like ssh: URL
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
const testUrl = 'user@example.com:foo/bar.git';
assert.deepStrictEqual(
  gitUtils.parseGitUrl(testUrl),
  Object.assign(
    new URL('ssh://user@example.com/foo/bar.git'),
    { helper: undefined },
  ),
);
parses absolute path like file:// URL
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
const testPath = path.resolve(path.join('foo', 'bar'));
assert.deepStrictEqual(
  gitUtils.parseGitUrl(testPath),
  Object.assign(pathToFileURL(testPath), { helper: undefined }),
);
parses relative path like file:// URL
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
const testPath = path.join('foo', 'bar');
assert.deepStrictEqual(
  gitUtils.parseGitUrl(testPath),
  Object.assign(pathToFileURL(testPath), { helper: undefined }),
);
parses Windows path like URL on non-Windows
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
const testPath = 'C:\\foo\\bar';
assert.deepStrictEqual(
  gitUtils.parseGitUrl(testPath),
  Object.assign(new URL(testPath), { helper: undefined }),
);
adds helper property for transport helper
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
const testUrl = 'myhelper::user@example.com:foo/bar.git';
assert.deepStrictEqual(
  gitUtils.parseGitUrl(testUrl),
  Object.assign(
    new URL('ssh://user@example.com/foo/bar.git'),
    { helper: 'myhelper' },
  ),
);

.resolveCommit

can resolve the hash of HEAD
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.resolveCommit('HEAD', options).then((hash) => {
        assert.match(hash, /^[a-fA-F0-9]{40}$/);
        headHash = hash;
      })
can resolve a hash to itself
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.resolveCommit(headHash, options).then((hash) => {
        assert.strictEqual(hash, headHash);
      })
can resolve branch name to commit hash
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
const branchName = Object.keys(BRANCH_REMOTES)[0];
return gitUtils.resolveCommit(branchName, options).then((hash) => {
  assert.match(hash, /^[a-fA-F0-9]{40}$/);
});
can resolve tag name to commit hash
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.resolveCommit(TAGS[0], options).then((hash) => {
        assert.match(hash, /^[a-fA-F0-9]{40}$/);
      })
rejects with Error for unresolvable name
/home/kevin/src/node-projects/appveyor-status/test/lib/git-utils.js
gitUtils.resolveCommit('notabranch', options).then(
        neverCalled,
        (err) => {
          assert(err instanceof Error);
        },
      )