本文整理汇总了Golang中github.com/bfontaine/stargazer/Godeps/_workspace/src/github.com/stretchr/testify/assert.Nil函数的典型用法代码示例。如果您正苦于以下问题:Golang Nil函数的具体用法?Golang Nil怎么用?Golang Nil使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Nil函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestMemoizeGetter
func TestMemoizeGetter(t *testing.T) {
var calls int
f := func(s string) (string, error) {
calls++
if s == "error" {
return "", errors.New("oops")
}
return "called:" + s, nil
}
memoized := memoizeGetter(f)
require.NotNil(t, memoized)
assert.Equal(t, 0, calls)
s, err := memoized("yo")
assert.Nil(t, err)
assert.Equal(t, "called:yo", s)
assert.Equal(t, 1, calls)
s, err = memoized("yo")
assert.Nil(t, err)
assert.Equal(t, "called:yo", s)
assert.Equal(t, 1, calls)
s, err = memoized("error")
assert.NotNil(t, err)
assert.Equal(t, 2, calls)
s, err = memoized("error")
assert.NotNil(t, err)
assert.Equal(t, 3, calls)
}
示例2: TestStarNotification
func TestStarNotification(t *testing.T) {
s := Star{
Added: true,
User: "U123",
Timestamp: "1401",
Message: Message{
User: "U321",
Channel: "C123",
Text: "yo",
Timestamp: "1400",
},
}
slackInfo = &slack.Info{
Team: &slack.Team{
Name: "yolo",
Domain: "yoloo",
},
}
n, err := s.notification()
assert.Nil(t, err)
assert.Equal(t,
"@usernameU123 just starred your message in #channelC123: https://yoloo.slack.com/archives/channelC123/p1400",
n)
}
示例3: TestSimpleMessage
func TestSimpleMessage(t *testing.T) {
message, err := unmarshalMessage(simpleMessage)
assert.Nil(t, err)
assert.NotNil(t, message)
assert.Equal(t, "message", message.Type)
assert.Equal(t, "C2147483705", message.Channel)
assert.Equal(t, "U2147483697", message.User)
assert.Equal(t, "Hello world", message.Text)
assert.Equal(t, "1355517523.000005", message.Timestamp)
}
示例4: TestGroupLeaveMessage
func TestGroupLeaveMessage(t *testing.T) {
message, err := unmarshalMessage(groupLeaveMessage)
assert.Nil(t, err)
assert.NotNil(t, message)
assert.Equal(t, "message", message.Type)
assert.Equal(t, "group_leave", message.SubType)
assert.Equal(t, "1358877455.000010", message.Timestamp)
assert.Equal(t, "U2147483828", message.User)
assert.Equal(t, "<@U2147483828|cal> has left the group", message.Text)
}
示例5: TestGroupJoinMessage
func TestGroupJoinMessage(t *testing.T) {
message, err := unmarshalMessage(groupJoinMessage)
assert.Nil(t, err)
assert.NotNil(t, message)
assert.Equal(t, "message", message.Type)
assert.Equal(t, "group_join", message.SubType)
assert.Equal(t, "1358877458.000011", message.Timestamp)
assert.Equal(t, "U2147483828", message.User)
assert.Equal(t, "<@U2147483828|cal> has joined the group", message.Text)
}
示例6: TestGroupUnarchiveMessage
func TestGroupUnarchiveMessage(t *testing.T) {
message, err := unmarshalMessage(groupUnarchiveMessage)
assert.Nil(t, err)
assert.NotNil(t, message)
assert.Equal(t, "message", message.Type)
assert.Equal(t, "group_unarchive", message.SubType)
assert.Equal(t, "1361482916.000003", message.Timestamp)
assert.Equal(t, "<U1234|@cal> un-archived the group", message.Text)
assert.Equal(t, "U1234", message.User)
}
示例7: TestMeMessage
func TestMeMessage(t *testing.T) {
message, err := unmarshalMessage(meMessage)
assert.Nil(t, err)
assert.NotNil(t, message)
assert.Equal(t, "message", message.Type)
assert.Equal(t, "me_message", message.SubType)
assert.Equal(t, "C2147483705", message.Channel)
assert.Equal(t, "U2147483697", message.User)
assert.Equal(t, "is doing that thing", message.Text)
assert.Equal(t, "1355517523.000005", message.Timestamp)
}
示例8: TestGroupTopicMessage
func TestGroupTopicMessage(t *testing.T) {
message, err := unmarshalMessage(groupTopicMessage)
assert.Nil(t, err)
assert.NotNil(t, message)
assert.Equal(t, "message", message.Type)
assert.Equal(t, "group_topic", message.SubType)
assert.Equal(t, "1358877455.000010", message.Timestamp)
assert.Equal(t, "U2147483828", message.User)
assert.Equal(t, "hello world", message.Topic)
assert.Equal(t, "<@U2147483828|cal> set the group topic: hello world", message.Text)
}
示例9: TestStarredMessage
func TestStarredMessage(t *testing.T) {
message, err := unmarshalMessage(starredMessage)
assert.Nil(t, err)
assert.NotNil(t, message)
assert.Equal(t, "is testing", message.Text)
assert.Equal(t, "message", message.Type)
assert.Equal(t, "me_message", message.SubType)
assert.Equal(t, "U2147483697", message.User)
assert.Equal(t, "1433314126.000003", message.Timestamp)
assert.Equal(t, true, message.IsStarred)
}
示例10: TestChannelJoinInvitedMessage
func TestChannelJoinInvitedMessage(t *testing.T) {
message, err := unmarshalMessage(channelJoinInvitedMessage)
assert.Nil(t, err)
assert.NotNil(t, message)
assert.Equal(t, "message", message.Type)
assert.Equal(t, "channel_join", message.SubType)
assert.Equal(t, "1358877458.000011", message.Timestamp)
assert.Equal(t, "U2147483828", message.User)
assert.Equal(t, "<@U2147483828|cal> has joined the channel", message.Text)
assert.Equal(t, "U2147483829", message.Inviter)
}
示例11: TestMessageDeletedMessage
func TestMessageDeletedMessage(t *testing.T) {
message, err := unmarshalMessage(messageDeletedMessage)
assert.Nil(t, err)
assert.NotNil(t, message)
assert.Equal(t, "message", message.Type)
assert.Equal(t, "message_deleted", message.SubType)
assert.True(t, message.Hidden)
assert.Equal(t, "C2147483705", message.Channel)
assert.Equal(t, "1358878755.000001", message.Timestamp)
assert.Equal(t, "1358878749.000002", message.DeletedTimestamp)
}
示例12: TestGroupPurposeMessage
func TestGroupPurposeMessage(t *testing.T) {
message, err := unmarshalMessage(groupPurposeMessage)
assert.Nil(t, err)
assert.NotNil(t, message)
assert.Equal(t, "message", message.Type)
assert.Equal(t, "group_purpose", message.SubType)
assert.Equal(t, "1358877455.000010", message.Timestamp)
assert.Equal(t, "U2147483828", message.User)
assert.Equal(t, "whatever", message.Purpose)
assert.Equal(t, "<@U2147483828|cal> set the group purpose: whatever", message.Text)
}
示例13: TestPost
func TestPost(t *testing.T) {
message, err := unmarshalMessage(testPost)
assert.Nil(t, err)
assert.NotNil(t, message)
assert.Equal(t, "message", message.Type)
assert.Equal(t, "file_share", message.SubType)
assert.Equal(t, "<@U2147483697|tester> shared a file: <https://test.slack.com/files/tester/abc/test_post|test post>", message.Text)
// TODO: Assert File
assert.Equal(t, "U2147483697", message.User)
assert.False(t, message.Upload)
assert.Equal(t, "1433315416.000008", message.Timestamp)
}
示例14: TestChannelArchiveMessage
func TestChannelArchiveMessage(t *testing.T) {
message, err := unmarshalMessage(channelArchiveMessage)
assert.Nil(t, err)
assert.NotNil(t, message)
assert.Equal(t, "message", message.Type)
assert.Equal(t, "channel_archive", message.SubType)
assert.Equal(t, "1361482916.000003", message.Timestamp)
assert.Equal(t, "<U1234|@cal> archived the channel", message.Text)
assert.Equal(t, "U1234", message.User)
assert.NotNil(t, message.Members)
assert.Equal(t, 2, len(message.Members))
}
示例15: TestGroupNameMessage
func TestGroupNameMessage(t *testing.T) {
message, err := unmarshalMessage(groupNameMessage)
assert.Nil(t, err)
assert.NotNil(t, message)
assert.Equal(t, "message", message.Type)
assert.Equal(t, "group_name", message.SubType)
assert.Equal(t, "1358877455.000010", message.Timestamp)
assert.Equal(t, "U2147483828", message.User)
assert.Equal(t, "random", message.OldName)
assert.Equal(t, "watercooler", message.Name)
assert.Equal(t, "<@U2147483828|cal> has renamed the group from \"random\" to \"watercooler\"", message.Text)
}