本文整理汇总了Golang中github.com/aws/aws-sdk-go/awstesting.AssertJSON函数的典型用法代码示例。如果您正苦于以下问题:Golang AssertJSON函数的具体用法?Golang AssertJSON怎么用?Golang AssertJSON使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AssertJSON函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestInputService5ProtocolTestRecursiveShapesCase3
func TestInputService5ProtocolTestRecursiveShapesCase3(t *testing.T) {
svc := NewInputService5ProtocolTest(nil)
svc.Endpoint = "https://test"
input := &InputService5TestShapeInputShape{
RecursiveStruct: &InputService5TestShapeRecursiveStructType{
RecursiveStruct: &InputService5TestShapeRecursiveStructType{
RecursiveStruct: &InputService5TestShapeRecursiveStructType{
RecursiveStruct: &InputService5TestShapeRecursiveStructType{
NoRecurse: aws.String("foo"),
},
},
},
},
}
req, _ := svc.InputService5TestCaseOperation3Request(input)
r := req.HTTPRequest
// build request
jsonrpc.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertJSON(t, `{"RecursiveStruct":{"RecursiveStruct":{"RecursiveStruct":{"RecursiveStruct":{"NoRecurse":"foo"}}}}}`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
assert.Equal(t, "application/x-amz-json-1.1", r.Header.Get("Content-Type"))
assert.Equal(t, "com.amazonaws.foo.OperationName", r.Header.Get("X-Amz-Target"))
}
开发者ID:rifflock,项目名称:aws-sdk-go,代码行数:35,代码来源:build_test.go
示例2: TestInputService3ProtocolTestBase64EncodedBlobsCase2
func TestInputService3ProtocolTestBase64EncodedBlobsCase2(t *testing.T) {
svc := NewInputService3ProtocolTest(nil)
svc.Endpoint = "https://test"
input := &InputService3TestShapeInputShape{
BlobMap: map[string][]byte{
"key1": []byte("foo"),
"key2": []byte("bar"),
},
}
req, _ := svc.InputService3TestCaseOperation2Request(input)
r := req.HTTPRequest
// build request
jsonrpc.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertJSON(t, `{"BlobMap":{"key1":"Zm9v","key2":"YmFy"}}`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
assert.Equal(t, "application/x-amz-json-1.1", r.Header.Get("Content-Type"))
assert.Equal(t, "com.amazonaws.foo.OperationName", r.Header.Get("X-Amz-Target"))
}
开发者ID:rifflock,项目名称:aws-sdk-go,代码行数:30,代码来源:build_test.go
示例3: TestInputService4ProtocolTestNestedBlobsCase1
func TestInputService4ProtocolTestNestedBlobsCase1(t *testing.T) {
svc := NewInputService4ProtocolTest(nil)
svc.Endpoint = "https://test"
input := &InputService4TestShapeInputService4TestCaseOperation1Input{
ListParam: [][]byte{
[]byte("foo"),
[]byte("bar"),
},
}
req, _ := svc.InputService4TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
jsonrpc.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertJSON(t, `{"ListParam":["Zm9v","YmFy"]}`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
assert.Equal(t, "application/x-amz-json-1.1", r.Header.Get("Content-Type"))
assert.Equal(t, "com.amazonaws.foo.OperationName", r.Header.Get("X-Amz-Target"))
}
开发者ID:rifflock,项目名称:aws-sdk-go,代码行数:30,代码来源:build_test.go
示例4: TestInputService6ProtocolTestEmptyMapsCase1
func TestInputService6ProtocolTestEmptyMapsCase1(t *testing.T) {
svc := NewInputService6ProtocolTest(nil)
svc.Endpoint = "https://test"
input := &InputService6TestShapeInputService6TestCaseOperation1Input{
Map: map[string]*string{},
}
req, _ := svc.InputService6TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
jsonrpc.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertJSON(t, `{"Map":{}}`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
assert.Equal(t, "application/x-amz-json-1.1", r.Header.Get("Content-Type"))
assert.Equal(t, "com.amazonaws.foo.OperationName", r.Header.Get("X-Amz-Target"))
}
开发者ID:rifflock,项目名称:aws-sdk-go,代码行数:27,代码来源:build_test.go
示例5: TestInputService2ProtocolTestTimestampValuesCase1
func TestInputService2ProtocolTestTimestampValuesCase1(t *testing.T) {
svc := NewInputService2ProtocolTest(nil)
svc.Endpoint = "https://test"
input := &InputService2TestShapeInputService2TestCaseOperation1Input{
TimeArg: aws.Time(time.Unix(1422172800, 0)),
}
req, _ := svc.InputService2TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
jsonrpc.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertJSON(t, `{"TimeArg":1422172800}`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
assert.Equal(t, "application/x-amz-json-1.1", r.Header.Get("Content-Type"))
assert.Equal(t, "com.amazonaws.foo.OperationName", r.Header.Get("X-Amz-Target"))
}
开发者ID:rifflock,项目名称:aws-sdk-go,代码行数:27,代码来源:build_test.go
示例6: TestInputService3ProtocolTestBase64EncodedBlobsCase1
func TestInputService3ProtocolTestBase64EncodedBlobsCase1(t *testing.T) {
sess := session.New()
svc := NewInputService3ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService3TestShapeInputShape{
BlobArg: []byte("foo"),
}
req, _ := svc.InputService3TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
jsonrpc.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertJSON(t, `{"BlobArg":"Zm9v"}`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
assert.Equal(t, "application/x-amz-json-1.1", r.Header.Get("Content-Type"))
assert.Equal(t, "com.amazonaws.foo.OperationName", r.Header.Get("X-Amz-Target"))
}
开发者ID:ernesto-jimenez,项目名称:goad,代码行数:27,代码来源:build_test.go
示例7: TestAssertJSON
func TestAssertJSON(t *testing.T) {
cases := []struct {
e, a string
asserts bool
}{
{
e: `{"RecursiveStruct":{"RecursiveMap":{"foo":{"NoRecurse":"foo"},"bar":{"NoRecurse":"bar"}}}}`,
a: `{"RecursiveStruct":{"RecursiveMap":{"bar":{"NoRecurse":"bar"},"foo":{"NoRecurse":"foo"}}}}`,
asserts: true,
},
}
for i, c := range cases {
mockT := &testing.T{}
if awstesting.AssertJSON(mockT, c.e, c.a) != c.asserts {
t.Error("Assert JSON result was not expected.", i)
}
}
}
开发者ID:ColourboxDevelopment,项目名称:aws-sdk-go,代码行数:19,代码来源:assert_test.go
示例8: TestInputService7ProtocolTestIdempotencyTokenAutoFillCase2
func TestInputService7ProtocolTestIdempotencyTokenAutoFillCase2(t *testing.T) {
sess := session.New()
svc := NewInputService7ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService7TestShapeInputShape{}
req, _ := svc.InputService7TestCaseOperation2Request(input)
r := req.HTTPRequest
// build request
jsonrpc.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertJSON(t, `{"Token":"00000000-0000-4000-8000-000000000000"}`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/path", r.URL.String())
// assert headers
}
开发者ID:artemnikitin,项目名称:devicefarm-ci-tool,代码行数:22,代码来源:build_test.go
示例9: assertMarshalsTo
func assertMarshalsTo(t *testing.T, value interface{}, expectedJSON string) {
actual, err := json.Marshal(value)
assert.Nil(t, err)
awstesting.AssertJSON(t, expectedJSON, string(actual))
}
开发者ID:rlcomte,项目名称:aws-sdk-go,代码行数:6,代码来源:template_test.go
示例10: TestTemplateCreation
func TestTemplateCreation(t *testing.T) {
template := Template{
AWSTemplateFormatVersion: "2010-09-09",
Description: "This is a test template",
Metadata: map[string]interface{}{
"some-key": map[string]int{"thing": 42},
"some-other-key": []bool{true, true, false, true},
},
Parameters: map[string]Parameter{
"KeyName": {
Type: "AWS::EC2::KeyPair::KeyName",
Description: "SSH KeyPair to use for instances",
},
"DBPassword": {
NoEcho: true,
Description: "Password for the DB",
Type: "String",
MinLength: 5,
MaxLength: 31,
AllowedPattern: "[a-zA-Z0-9]*",
ConstraintDescription: "must contain only alphanumeric characters",
},
"InstanceType": {
Type: "String",
Default: "t1.micro",
AllowedValues: []string{"t1.micro", "t2.micro"},
},
},
}
expected := `
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "This is a test template",
"Metadata": {
"some-key": { "thing": 42 },
"some-other-key": [ true, true, false, true ]
},
"Parameters": {
"KeyName": {
"Description" : "SSH KeyPair to use for instances",
"Type": "AWS::EC2::KeyPair::KeyName"
},
"DBPassword": {
"NoEcho": "true",
"Description" : "Password for the DB",
"Type": "String",
"MinLength": "5",
"MaxLength": "31",
"AllowedPattern" : "[a-zA-Z0-9]*",
"ConstraintDescription" : "must contain only alphanumeric characters"
},
"InstanceType" : {
"Type" : "String",
"Default" : "t1.micro",
"AllowedValues" : [ "t1.micro", "t2.micro" ]
}
}
}
`
assertMarshalsTo(t, template, expected)
asString := template.String()
awstesting.AssertJSON(t, expected, asString)
}
开发者ID:rlcomte,项目名称:aws-sdk-go,代码行数:72,代码来源:template_test.go
注:本文中的github.com/aws/aws-sdk-go/awstesting.AssertJSON函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论