本文整理汇总了Golang中github.com/convox/rack/Godeps/_workspace/src/github.com/stretchr/testify/assert.NotNil函数的典型用法代码示例。如果您正苦于以下问题:Golang NotNil函数的具体用法?Golang NotNil怎么用?Golang NotNil使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NotNil函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestClientGetErrors
func TestClientGetErrors(t *testing.T) {
client := New("", "", "")
err := client.Get("", nil)
assert.NotNil(t, err)
assert.Equal(t, "Get https://: http: no Host in request URL", err.Error())
err = client.Get("/%", nil)
assert.NotNil(t, err)
assert.Equal(t, "parse https:///%: invalid URL escape \"%\"", err.Error())
}
开发者ID:soulware,项目名称:rack,代码行数:13,代码来源:client_test.go
示例2: TestManifestInvalid
func TestManifestInvalid(t *testing.T) {
manifest, err := LoadManifest("invalid-manifest")
assert.Nil(t, manifest)
assert.NotNil(t, err)
assert.Regexp(t, "^invalid manifest: ", err.Error())
}
开发者ID:cozmo,项目名称:rack,代码行数:7,代码来源:manifest_test.go
示例3: TestInputService8ProtocolTestTimestampValuesCase1
func TestInputService8ProtocolTestTimestampValuesCase1(t *testing.T) {
sess := session.New()
svc := NewInputService8ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService8TestShapeInputService8TestCaseOperation1Input{
TimeArg: aws.Time(time.Unix(1422172800, 0)),
}
req, _ := svc.InputService8TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
ec2query.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertQuery(t, `Action=OperationName&TimeArg=2015-01-25T08%3A00%3A00Z&Version=2014-01-01`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
}
开发者ID:kuenzaa,项目名称:rack,代码行数:25,代码来源:build_test.go
示例4: TestOutputService4ProtocolTestListsCase2
func TestOutputService4ProtocolTestListsCase2(t *testing.T) {
sess := session.New()
svc := NewOutputService4ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
buf := bytes.NewReader([]byte("{\"ListMember\": [\"a\", null], \"ListMemberMap\": [{}, null, null, {}], \"ListMemberStruct\": [{}, null, null, {}]}"))
req, out := svc.OutputService4TestCaseOperation2Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
// set headers
// unmarshal response
jsonrpc.UnmarshalMeta(req)
jsonrpc.Unmarshal(req)
assert.NoError(t, req.Error)
// assert response
assert.NotNil(t, out) // ensure out variable is used
assert.Equal(t, "a", *out.ListMember[0])
assert.Nil(t, out.ListMember[1])
assert.Nil(t, out.ListMemberMap[1])
assert.Nil(t, out.ListMemberMap[2])
assert.Nil(t, out.ListMemberStruct[1])
assert.Nil(t, out.ListMemberStruct[2])
}
开发者ID:kuenzaa,项目名称:rack,代码行数:25,代码来源:unmarshal_test.go
示例5: TestInputService7ProtocolTestBase64EncodedBlobsCase1
func TestInputService7ProtocolTestBase64EncodedBlobsCase1(t *testing.T) {
sess := session.New()
svc := NewInputService7ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService7TestShapeInputService7TestCaseOperation1Input{
BlobArg: []byte("foo"),
}
req, _ := svc.InputService7TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
ec2query.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertQuery(t, `Action=OperationName&BlobArg=Zm9v&Version=2014-01-01`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
}
开发者ID:kuenzaa,项目名称:rack,代码行数:25,代码来源:build_test.go
示例6: TestInputService6ProtocolTestListWithLocationNameAndQueryNameCase1
func TestInputService6ProtocolTestListWithLocationNameAndQueryNameCase1(t *testing.T) {
sess := session.New()
svc := NewInputService6ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService6TestShapeInputService6TestCaseOperation1Input{
ListArg: []*string{
aws.String("a"),
aws.String("b"),
aws.String("c"),
},
}
req, _ := svc.InputService6TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
ec2query.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertQuery(t, `Action=OperationName&ListQueryName.1=a&ListQueryName.2=b&ListQueryName.3=c&Version=2014-01-01`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
}
开发者ID:kuenzaa,项目名称:rack,代码行数:29,代码来源:build_test.go
示例7: TestInputService3ProtocolTestNestedStructureMembersCase1
func TestInputService3ProtocolTestNestedStructureMembersCase1(t *testing.T) {
sess := session.New()
svc := NewInputService3ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService3TestShapeInputService3TestCaseOperation1Input{
StructArg: &InputService3TestShapeStructType{
ScalarArg: aws.String("foo"),
},
}
req, _ := svc.InputService3TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
ec2query.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertQuery(t, `Action=OperationName&Struct.Scalar=foo&Version=2014-01-01`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
}
开发者ID:kuenzaa,项目名称:rack,代码行数:27,代码来源:build_test.go
示例8: TestDownloadError
func TestDownloadError(t *testing.T) {
s, names, _ := dlLoggingSvc([]byte{1, 2, 3})
num := 0
s.Handlers.Send.PushBack(func(r *request.Request) {
num++
if num > 1 {
r.HTTPResponse.StatusCode = 400
r.HTTPResponse.Body = ioutil.NopCloser(bytes.NewReader([]byte{}))
}
})
d := s3manager.NewDownloaderWithClient(s, func(d *s3manager.Downloader) {
d.Concurrency = 1
d.PartSize = 1
})
w := &aws.WriteAtBuffer{}
n, err := d.Download(w, &s3.GetObjectInput{
Bucket: aws.String("bucket"),
Key: aws.String("key"),
})
assert.NotNil(t, err)
assert.Equal(t, int64(1), n)
assert.Equal(t, []string{"GetObject", "GetObject"}, *names)
assert.Equal(t, []byte{1}, w.Bytes())
}
开发者ID:kuenzaa,项目名称:rack,代码行数:27,代码来源:download_test.go
示例9: TestOutputService1ProtocolTestScalarMembersCase1
func TestOutputService1ProtocolTestScalarMembersCase1(t *testing.T) {
sess := session.New()
svc := NewOutputService1ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
buf := bytes.NewReader([]byte("<OperationNameResponse><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><RequestId>request-id</RequestId></OperationNameResponse>"))
req, out := svc.OutputService1TestCaseOperation1Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
// set headers
// unmarshal response
ec2query.UnmarshalMeta(req)
ec2query.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, true, *out.TrueBool)
}
开发者ID:kuenzaa,项目名称:rack,代码行数:27,代码来源:unmarshal_test.go
示例10: TestOutputService9ProtocolTestSupportsHeaderMapsCase1
func TestOutputService9ProtocolTestSupportsHeaderMapsCase1(t *testing.T) {
sess := session.New()
svc := NewOutputService9ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
buf := bytes.NewReader([]byte("{}"))
req, out := svc.OutputService9TestCaseOperation1Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
// set headers
req.HTTPResponse.Header.Set("Content-Length", "10")
req.HTTPResponse.Header.Set("X-Bam", "boo")
req.HTTPResponse.Header.Set("X-Foo", "bar")
// unmarshal response
restjson.UnmarshalMeta(req)
restjson.Unmarshal(req)
assert.NoError(t, req.Error)
// assert response
assert.NotNil(t, out) // ensure out variable is used
assert.Equal(t, "10", *out.AllHeaders["Content-Length"])
assert.Equal(t, "boo", *out.AllHeaders["X-Bam"])
assert.Equal(t, "bar", *out.AllHeaders["X-Foo"])
assert.Equal(t, "boo", *out.PrefixedHeaders["Bam"])
assert.Equal(t, "bar", *out.PrefixedHeaders["Foo"])
}
开发者ID:kuenzaa,项目名称:rack,代码行数:27,代码来源:unmarshal_test.go
示例11: TestInputService2ProtocolTestStructureWithLocationNameAndQueryNameAppliedToMembersCase1
func TestInputService2ProtocolTestStructureWithLocationNameAndQueryNameAppliedToMembersCase1(t *testing.T) {
sess := session.New()
svc := NewInputService2ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService2TestShapeInputService2TestCaseOperation1Input{
Bar: aws.String("val2"),
Foo: aws.String("val1"),
Yuck: aws.String("val3"),
}
req, _ := svc.InputService2TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
ec2query.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertQuery(t, `Action=OperationName&BarLocationName=val2&Foo=val1&Version=2014-01-01&yuckQueryName=val3`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
}
开发者ID:kuenzaa,项目名称:rack,代码行数:27,代码来源:build_test.go
示例12: TestInputService2ProtocolTestTimestampValuesCase1
func TestInputService2ProtocolTestTimestampValuesCase1(t *testing.T) {
sess := session.New()
svc := NewInputService2ProtocolTest(sess, &aws.Config{Endpoint: aws.String("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:kuenzaa,项目名称:rack,代码行数:27,代码来源:build_test.go
示例13: TestInputService4ProtocolTestNestedBlobsCase1
func TestInputService4ProtocolTestNestedBlobsCase1(t *testing.T) {
sess := session.New()
svc := NewInputService4ProtocolTest(sess, &aws.Config{Endpoint: aws.String("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:kuenzaa,项目名称:rack,代码行数:30,代码来源:build_test.go
示例14: TestInputService5ProtocolTestRecursiveShapesCase3
func TestInputService5ProtocolTestRecursiveShapesCase3(t *testing.T) {
sess := session.New()
svc := NewInputService5ProtocolTest(sess, &aws.Config{Endpoint: aws.String("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:kuenzaa,项目名称:rack,代码行数:35,代码来源:build_test.go
示例15: TestInvalidMustCompilePanics
func TestInvalidMustCompilePanics(t *testing.T) {
defer func() {
r := recover()
assert.NotNil(t, r)
}()
MustCompile("not a valid expression")
}
开发者ID:kuenzaa,项目名称:rack,代码行数:7,代码来源:api_test.go
示例16: TestLexingErrors
func TestLexingErrors(t *testing.T) {
assert := assert.New(t)
lexer := NewLexer()
for _, tt := range lexingErrorTests {
_, err := lexer.tokenize(tt.expression)
assert.NotNil(err, fmt.Sprintf("Expected lexing error: %s", tt.msg))
}
}
开发者ID:kuenzaa,项目名称:rack,代码行数:8,代码来源:lexer_test.go
示例17: TestParsingErrors
func TestParsingErrors(t *testing.T) {
assert := assert.New(t)
parser := NewParser()
for _, tt := range parsingErrorTests {
_, err := parser.Parse(tt.expression)
assert.NotNil(err, fmt.Sprintf("Expected parsing error: %s, for expression: %s", tt.msg, tt.expression))
}
}
开发者ID:kuenzaa,项目名称:rack,代码行数:8,代码来源:parser_test.go
示例18: TestNewDefaultSession
func TestNewDefaultSession(t *testing.T) {
s := session.New(&aws.Config{Region: aws.String("region")})
assert.Equal(t, "region", *s.Config.Region)
assert.Equal(t, http.DefaultClient, s.Config.HTTPClient)
assert.NotNil(t, s.Config.Logger)
assert.Equal(t, aws.LogOff, *s.Config.LogLevel)
}
开发者ID:kuenzaa,项目名称:rack,代码行数:8,代码来源:session_test.go
示例19: TestClientErrorReading
func TestClientErrorReading(t *testing.T) {
er := ErrorReader{Error: "error reading"}
res := &http.Response{StatusCode: 400, Body: er}
err := responseError(res)
assert.NotNil(t, err, "err is not nil")
assert.Equal(t, "error reading response body: error reading", err.Error(), "err text is valid")
}
开发者ID:soulware,项目名称:rack,代码行数:8,代码来源:client_test.go
示例20: TestSendHandlerError
func TestSendHandlerError(t *testing.T) {
svc := awstesting.NewClient(&aws.Config{
HTTPClient: &http.Client{
Transport: &testSendHandlerTransport{},
},
})
svc.Handlers.Clear()
svc.Handlers.Send.PushBackNamed(corehandlers.SendHandler)
r := svc.NewRequest(&request.Operation{Name: "Operation"}, nil, nil)
r.Send()
assert.Error(t, r.Error)
assert.NotNil(t, r.HTTPResponse)
}
开发者ID:kuenzaa,项目名称:rack,代码行数:15,代码来源:handlers_test.go
注:本文中的github.com/convox/rack/Godeps/_workspace/src/github.com/stretchr/testify/assert.NotNil函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论