当前位置: 首页>>代码示例>>Golang>>正文


Golang Gaudi.GetApplication方法代码示例

本文整理汇总了Golang中github.com/marmelab/gaudi/gaudi.Gaudi.GetApplication方法的典型用法代码示例。如果您正苦于以下问题:Golang Gaudi.GetApplication方法的具体用法?Golang Gaudi.GetApplication怎么用?Golang Gaudi.GetApplication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/marmelab/gaudi/gaudi.Gaudi的用法示例。


在下文中一共展示了Gaudi.GetApplication方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestStartApplicationShouldCleanAndBuildThem

func (s *GaudiTestSuite) TestStartApplicationShouldCleanAndBuildThem(c *C) {
	os.RemoveAll("/var/tmp/gaudi/templates/")

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

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

	util.MOCK().DisableMock("IsFile")
	util.MOCK().DisableMock("IsDir")

	// Retrieving templates (1)
	util.EXPECT().PrintGreen(gomock.Any()).Times(1)
	// Killing, Clearing, Building, Starting (3*2)
	util.EXPECT().PrintGreen(gomock.Any(), gomock.Any(), gomock.Any()).Times(6)
	// Started (1*2)
	util.EXPECT().PrintGreen(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(2)

	// Setup the docker mock package
	docker.MOCK().SetController(ctrl)
	docker.EXPECT().ImageExists(gomock.Any()).Return(true).Times(1)
	docker.EXPECT().HasDocker().Return(true).Times(1)
	docker.EXPECT().Kill(gomock.Any()).Return().Times(2)
	docker.EXPECT().Remove(gomock.Any()).Return().Times(2)
	docker.EXPECT().Build(gomock.Any(), gomock.Any()).Return().Times(2)
	docker.EXPECT().Start(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return("123").Times(2)
	docker.EXPECT().Inspect(gomock.Any()).Return([]byte("[{\"ID\": \"123\", \"State\":{\"Running\": false}, \"NetworkSettings\": {\"IPAddress\": \"172.17.0.10\"}}]"), nil).Times(2)

	g := gaudi.Gaudi{}
	g.Init(`
applications:
    app:
        type: php-fpm
        links: [db]
    db:
        type: mysql
        ports:
            3306: 9000
`)

	c.Assert(len(g.Applications), Equals, 2)

	g.StartApplications(true)
	c.Assert(g.GetApplication("db").IsRunning(), Equals, true)
	c.Assert(g.GetApplication("app").IsRunning(), Equals, true)
}
开发者ID:nidhisarvaiya,项目名称:gaudi,代码行数:48,代码来源:gaudi_unit_test.go

示例2: TestStartApacheShouldStartedItCorrectly

// Apache
func (s *GaudiTestSuite) TestStartApacheShouldStartedItCorrectly(c *C) {
	g := gaudi.Gaudi{}
	g.Init(`
applications:
    front:
        type: apache
        ports:
            80: 80
`)

	c.Assert(len(g.Applications), Equals, 1)
	g.StartApplications(true)

	// Test apache is running
	resp, err := http.Get("http://" + g.GetApplication("front").Ip)
	defer resp.Body.Close()

	c.Check(err, Equals, nil)
	c.Check(resp.StatusCode, Equals, 200)
}
开发者ID:hungld,项目名称:gaudi,代码行数:21,代码来源:gaudi_functional_test.go

示例3: TestStartPhpAndApacheShouldStartedThemCorrectly

// Apache + php-fpm
func (s *GaudiTestSuite) TestStartPhpAndApacheShouldStartedThemCorrectly(c *C) {
	err := os.MkdirAll("/tmp/php", 0775)
	ioutil.WriteFile("/tmp/php/ok.php", []byte("<?php echo 'ok';"), 0775)

	g := gaudi.Gaudi{}
	g.Init(`
applications:
    front:
        type: apache
        links: [app]
        ports:
            80: 80
        volumes:
            /tmp/php: /var/www
        custom:
            fastCgi: app

    app:
        type: php-fpm
        ports:
            9000: 9000
        volumes:
            /tmp/php: /var/www
`)

	c.Assert(len(g.Applications), Equals, 2)
	g.StartApplications(true)
	time.Sleep(2 * time.Second)

	// Test apache is running
	resp, err := http.Get("http://" + g.GetApplication("front").Ip + "/ok.php")
	defer resp.Body.Close()

	content, _ := ioutil.ReadAll(resp.Body)

	c.Check(err, Equals, nil)
	c.Check(resp.StatusCode, Equals, 200)
	c.Check(string(content), Equals, "ok")
}
开发者ID:hungld,项目名称:gaudi,代码行数:40,代码来源:gaudi_functional_test.go

示例4: TestInitShouldCreateApplications

func (s *GaudiTestSuite) TestInitShouldCreateApplications(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)

	// Disable the util package mock
	util.MOCK().DisableMock("IsDir")
	util.MOCK().DisableMock("IsFile")

	util.EXPECT().PrintGreen("Retrieving templates ...")

	docker.EXPECT().ImageExists(gomock.Any()).Return(true).Times(1)
	docker.EXPECT().HasDocker().Return(true).Times(1)
	docker.EXPECT().Inspect(gomock.Any()).Return([]byte("[{\"ID\": \"123\", \"State\":{\"Running\": false}, \"NetworkSettings\": {\"IPAddress\": \"\"}}]"), nil)

	g := gaudi.Gaudi{}
	g.Init(`
applications:
    app:
        type: php-fpm
        links: [db]
    db:
        type: mysql
        ports:
            3306: 9000
`)

	c.Assert(len(g.Applications), Equals, 2)
	c.Assert(g.GetApplication("app").Name, Equals, "app")
	c.Assert(g.GetApplication("app").Type, Equals, "php-fpm")
	c.Assert(g.GetApplication("app").Dependencies[0].Name, Equals, "db")
	c.Assert(g.GetApplication("db").GetFirstPort(), Equals, "3306")
	c.Assert(g.GetApplication("db").IsRunning(), Equals, false)
}
开发者ID:nidhisarvaiya,项目名称:gaudi,代码行数:40,代码来源:gaudi_unit_test.go


注:本文中的github.com/marmelab/gaudi/gaudi.Gaudi.GetApplication方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。