• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang test.StubAws函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/convox/rack/test.StubAws函数的典型用法代码示例。如果您正苦于以下问题:Golang StubAws函数的具体用法?Golang StubAws怎么用?Golang StubAws使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: TestInstanceTerminate

func TestInstanceTerminate(t *testing.T) {
	// set current provider
	testProvider := &provider.TestProviderRunner{}
	provider.CurrentProvider = testProvider

	defer func() {
		//TODO: remove: as we arent updating all tests we need tos et current provider back to a
		//clean default one (I miss rspec before)
		provider.CurrentProvider = new(provider.TestProviderRunner)
	}()

	// setup expectations on current provider
	testProvider.On("SystemGet").Return(nil, nil)

	os.Setenv("RACK", "convox-test")

	aws := test.StubAws(
		test.DeleteInstanceCycle("i-4a5513f4"),
	)
	defer aws.Close()

	body := test.HTTPBody("DELETE", "http://convox/instances/i-4a5513f4", nil)

	var resp map[string]bool
	err := json.Unmarshal([]byte(body), &resp)

	if assert.Nil(t, err) {
		assert.Equal(t, true, resp["success"])
	}
}
开发者ID:cleblanc87,项目名称:rack,代码行数:30,代码来源:instances_test.go


示例2: TestAppCreate

// Test the primary path: creating an app on a `convox` rack
// Return to testing against a `convox-test` rack afterwards
func TestAppCreate(t *testing.T) {
	r := os.Getenv("RACK")
	os.Setenv("RACK", "convox")
	defer os.Setenv("RACK", r)

	aws := test.StubAws(
		test.DescribeStackNotFound("application"),
		test.CreateAppStackCycle("convox-application"),
		test.DescribeAppStackCycle("convox-application"),
	)
	defer aws.Close()

	val := url.Values{"name": []string{"application"}}
	body := test.HTTPBody("POST", "http://convox/apps", val)

	if assert.NotEqual(t, "", body) {
		var resp map[string]string
		err := json.Unmarshal([]byte(body), &resp)

		if assert.Nil(t, err) {
			assert.Equal(t, "application", resp["name"])
			assert.Equal(t, "running", resp["status"])
		}
	}
}
开发者ID:soulware,项目名称:rack,代码行数:27,代码来源:apps_test.go


示例3: TestFormationScaleMemory2048

// post memory=2048 should error
func TestFormationScaleMemory2048(t *testing.T) {
	// set current provider
	testProvider := &provider.TestProviderRunner{
		Capacity: structs.Capacity{
			InstanceMemory: 1024,
		},
	}
	provider.CurrentProvider = testProvider
	defer func() {
		//TODO: remove: as we arent updating all tests we need tos et current provider back to a
		//clean default one (I miss rspec before)
		provider.CurrentProvider = new(provider.TestProviderRunner)
	}()
	testProvider.On("CapacityGet").Return(testProvider.Capacity, nil)

	aws := test.StubAws(
		test.DescribeAppStackCycle("convox-test-application"),
		test.DescribeAppStackCycle("convox-test-application"),
		test.GetItemAppReleaseCycle("convox-test-application"),
		test.UpdateAppStackCycle("convox-test-application", "1", "512"),
	)
	defer aws.Close()

	provider.TestProvider.Capacity = structs.Capacity{
		InstanceMemory: 1024,
	}

	val := url.Values{"count": []string{""}, "memory": []string{"2048"}}
	body := test.HTTPBody("POST", "http://convox/apps/application/formation/main", val)

	assert.Equal(t, `{"error":"requested memory 2048 greater than instance size 1024"}`, body)
}
开发者ID:cleblanc87,项目名称:rack,代码行数:33,代码来源:formation_test.go


示例4: TestFormationScaleCount0

// post count=0 should set MainDesiredCount=0 in the stack update
func TestFormationScaleCount0(t *testing.T) {
	// set current provider
	testProvider := &provider.TestProviderRunner{
		Capacity: structs.Capacity{},
	}
	provider.CurrentProvider = testProvider
	defer func() {
		//TODO: remove: as we arent updating all tests we need tos et current provider back to a
		//clean default one (I miss rspec before)
		provider.CurrentProvider = new(provider.TestProviderRunner)
	}()
	// setup expectations on current provider
	testProvider.On("CapacityGet").Return(testProvider.Capacity, nil)

	aws := test.StubAws(
		test.DescribeAppStackCycle("convox-test-application"),
		test.DescribeAppStackCycle("convox-test-application"),
		test.GetItemAppReleaseCycle("convox-test-application"),
		test.UpdateAppStackCycle("convox-test-application", "0", "256"),
	)
	defer aws.Close()

	val := url.Values{"count": []string{"0"}, "memory": []string{""}}
	body := test.HTTPBody("POST", "http://convox/apps/application/formation/main", val)

	assert.Equal(t, `{"success":true}`, body)
}
开发者ID:cleblanc87,项目名称:rack,代码行数:28,代码来源:formation_test.go


示例5: TestBasicAuth

func TestBasicAuth(t *testing.T) {
	models.TestProvider.On("SystemGet").Return(nil, nil)

	assert := assert.New(t)
	aws := test.StubAws(test.DescribeConvoxStackCycle("convox-test"))
	defer aws.Close()
	defer os.Setenv("PASSWORD", os.Getenv("PASSWORD"))
	defer os.Setenv("RACK", os.Getenv("RACK"))

	os.Setenv("PASSWORD", "keymaster")
	os.Setenv("RACK", "convox-test")

	req, _ := http.NewRequest("GET", "http://convox/system", nil)
	w := httptest.NewRecorder()
	controllers.HandlerFunc(w, req)

	if !assert.Equal(401, w.Code) {
		return
	}

	w = httptest.NewRecorder()
	req.SetBasicAuth("", "keymaster")
	controllers.HandlerFunc(w, req)

	assert.Equal(200, w.Code)
}
开发者ID:gmelika,项目名称:rack,代码行数:26,代码来源:api_test.go


示例6: TestBasicAuth

func TestBasicAuth(t *testing.T) {
	// set current provider
	testProvider := &provider.TestProviderRunner{}
	provider.CurrentProvider = testProvider
	defer func() {
		//TODO: remove: as we arent updating all tests we need tos et current provider back to a
		//clean default one (I miss rspec before)
		provider.CurrentProvider = new(provider.TestProviderRunner)
	}()
	// setup expectations on current provider
	testProvider.On("SystemGet").Return(nil, nil)

	assert := assert.New(t)
	aws := test.StubAws(test.DescribeConvoxStackCycle("convox-test"))
	defer aws.Close()
	defer os.Setenv("PASSWORD", os.Getenv("PASSWORD"))
	defer os.Setenv("RACK", os.Getenv("RACK"))

	os.Setenv("PASSWORD", "keymaster")
	os.Setenv("RACK", "convox-test")

	req, _ := http.NewRequest("GET", "http://convox/system", nil)
	w := httptest.NewRecorder()
	controllers.HandlerFunc(w, req)

	if !assert.Equal(401, w.Code) {
		return
	}

	w = httptest.NewRecorder()
	req.SetBasicAuth("", "keymaster")
	controllers.HandlerFunc(w, req)

	assert.Equal(200, w.Code)
}
开发者ID:cleblanc87,项目名称:rack,代码行数:35,代码来源:api_test.go


示例7: TestProcessesListWithDetached

func TestProcessesListWithDetached(t *testing.T) {
	models.TestProvider = &provider.TestProvider{
		Instances: []structs.Instance{
			structs.Instance{},
			structs.Instance{},
			structs.Instance{},
		},
	}

	// setup expectations on current provider
	models.TestProvider.On("InstanceList").Return(models.TestProvider.Instances, nil)

	os.Setenv("RACK", "convox-test")
	os.Setenv("CLUSTER", "convox-test-cluster")

	aws := test.StubAws(
		test.DescribeAppStackCycle("convox-test-myapp-staging"),
		test.DescribeAppStackCycle("convox-test-myapp-staging"),
		test.DescribeAppStackResourcesCycle("convox-test-myapp-staging"),

		test.ListContainerInstancesCycle("convox-test-cluster"),
		test.DescribeContainerInstancesCycle("convox-test-cluster"),
		test.DescribeInstancesCycle(),

		test.ListTasksCycle("convox-test-cluster", "convox-test-myapp-staging-worker-SCELGCIYSKF"),
		test.DescribeTasksCycle("convox-test-cluster"),
		test.ListTasksOneoffCycle("convox-test-cluster"),
		test.DescribeTasksOneoffCycle("convox-test-cluster"),
		test.DescribeTaskDefinitionCycle("convox-test-cluster"),
		test.DescribeTaskDefinitionCycle("convox-test-cluster"),

		test.DescribeAppStackResourcesCycle("convox-test-myapp-staging"),
		test.DescribeServicesCycle("convox-test-cluster"),
	)
	defer aws.Close()

	docker := test.StubDocker(
		// query for every ECS task to get docker id, command, created
		test.ListECSContainersCycle(),
		test.ListECSOneoffContainersCycle(),

		// query every instance for one-off containers
		test.ListOneoffContainersEmptyCycle(),
		test.ListOneoffContainersEmptyCycle(),
		test.ListOneoffContainersEmptyCycle(),
	)
	defer docker.Close()

	body := test.HTTPBody("GET", "http://convox/apps/myapp-staging/processes", url.Values{})

	var resp client.Processes
	err := json.Unmarshal([]byte(body), &resp)

	if assert.Nil(t, err) {
		assert.Equal(t, 2, len(resp))
		assert.Equal(t, "echo 1", resp[0].Command)
		assert.Equal(t, "/bin/sh -c yes", resp[1].Command)
	}
}
开发者ID:gmelika,项目名称:rack,代码行数:59,代码来源:processes_test.go


示例8: TestProcessesList

func TestProcessesList(t *testing.T) {
	// set current provider
	models.TestProvider = &provider.TestProvider{
		Instances: []structs.Instance{
			structs.Instance{},
			structs.Instance{},
			structs.Instance{},
		},
	}

	// setup expectations on current provider
	models.TestProvider.On("InstanceList").Return(models.TestProvider.Instances, nil)

	aws := test.StubAws(
		test.DescribeAppStackCycle("convox-test-myapp-staging"),
		test.DescribeAppStackCycle("convox-test-myapp-staging"),
		test.DescribeAppStackResourcesCycle("convox-test-myapp-staging"),

		test.ListContainerInstancesCycle("convox-test-cluster"),
		test.DescribeContainerInstancesCycle("convox-test-cluster"),
		test.DescribeInstancesCycle(),

		test.ListTasksCycle("convox-test-cluster", "convox-test-myapp-staging-worker-SCELGCIYSKF"),
		test.DescribeTasksCycle("convox-test-cluster"),
		test.ListTasksOneoffEmptyCycle("convox-test-cluster"),
		test.DescribeTaskDefinitionCycle("convox-test-cluster"),

		test.DescribeAppStackResourcesCycle("convox-test-myapp-staging"),
		test.DescribeServicesCycle("convox-test-cluster"),
	)
	defer aws.Close()

	docker := test.StubDocker(
		// query for every ECS task to get docker id, command, created
		test.ListECSContainersCycle(),

		// query every instance for one-off containers
		test.ListOneoffContainersEmptyCycle(),
		test.ListOneoffContainersEmptyCycle(),
		test.ListOneoffContainersEmptyCycle(),

		// query for every container to get CPU and Memory stats
		test.StatsCycle(),
	)
	defer docker.Close()

	v := url.Values{}
	v.Add("stats", "true")
	body := test.HTTPBody("GET", "http://convox/apps/myapp-staging/processes", v)

	var resp client.Processes
	err := json.Unmarshal([]byte(body), &resp)

	if assert.Nil(t, err) {
		assert.Equal(t, 1, len(resp))
		assert.Equal(t, 0.0974, resp[0].Memory)
	}
}
开发者ID:gmelika,项目名称:rack,代码行数:58,代码来源:processes_test.go


示例9: TestAppShowWithAppNotFound

func TestAppShowWithAppNotFound(t *testing.T) {
	aws := test.StubAws(
		test.DescribeStackNotFound("convox-test-bar"),
		test.DescribeStackNotFound("bar"),
	)
	defer aws.Close()

	test.AssertStatus(t, 404, "GET", "http://convox/apps/bar", nil)
}
开发者ID:soulware,项目名称:rack,代码行数:9,代码来源:apps_test.go


示例10: TestNoPassword

func TestNoPassword(t *testing.T) {
	aws := test.StubAws(test.DescribeConvoxStackCycle("convox-test"))
	defer aws.Close()
	defer os.Setenv("RACK", os.Getenv("RACK"))

	os.Setenv("RACK", "convox-test")

	assert.HTTPSuccess(t, controllers.HandlerFunc, "GET", "http://convox/system", nil)
}
开发者ID:anthonyrisinger,项目名称:rack,代码行数:9,代码来源:api_test.go


示例11: TestAppCreateWithAlreadyExistsUnbound

func TestAppCreateWithAlreadyExistsUnbound(t *testing.T) {
	aws := test.StubAws(
		test.DescribeAppStackCycle("application"),
	)
	defer aws.Close()

	val := url.Values{"name": []string{"application"}}
	body := test.AssertStatus(t, 403, "POST", "http://convox/apps", val)
	assert.Equal(t, "{\"error\":\"there is already a legacy app named application (running). We recommend you delete this app and create it again.\"}", body)
}
开发者ID:soulware,项目名称:rack,代码行数:10,代码来源:apps_test.go


示例12: TestAppCreateWithRackName

func TestAppCreateWithRackName(t *testing.T) {
	aws := test.StubAws(
		test.DescribeAppStackCycle("foobar"),
	)
	defer aws.Close()

	val := url.Values{"name": []string{"convox-test"}}
	body := test.AssertStatus(t, 403, "POST", "http://convox/apps", val)
	assert.Equal(t, "{\"error\":\"application name cannot match rack name (convox-test). Please choose a different name for your app.\"}", body)
}
开发者ID:gmelika,项目名称:rack,代码行数:10,代码来源:apps_test.go


示例13: TestAppCreateWithAlreadyExists

func TestAppCreateWithAlreadyExists(t *testing.T) {
	aws := test.StubAws(
		test.CreateAppStackExistsCycle("application"),
		test.DescribeAppStackCycle("application"),
	)
	defer aws.Close()

	val := url.Values{"name": []string{"application"}}
	test.AssertStatus(t, 403, "POST", "http://convox/apps", val)
}
开发者ID:anthonyrisinger,项目名称:rack,代码行数:10,代码来源:apps_test.go


示例14: TestGetProcessesWithDeployments

func TestGetProcessesWithDeployments(t *testing.T) {
	os.Setenv("RACK", "convox-test")
	os.Setenv("CLUSTER", "convox-test-cluster")

	aws := test.StubAws(
		test.DescribeAppStackCycle("convox-test-myapp-staging"),
		test.DescribeAppStackCycle("convox-test-myapp-staging"),
		test.DescribeAppStackResourcesCycle("convox-test-myapp-staging"),

		test.ListContainerInstancesCycle("convox-test-cluster"),
		test.DescribeContainerInstancesCycle("convox-test-cluster"),
		test.DescribeInstancesCycle(),

		test.ListTasksCycle("convox-test-cluster", "convox-test-myapp-staging-worker-SCELGCIYSKF"),
		test.DescribeTasksCycle("convox-test-cluster"),
		test.ListTasksOneoffEmptyCycle("convox-test-cluster"),
		test.DescribeTaskDefinitionCycle("convox-test-cluster"),

		test.DescribeAppStackResourcesCycle("convox-test-myapp-staging"),
		test.DescribeServicesWithDeploymentsCycle("convox-test-cluster"),
		test.DescribeTaskDefinition3Cycle("convox-test-cluster"),
		test.DescribeTaskDefinition1Cycle("convox-test-cluster"),
	)
	defer aws.Close()

	docker := test.StubDocker(
		// query for every ECS task to get docker id, command, created
		test.ListECSContainersCycle(),

		// query every instance for one-off containers
		test.ListOneoffContainersEmptyCycle(),
		test.ListOneoffContainersEmptyCycle(),
		test.ListOneoffContainersEmptyCycle(),

		// query for every container to get CPU and Memory stats
		test.StatsCycle(),
	)
	defer docker.Close()

	v := url.Values{}
	v.Add("stats", "true")
	body := test.HTTPBody("GET", "http://convox/apps/myapp-staging/processes", v)

	var resp client.Processes
	err := json.Unmarshal([]byte(body), &resp)

	if assert.Nil(t, err) {
		assert.Equal(t, 2, len(resp))
		assert.Equal(t, "8dfafdbc3a40", resp[0].Id)
		assert.Equal(t, 0.0974, resp[0].Memory)
		assert.Equal(t, "pending", resp[1].Id)
		assert.EqualValues(t, 0, resp[1].Memory)
	}
}
开发者ID:soulware,项目名称:rack,代码行数:54,代码来源:processes_test.go


示例15: getClusterServices

func getClusterServices() (models.ECSServices, error) {
	os.Setenv("RACK", "convox-test")
	os.Setenv("CLUSTER", "convox-test")

	stubAws := test.StubAws(
		test.HttpdListServicesCycle(),
		test.HttpdDescribeServicesCycle(),
	)
	defer stubAws.Close()

	return models.ClusterServices()
}
开发者ID:anthonyrisinger,项目名称:rack,代码行数:12,代码来源:cluster_test.go


示例16: TestAppCreateWithAlreadyExists

func TestAppCreateWithAlreadyExists(t *testing.T) {
	aws := test.StubAws(
		test.DescribeStackNotFound("application"),
		test.CreateAppStackExistsCycle("convox-test-application"),
		test.DescribeAppStackCycle("convox-test-application"),
	)
	defer aws.Close()

	val := url.Values{"name": []string{"application"}}
	body := test.AssertStatus(t, 403, "POST", "http://convox/apps", val)
	assert.Equal(t, "{\"error\":\"there is already an app named application (running)\"}", body)
}
开发者ID:soulware,项目名称:rack,代码行数:12,代码来源:apps_test.go


示例17: TestAppList

func TestAppList(t *testing.T) {
	aws := test.StubAws(test.DescribeStackCycleWithoutQuery("convox-test-bar"))
	defer aws.Close()

	body := test.HTTPBody("GET", "http://convox/apps", nil)

	var resp []map[string]string
	err := json.Unmarshal([]byte(body), &resp)

	if assert.Nil(t, err) {
		assert.Equal(t, "bar", resp[0]["name"])
		assert.Equal(t, "running", resp[0]["status"])
	}
}
开发者ID:soulware,项目名称:rack,代码行数:14,代码来源:apps_test.go


示例18: TestFormationScaleCount0

// post count=0 should set MainDesiredCount=0 in the stack update
func TestFormationScaleCount0(t *testing.T) {
	aws := test.StubAws(
		test.DescribeAppStackCycle("convox-test-application"),
		test.DescribeAppStackCycle("convox-test-application"),
		test.GetItemAppReleaseCycle("convox-test-application"),
		test.UpdateAppStackCycle("convox-test-application", "0", "256"),
	)
	defer aws.Close()

	val := url.Values{"count": []string{"0"}, "memory": []string{""}}
	body := test.HTTPBody("POST", "http://convox/apps/application/formation/main", val)

	assert.Equal(t, `{"success":true}`, body)
}
开发者ID:soulware,项目名称:rack,代码行数:15,代码来源:formation_test.go


示例19: TestFormationScaleMemoryInvalid

// post memory=foo should 403
func TestFormationScaleMemoryInvalid(t *testing.T) {
	aws := test.StubAws(
		test.DescribeAppStackCycle("convox-test-application"),
		test.DescribeAppStackCycle("convox-test-application"),
		test.GetItemAppReleaseCycle("convox-test-application"),
		test.UpdateAppStackCycle("convox-test-application", "1", "256"),
	)
	defer aws.Close()

	val := url.Values{"count": []string{""}, "memory": []string{"foo"}}
	body := test.HTTPBody("POST", "http://convox/apps/application/formation/main", val)

	assert.Equal(t, `{"error":"memory must be numeric"}`, body)
}
开发者ID:soulware,项目名称:rack,代码行数:15,代码来源:formation_test.go


示例20: TestGetProcessesWithDeployments

func TestGetProcessesWithDeployments(t *testing.T) {
	os.Setenv("RACK", "convox-test")
	os.Setenv("CLUSTER", "convox-test-cluster")
	os.Setenv("TEST", "true")

	aws := test.StubAws(
		test.DescribeAppStackCycle("myapp-staging"),
		test.DescribeAppStackCycle("myapp-staging"),
		test.ListTasksCycle("convox-test-cluster"),
		test.DescribeTasksCycle("convox-test-cluster"),
		test.DescribeTaskDefinitionCycle("convox-test-cluster"),
		test.DescribeContainerInstancesFilteredCycle("convox-test-cluster"),
		test.DescribeInstancesFilteredCycle(),
		test.DescribeAppStackResourcesCycle("myapp-staging"),
		test.DescribeServicesWithDeploymentsCycle("convox-test-cluster"),
		test.DescribeTaskDefinition3Cycle("convox-test-cluster"),
		test.ListContainerInstancesCycle("convox-test-cluster"),
		test.DescribeContainerInstancesCycle("convox-test-cluster"),
		test.DescribeInstancesCycle(),
		test.DescribeTaskDefinition1Cycle("convox-test-cluster"),
	)
	defer aws.Close()

	docker := test.StubDocker(
		test.ListContainersCycle(),
		test.ListConvoxContainersCycle(),
		test.ListConvoxContainersCycle(),
		test.ListConvoxContainersCycle(),
		test.StatsCycle(),
	)
	defer docker.Close()

	v := url.Values{}
	v.Add("stats", "false")
	body := test.HTTPBody("GET", "http://convox/apps/myapp-staging/processes", v)

	var resp client.Processes
	err := json.Unmarshal([]byte(body), &resp)

	if assert.Nil(t, err) {
		assert.Equal(t, 2, len(resp))
		assert.Equal(t, "pending", resp[1].Id)
		//assert.Equal(t, "8dfafdbc3a40", resp[1].Id)
		//assert.Equal(t, "8dfafdbc3a40", resp[2].Id)
		//assert.Equal(t, "4932cce0897b", resp[3].Id)
		//assert.Equal(t, "pending", resp[4].Id)
	}
}
开发者ID:cozmo,项目名称:rack,代码行数:48,代码来源:processes_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang awserr.New函数代码示例发布时间:2022-05-23
下一篇:
Golang test.Runs函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap