示例#1
0
func (s *GaudiTestSuite) TestUseCustomTemplateShouldUseIt(c *C) {
	os.RemoveAll("/var/tmp/gaudi/")

	// Create a gomock controller, and arrange for it's finish to be called
	ctrl := gomock.NewController(c)
	defer ctrl.Finish()
	docker.MOCK().SetController(ctrl)

	// Setup the util mock package
	util.MOCK().SetController(ctrl)

	util.MOCK().EnableMock("IsDir")
	util.MOCK().EnableMock("IsFile")
	util.MOCK().EnableMock("LogError")

	g := gaudi.Gaudi{}
	g.ApplicationDir = "/vagrant"

	docker.EXPECT().HasDocker().Return(true).Times(1)
	docker.EXPECT().ImageExists(gomock.Any()).Return(true).Times(1)

	util.EXPECT().IsDir("/var/tmp/gaudi/templates/").Return(false)
	util.EXPECT().IsFile("/vagrant/.gaudi/version.txt").Return(false)
	util.EXPECT().PrintGreen("Retrieving templates ...")

	util.EXPECT().IsFile("/vagrant/front/Dockerfile").Return(true).Times(3)
	util.EXPECT().LogError("Application 'custom' is not supported. Check http://gaudi.io/components.html for a list of supported applications.").Times(3)

	g.Init(`
applications:
    app:
        type: custom
        template: ./front/Dockerfile

    app2:
        type: custom
        template: front/Dockerfile

    app3:
        type: custom
        template: /vagrant/front/Dockerfile
`)
}