本文整理汇总了Golang中github.com/aws/aws-sdk-go/internal/protocol/query.Unmarshal函数的典型用法代码示例。如果您正苦于以下问题:Golang Unmarshal函数的具体用法?Golang Unmarshal怎么用?Golang Unmarshal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Unmarshal函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestOutputService1ProtocolTestScalarMembersCase1
func TestOutputService1ProtocolTestScalarMembersCase1(t *testing.T) {
svc := NewOutputService1ProtocolTest(nil)
buf := bytes.NewReader([]byte("<OperationNameResponse><OperationNameResult><Str>myname</Str><FooNum>123</FooNum><FalseBool>false</FalseBool><TrueBool>true</TrueBool><Float>1.2</Float><Double>1.3</Double><Long>200</Long><Char>a</Char><Timestamp>2015-01-25T08:00:00Z</Timestamp></OperationNameResult><ResponseMetadata><RequestId>request-id</RequestId></ResponseMetadata></OperationNameResponse>"))
req, out := svc.OutputService1TestCaseOperation1Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
// set headers
// unmarshal response
query.UnmarshalMeta(req)
query.Unmarshal(req)
assert.NoError(t, req.Error)
// assert response
assert.NotNil(t, out) // ensure out variable is used
assert.Equal(t, "a", *out.Char)
assert.Equal(t, 1.3, *out.Double)
assert.Equal(t, false, *out.FalseBool)
assert.Equal(t, 1.2, *out.Float)
assert.Equal(t, int64(200), *out.Long)
assert.Equal(t, int64(123), *out.Num)
assert.Equal(t, "myname", *out.Str)
assert.Equal(t, time.Unix(1.4221728e+09, 0).UTC().String(), out.Timestamp.String())
assert.Equal(t, true, *out.TrueBool)
}
开发者ID:Xetius,项目名称:grafana,代码行数:27,代码来源:unmarshal_test.go
示例2: TestOutputService13ProtocolTestFlattenedMapInShapeDefinitionCase1
func TestOutputService13ProtocolTestFlattenedMapInShapeDefinitionCase1(t *testing.T) {
svc := NewOutputService13ProtocolTest(nil)
buf := bytes.NewReader([]byte("<OperationNameResponse><OperationNameResult><Attribute><Name>qux</Name><Value>bar</Value></Attribute></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
req, out := svc.OutputService13TestCaseOperation1Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
// set headers
// unmarshal response
query.UnmarshalMeta(req)
query.Unmarshal(req)
assert.NoError(t, req.Error)
// assert response
assert.NotNil(t, out) // ensure out variable is used
assert.Equal(t, "bar", *out.Map["qux"])
}
开发者ID:Xetius,项目名称:grafana,代码行数:19,代码来源:unmarshal_test.go
示例3: TestOutputService7ProtocolTestFlattenedSingleElementListCase1
func TestOutputService7ProtocolTestFlattenedSingleElementListCase1(t *testing.T) {
svc := NewOutputService7ProtocolTest(nil)
buf := bytes.NewReader([]byte("<OperationNameResponse><OperationNameResult><ListMember>abc</ListMember></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
req, out := svc.OutputService7TestCaseOperation1Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
// set headers
// unmarshal response
query.UnmarshalMeta(req)
query.Unmarshal(req)
assert.NoError(t, req.Error)
// assert response
assert.NotNil(t, out) // ensure out variable is used
assert.Equal(t, "abc", *out.ListMember[0])
}
开发者ID:Xetius,项目名称:grafana,代码行数:19,代码来源:unmarshal_test.go
示例4: TestOutputService3ProtocolTestBlobCase1
func TestOutputService3ProtocolTestBlobCase1(t *testing.T) {
svc := NewOutputService3ProtocolTest(nil)
buf := bytes.NewReader([]byte("<OperationNameResponse><OperationNameResult><Blob>dmFsdWU=</Blob></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
req, out := svc.OutputService3TestCaseOperation1Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
// set headers
// unmarshal response
query.UnmarshalMeta(req)
query.Unmarshal(req)
assert.NoError(t, req.Error)
// assert response
assert.NotNil(t, out) // ensure out variable is used
assert.Equal(t, "value", string(out.Blob))
}
开发者ID:Xetius,项目名称:grafana,代码行数:19,代码来源:unmarshal_test.go
示例5: TestOutputService2ProtocolTestNotAllMembersInResponseCase1
func TestOutputService2ProtocolTestNotAllMembersInResponseCase1(t *testing.T) {
svc := NewOutputService2ProtocolTest(nil)
buf := bytes.NewReader([]byte("<OperationNameResponse><OperationNameResult><Str>myname</Str></OperationNameResult><ResponseMetadata><RequestId>request-id</RequestId></ResponseMetadata></OperationNameResponse>"))
req, out := svc.OutputService2TestCaseOperation1Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
// set headers
// unmarshal response
query.UnmarshalMeta(req)
query.Unmarshal(req)
assert.NoError(t, req.Error)
// assert response
assert.NotNil(t, out) // ensure out variable is used
assert.Equal(t, "myname", *out.Str)
}
开发者ID:Xetius,项目名称:grafana,代码行数:19,代码来源:unmarshal_test.go
示例6: TestOutputService14ProtocolTestNamedMapCase1
func TestOutputService14ProtocolTestNamedMapCase1(t *testing.T) {
svc := NewOutputService14ProtocolTest(nil)
buf := bytes.NewReader([]byte("<OperationNameResponse><OperationNameResult><Map><foo>qux</foo><bar>bar</bar></Map><Map><foo>baz</foo><bar>bam</bar></Map></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
req, out := svc.OutputService14TestCaseOperation1Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
// set headers
// unmarshal response
query.UnmarshalMeta(req)
query.Unmarshal(req)
assert.NoError(t, req.Error)
// assert response
assert.NotNil(t, out) // ensure out variable is used
assert.Equal(t, "bam", *out.Map["baz"])
assert.Equal(t, "bar", *out.Map["qux"])
}
开发者ID:Xetius,项目名称:grafana,代码行数:20,代码来源:unmarshal_test.go
示例7: TestOutputService11ProtocolTestNormalMapCase1
func TestOutputService11ProtocolTestNormalMapCase1(t *testing.T) {
svc := NewOutputService11ProtocolTest(nil)
buf := bytes.NewReader([]byte("<OperationNameResponse xmlns=\"https://service.amazonaws.com/doc/2010-05-08\"><OperationNameResult><Map><entry><key>qux</key><value><foo>bar</foo></value></entry><entry><key>baz</key><value><foo>bam</foo></value></entry></Map></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
req, out := svc.OutputService11TestCaseOperation1Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
// set headers
// unmarshal response
query.UnmarshalMeta(req)
query.Unmarshal(req)
assert.NoError(t, req.Error)
// assert response
assert.NotNil(t, out) // ensure out variable is used
assert.Equal(t, "bam", *out.Map["baz"].Foo)
assert.Equal(t, "bar", *out.Map["qux"].Foo)
}
开发者ID:Xetius,项目名称:grafana,代码行数:20,代码来源:unmarshal_test.go
示例8: TestOutputService10ProtocolTestFlattenedListWithLocationNameCase1
func TestOutputService10ProtocolTestFlattenedListWithLocationNameCase1(t *testing.T) {
svc := NewOutputService10ProtocolTest(nil)
buf := bytes.NewReader([]byte("<OperationNameResponse xmlns=\"https://service.amazonaws.com/doc/2010-05-08/\"><OperationNameResult><NamedList>a</NamedList><NamedList>b</NamedList></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
req, out := svc.OutputService10TestCaseOperation1Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
// set headers
// unmarshal response
query.UnmarshalMeta(req)
query.Unmarshal(req)
assert.NoError(t, req.Error)
// assert response
assert.NotNil(t, out) // ensure out variable is used
assert.Equal(t, "a", *out.List[0])
assert.Equal(t, "b", *out.List[1])
}
开发者ID:Xetius,项目名称:grafana,代码行数:20,代码来源:unmarshal_test.go
示例9: TestOutputService9ProtocolTestFlattenedListOfStructuresCase1
func TestOutputService9ProtocolTestFlattenedListOfStructuresCase1(t *testing.T) {
svc := NewOutputService9ProtocolTest(nil)
buf := bytes.NewReader([]byte("<OperationNameResponse xmlns=\"https://service.amazonaws.com/doc/2010-05-08/\"><OperationNameResult><List><Foo>firstfoo</Foo><Bar>firstbar</Bar><Baz>firstbaz</Baz></List><List><Foo>secondfoo</Foo><Bar>secondbar</Bar><Baz>secondbaz</Baz></List></OperationNameResult><ResponseMetadata><RequestId>requestid</RequestId></ResponseMetadata></OperationNameResponse>"))
req, out := svc.OutputService9TestCaseOperation1Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
// set headers
// unmarshal response
query.UnmarshalMeta(req)
query.Unmarshal(req)
assert.NoError(t, req.Error)
// assert response
assert.NotNil(t, out) // ensure out variable is used
assert.Equal(t, "firstbar", *out.List[0].Bar)
assert.Equal(t, "firstbaz", *out.List[0].Baz)
assert.Equal(t, "firstfoo", *out.List[0].Foo)
assert.Equal(t, "secondbar", *out.List[1].Bar)
assert.Equal(t, "secondbaz", *out.List[1].Baz)
assert.Equal(t, "secondfoo", *out.List[1].Foo)
}
开发者ID:Xetius,项目名称:grafana,代码行数:24,代码来源:unmarshal_test.go
注:本文中的github.com/aws/aws-sdk-go/internal/protocol/query.Unmarshal函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论