91 lines
2.7 KiB
TypeScript
91 lines
2.7 KiB
TypeScript
|
import { DockerfileServiceImpl, DockerfileInfoImpl } from './dockerfile.service.impl';
|
||
|
import Spy = jasmine.Spy;
|
||
|
|
||
|
|
||
|
describe("DockerfileInfoImpl", () => {
|
||
|
var dockerfileInfoImpl: DockerfileInfoImpl;
|
||
|
var contents: string;
|
||
|
var configMock: any;
|
||
|
|
||
|
beforeEach(() => {
|
||
|
contents = "";
|
||
|
configMock = jasmine.createSpyObj('configMock', ['getDomain']);
|
||
|
dockerfileInfoImpl = new DockerfileInfoImpl(contents, configMock);
|
||
|
});
|
||
|
|
||
|
describe("forData", () => {
|
||
|
|
||
|
it("returns null if given contents do not contain a 'FROM' command", () => {
|
||
|
expect(DockerfileInfoImpl.forData(contents, configMock)).toBe(null);
|
||
|
});
|
||
|
|
||
|
it("returns a new DockerfileInfoImpl instance if given contents are valid", () => {
|
||
|
contents = "FROM quay.io/coreos/nginx";
|
||
|
|
||
|
expect(DockerfileInfoImpl.forData(contents, configMock) instanceof DockerfileInfoImpl).toBe(true);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
describe("getRegistryBaseImage", () => {
|
||
|
|
||
|
|
||
|
});
|
||
|
|
||
|
describe("getBaseImage", () => {
|
||
|
var baseImageAndTag
|
||
|
|
||
|
it("returns null if instance's contents do not contain a 'FROM' command", () => {
|
||
|
var getBaseImageAndTagSpy: Spy = spyOn(dockerfileInfoImpl, "getBaseImageAndTag").and.returnValue()
|
||
|
});
|
||
|
|
||
|
it("returns")
|
||
|
});
|
||
|
|
||
|
describe("getBaseImageAndTag", () => {
|
||
|
|
||
|
it("returns null if instance's contents do not contain a 'FROM' command", () => {
|
||
|
expect(dockerfileInfoImpl.getBaseImageAndTag()).toBe(null);
|
||
|
});
|
||
|
|
||
|
it("returns a string containing the base image and tag from the instance's contents", () => {
|
||
|
contents = "FROM quay.io/coreos/nginx";
|
||
|
dockerfileInfoImpl = new DockerfileInfoImpl(contents, configMock);
|
||
|
var baseImageAndTag: string = dockerfileInfoImpl.getBaseImageAndTag();
|
||
|
|
||
|
expect(baseImageAndTag).toEqual(contents.substring('FROM '.length, contents.length).trim());
|
||
|
});
|
||
|
|
||
|
it("handles the presence of newlines", () => {
|
||
|
contents = "FROM quay.io/coreos/nginx\nRUN echo $0";
|
||
|
dockerfileInfoImpl = new DockerfileInfoImpl(contents, configMock);
|
||
|
var baseImageAndTag: string = dockerfileInfoImpl.getBaseImageAndTag();
|
||
|
|
||
|
expect(baseImageAndTag).toEqual(contents.substring('FROM '.length, contents.indexOf('\n')).trim());
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
|
||
|
|
||
|
describe("DockerfileServiceImpl", () => {
|
||
|
var dockerfileServiceImpl: DockerfileServiceImpl;
|
||
|
var dataFileServiceMock: any;
|
||
|
var configMock: any;
|
||
|
|
||
|
beforeEach(() => {
|
||
|
dataFileServiceMock = jasmine.createSpyObj('dataFileServiceMock', [
|
||
|
'readDataArrayAsPossibleArchive',
|
||
|
'arrayToString',
|
||
|
'blobToString',
|
||
|
]);
|
||
|
configMock = jasmine.createSpyObj('configMock', ['getDomain']);
|
||
|
dockerfileServiceImpl = new DockerfileServiceImpl(dataFileServiceMock, configMock);
|
||
|
});
|
||
|
|
||
|
describe("getDockerfile", () => {
|
||
|
|
||
|
});
|
||
|
|
||
|
describe("extractDockerfile", () => {
|
||
|
|
||
|
});
|
||
|
});
|