本文整理匯總了Golang中github.com/motain/gocheck.C.Assert方法的典型用法代碼示例。如果您正苦於以下問題:Golang C.Assert方法的具體用法?Golang C.Assert怎麽用?Golang C.Assert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/motain/gocheck.C
的用法示例。
在下文中一共展示了C.Assert方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SetUp
func (s *LocalServer) SetUp(c *gocheck.C) {
srv, err := elbtest.NewServer()
c.Assert(err, gocheck.IsNil)
c.Assert(srv, gocheck.NotNil)
s.srv = srv
s.region = aws.Region{ELBEndpoint: srv.URL()}
}
示例2: TestDescribeScheduledActions
func (s *S) TestDescribeScheduledActions(c *gocheck.C) {
testServer.Response(200, nil, DescribeScheduledActionsResponse)
st, _ := time.Parse(time.RFC3339, "2014-06-01T00:30:00Z")
request := &DescribeScheduledActionsParams{
AutoScalingGroupName: "ASGTest1",
MaxRecords: 1,
StartTime: st,
}
resp, err := s.as.DescribeScheduledActions(request)
c.Assert(err, gocheck.IsNil)
values := testServer.WaitRequest().PostForm
c.Assert(values.Get("Version"), gocheck.Equals, "2011-01-01")
c.Assert(values.Get("Action"), gocheck.Equals, "DescribeScheduledActions")
c.Assert(resp.RequestId, gocheck.Equals, "0eb4217f-8421-11e3-9233-7100ef811766")
c.Assert(resp.ScheduledUpdateGroupActions, gocheck.DeepEquals, []ScheduledUpdateGroupAction{
{
AutoScalingGroupName: "ASGTest1",
ScheduledActionARN: "arn:aws:autoscaling:us-west-2:193024542802:scheduledUpdateGroupAction:61f68b2c-bde3-4316-9a81-eb95dc246509:autoScalingGroupName/ASGTest1:scheduledActionName/SATest1",
ScheduledActionName: "SATest1",
Recurrence: "30 0 1 1,6,12 *",
MaxSize: 4,
StartTime: st,
Time: st,
},
})
}
示例3: TestExitStandby
func (s *S) TestExitStandby(c *gocheck.C) {
testServer.Response(200, nil, ExitStandbyResponse)
resp, err := s.as.ExitStandby("my-asg", []string{"i-5b73d709"})
c.Assert(err, gocheck.IsNil)
values := testServer.WaitRequest().PostForm
c.Assert(values.Get("Version"), gocheck.Equals, "2011-01-01")
c.Assert(values.Get("Action"), gocheck.Equals, "ExitStandby")
c.Assert(values.Get("AutoScalingGroupName"), gocheck.Equals, "my-asg")
c.Assert(values.Get("InstanceIds.member.1"), gocheck.Equals, "i-5b73d709")
st, _ := time.Parse(time.RFC3339, "2014-06-13T22:43:53.523Z")
expected := &ExitStandbyResult{
RequestId: "321a11c8-f34c-11e3-a434-7f10009d5849",
Activities: []Activity{
{
StatusCode: "PreInService",
Progress: 30,
ActivityId: "dca4efcf-eea6-4844-8064-cab1fecd1aa2",
StartTime: st,
AutoScalingGroupName: "my-asg",
Details: "{\"Availability Zone\":\"us-east-1a\"}",
Cause: "At 2014-06-13T22:43:53Z instance i-5b73d709 was moved out of standby in response to a user request, increasing the capacity from 3 to 4.",
Description: "Moving EC2 instance out of Standby: i-5b73d709",
},
},
}
c.Assert(resp, gocheck.DeepEquals, expected)
}
示例4: TestListGroups
func (s *S) TestListGroups(c *gocheck.C) {
testServer.Response(200, nil, ListGroupsExample)
resp, err := s.iam.Groups("/division_abc/")
values := testServer.WaitRequest().URL.Query()
c.Assert(values.Get("Action"), gocheck.Equals, "ListGroups")
c.Assert(values.Get("PathPrefix"), gocheck.Equals, "/division_abc/")
c.Assert(err, gocheck.IsNil)
c.Assert(resp.RequestId, gocheck.Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
expected := []iam.Group{
{
Path: "/division_abc/subdivision_xyz/",
Name: "Admins",
Id: "AGPACKCEVSQ6C2EXAMPLE",
Arn: "arn:aws:iam::123456789012:group/Admins",
},
{
Path: "/division_abc/subdivision_xyz/product_1234/engineering/",
Name: "Test",
Id: "AGP2MAB8DPLSRHEXAMPLE",
Arn: "arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_1234/engineering/Test",
},
{
Path: "/division_abc/subdivision_xyz/product_1234/",
Name: "Managers",
Id: "AGPIODR4TAW7CSEXAMPLE",
Arn: "arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_1234/Managers",
},
}
c.Assert(resp.Groups, gocheck.DeepEquals, expected)
}
示例5: SetUpSuite
func (s *S) SetUpSuite(c *gocheck.C) {
var err error
testServer.Start()
auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
s.rds, err = rds.New(auth, aws.Region{RDSEndpoint: aws.ServiceInfo{testServer.URL, aws.V2Signature}})
c.Assert(err, gocheck.IsNil)
}
示例6: TestCases
func (s *V4SignerSuite) TestCases(c *gocheck.C) {
signer := aws.NewV4Signer(s.auth, "host", s.region)
for _, testCase := range s.cases {
req, err := http.NewRequest(testCase.request.method, "http://"+testCase.request.host+testCase.request.url, strings.NewReader(testCase.request.body))
c.Assert(err, gocheck.IsNil, gocheck.Commentf("Testcase: %s", testCase.label))
for _, v := range testCase.request.headers {
h := strings.SplitN(v, ":", 2)
req.Header.Add(h[0], h[1])
}
req.Header.Set("host", req.Host)
t := signer.RequestTime(req)
canonicalRequest := signer.CanonicalRequest(req)
c.Check(canonicalRequest, gocheck.Equals, testCase.canonicalRequest, gocheck.Commentf("Testcase: %s", testCase.label))
stringToSign := signer.StringToSign(t, canonicalRequest)
c.Check(stringToSign, gocheck.Equals, testCase.stringToSign, gocheck.Commentf("Testcase: %s", testCase.label))
signature := signer.Signature(t, stringToSign)
c.Check(signature, gocheck.Equals, testCase.signature, gocheck.Commentf("Testcase: %s", testCase.label))
authorization := signer.Authorization(req.Header, t, signature)
c.Check(authorization, gocheck.Equals, testCase.authorization, gocheck.Commentf("Testcase: %s", testCase.label))
signer.Sign(req)
c.Check(req.Header.Get("Authorization"), gocheck.Equals, testCase.authorization, gocheck.Commentf("Testcase: %s", testCase.label))
}
}
示例7: TestEscaping
func (s *S) TestEscaping(c *gocheck.C) {
params := map[string]string{"Nonce": "+ +"}
elb.Sign(testAuth, "GET", "/path", params, "localhost")
c.Assert(params["Nonce"], gocheck.Equals, "+ +")
expected := "bqffDELReIqwjg/W0DnsnVUmfLK4wXVLO4/LuG+1VFA="
c.Assert(params["Signature"], gocheck.Equals, expected)
}
示例8: createInstanceAndLB
func (s *ClientTests) createInstanceAndLB(c *gocheck.C) (*elb.CreateLoadBalancer, string) {
options := ec2.RunInstancesOptions{
ImageId: "ami-ccf405a5",
InstanceType: "t1.micro",
AvailabilityZone: "us-east-1c",
}
resp1, err := s.ec2.RunInstances(&options)
c.Assert(err, gocheck.IsNil)
instId := resp1.Instances[0].InstanceId
createLBReq := elb.CreateLoadBalancer{
Name: "testlb",
AvailabilityZones: []string{"us-east-1c"},
Listeners: []elb.Listener{
{
InstancePort: 80,
InstanceProtocol: "http",
LoadBalancerPort: 80,
Protocol: "http",
},
},
}
_, err = s.elb.CreateLoadBalancer(&createLBReq)
c.Assert(err, gocheck.IsNil)
return &createLBReq, instId
}
示例9: TestDescribeInstanceHealthBadRequest
func (s *S) TestDescribeInstanceHealthBadRequest(c *gocheck.C) {
testServer.PrepareResponse(400, nil, DescribeInstanceHealthBadRequest)
resp, err := s.elb.DescribeInstanceHealth("testlb", "i-foooo")
c.Assert(err, gocheck.NotNil)
c.Assert(resp, gocheck.IsNil)
c.Assert(err, gocheck.ErrorMatches, ".*i-foooo.*(InvalidInstance).*")
}
示例10: TestDescribeLoadBalancersBadRequest
func (s *S) TestDescribeLoadBalancersBadRequest(c *gocheck.C) {
testServer.PrepareResponse(400, nil, DescribeLoadBalancersBadRequest)
resp, err := s.elb.DescribeLoadBalancers()
c.Assert(resp, gocheck.IsNil)
c.Assert(err, gocheck.NotNil)
c.Assert(err, gocheck.ErrorMatches, `^Cannot find Load Balancer absentlb \(LoadBalancerNotFound\)$`)
}
示例11: TestGetTemplate
func (s *S) TestGetTemplate(c *gocheck.C) {
testServer.Response(200, nil, GetTemplateResponse)
resp, err := s.cf.GetTemplate("MyStack")
c.Assert(err, gocheck.IsNil)
values := testServer.WaitRequest().PostForm
// Post request test
c.Assert(values.Get("Version"), gocheck.Equals, "2010-05-15")
c.Assert(values.Get("Action"), gocheck.Equals, "GetTemplate")
c.Assert(values.Get("StackName"), gocheck.Equals, "MyStack")
// Response test
templateBody := `{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Simple example",
"Resources" : {
"MySQS" : {
"Type" : "AWS::SQS::Queue",
"Properties" : {
}
}
}
}`
c.Assert(resp.TemplateBody, gocheck.Equals, templateBody)
c.Assert(resp.RequestId, gocheck.Equals, "4af14eec-350e-11e4-b260-EXAMPLE")
}
示例12: TestEnvAuthAlt
func (s *S) TestEnvAuthAlt(c *gocheck.C) {
os.Clearenv()
os.Setenv("AWS_SECRET_KEY", "secret")
os.Setenv("AWS_ACCESS_KEY", "access")
auth, err := aws.EnvAuth()
c.Assert(err, gocheck.IsNil)
c.Assert(auth, gocheck.Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"})
}
示例13: TestGetAuthEnv
func (s *S) TestGetAuthEnv(c *gocheck.C) {
os.Clearenv()
os.Setenv("AWS_SECRET_ACCESS_KEY", "secret")
os.Setenv("AWS_ACCESS_KEY_ID", "access")
auth, err := aws.GetAuth("", "", "", time.Time{})
c.Assert(err, gocheck.IsNil)
c.Assert(auth, gocheck.Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"})
}
示例14: TestListAccessKeysUserNotFound
func (s *ClientTests) TestListAccessKeysUserNotFound(c *gocheck.C) {
_, err := s.iam.AccessKeys("unknowngopher")
c.Assert(err, gocheck.NotNil)
iamErr, ok := err.(*iam.Error)
c.Assert(ok, gocheck.Equals, true)
c.Assert(iamErr.StatusCode, gocheck.Equals, 404)
c.Assert(iamErr.Code, gocheck.Equals, "NoSuchEntity")
c.Assert(iamErr.Message, gocheck.Equals, "The user with name unknowngopher cannot be found.")
}
示例15: checkContents
func checkContents(c *gocheck.C, contents []s3.Key, data map[string][]byte, expected []s3.Key) {
c.Assert(contents, gocheck.HasLen, len(expected))
for i, k := range contents {
c.Check(k.Key, gocheck.Equals, expected[i].Key)
// TODO mtime
c.Check(k.Size, gocheck.Equals, int64(len(data[k.Key])))
c.Check(k.ETag, gocheck.Equals, etag(data[k.Key]))
}
}