Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion client/directives/components/buildLogs/buildLogsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ function BuildLogsController(
$rootScope,
$timeout,
errs,
keypather,
launchDebugContainer,
loading,
updateInstanceWithNewBuild,
primus,
promisify,
fetchRepoDockerfile,
streamingLog
) {
var BLC = this;
Expand All @@ -27,10 +29,20 @@ function BuildLogsController(
BLC.failReason = buildError.message || 'failed';
BLC.showDebug = true;
BLC.buildLogsRunning = false;
BLC.showNoDockerfileError = (BLC.instance.hasDockerfileMirroring() && BLC.instance.mirroredDockerfile === null);
if (status === 'neverStarted') {
BLC.showErrorPanel = true;
}
var repoAndBranchName = BLC.instance.getRepoAndBranchName().split('/');
var repoName = repoAndBranchName[0];
var branchName = repoAndBranchName[1];
var dockerfilePath = keypather.get(BLC, 'instance.mirroredDockerfile.attrs.path');
var dockerfileName = keypather.get(BLC, 'instance.mirroredDockerfile.attrs.name');
if (dockerfilePath && dockerfileName) {
fetchRepoDockerfile(repoName, branchName, dockerfilePath + dockerfileName)
.then(function (dockerfile) {
BLC.showNoDockerfileError = (BLC.instance.hasDockerfileMirroring() && dockerfile.message === 'Not Found');
});
}
} else if (status === 'building') {
BLC.buildStatus = 'running';
BLC.buildLogsRunning = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ describe('BuildLogsController'.bold.underline.blue, function () {
var BLC;
var mockCreateDebugContainer;
var mockDebugContainer;
var mockDockerfile;
var mockErrs;
var isRunnabotPartOfOrgStub;
var fetchRepoDockerfileStub;

function setup(useInstance, dontIncludeBuildDockerContainer) {
mockInstance = {
Expand All @@ -36,6 +38,13 @@ describe('BuildLogsController'.bold.underline.blue, function () {
dockerContainer: dontIncludeBuildDockerContainer ? undefined : 'asdsdfsd'
}
}
},
getRepoAndBranchName: sinon.stub().returns('test/master'),
mirroredDockerfile: {
attrs: {
path: '/',
name: 'Dockerfile'
}
}
};
mockDebugContainer = {
Expand All @@ -51,7 +60,7 @@ describe('BuildLogsController'.bold.underline.blue, function () {
logs: []
};
mockStreamingLog = sinon.stub().returns(mockStreamingLogContents);

mockDockerfile = {message: 'Not Found'};
mockPrimus = {
createBuildStream: sinon.spy(function () {
mockStream = new EventEmitter();
Expand All @@ -77,7 +86,10 @@ describe('BuildLogsController'.bold.underline.blue, function () {
mockCreateDebugContainer = sinon.stub().returns($q.when(mockDebugContainer));
return mockCreateDebugContainer;
});

$provide.factory('fetchRepoDockerfile', function ($q) {
fetchRepoDockerfileStub = sinon.stub().returns($q.when(mockDockerfile));
return fetchRepoDockerfileStub;
});
$provide.factory('isRunnabotPartOfOrg', function ($q) {
isRunnabotPartOfOrgStub = sinon.stub().returns($q.when());
return isRunnabotPartOfOrgStub;
Expand Down Expand Up @@ -188,6 +200,12 @@ describe('BuildLogsController'.bold.underline.blue, function () {
mockInstance.on.lastCall.args[1]();
expect(BLC.showDebug).to.be.ok;
});
it('should display a dockerfile error if absent', function () {
mockInstance.status.returns('buildFailed');
mockInstance.on.lastCall.args[1]();
$scope.$digest();
expect(BLC.showNoDockerfileError).to.equal(true);
})
});
describe('actions', function () {
describe('launchDebugContainer', function () {
Expand Down