當前位置: 首頁>>代碼示例>>Golang>>正文


Golang assert.NotNil函數代碼示例

本文整理匯總了Golang中github.com/bfontaine/stargazer/Godeps/_workspace/src/github.com/stretchr/testify/assert.NotNil函數的典型用法代碼示例。如果您正苦於以下問題:Golang NotNil函數的具體用法?Golang NotNil怎麽用?Golang NotNil使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NotNil函數的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)
}
開發者ID:bfontaine,項目名稱:stargazer,代碼行數:34,代碼來源:slackutils_test.go

示例2: TestEditedMessage

func TestEditedMessage(t *testing.T) {
	message, err := unmarshalMessage(editedMessage)
	assert.Nil(t, err)
	assert.NotNil(t, message)
	assert.Equal(t, "message", message.Type)
	assert.Equal(t, "U2147483697", message.User)
	assert.Equal(t, "hello edited", message.Text)
	assert.NotNil(t, message.Edited)
	assert.Equal(t, "U2147483697", message.Edited.User)
	assert.Equal(t, "1433314416.000000", message.Edited.Timestamp)
	assert.Equal(t, "1433314408.000004", message.Timestamp)
}
開發者ID:bfontaine,項目名稱:stargazer,代碼行數:12,代碼來源:messages_test.go

示例3: TestGroupArchiveMessage

func TestGroupArchiveMessage(t *testing.T) {
	message, err := unmarshalMessage(groupArchiveMessage)
	assert.Nil(t, err)
	assert.NotNil(t, message)
	assert.Equal(t, "message", message.Type)
	assert.Equal(t, "group_archive", message.SubType)
	assert.Equal(t, "1361482916.000003", message.Timestamp)
	assert.Equal(t, "<U1234|@cal> archived the group", message.Text)
	assert.Equal(t, "U1234", message.User)
	assert.NotNil(t, message.Members)
	assert.Equal(t, 2, len(message.Members))
}
開發者ID:bfontaine,項目名稱:stargazer,代碼行數:12,代碼來源:messages_test.go

示例4: TestFileShareMessage

func TestFileShareMessage(t *testing.T) {
	message, err := unmarshalMessage(fileShareMessage)
	fmt.Println(err)
	assert.Nil(t, err)
	assert.NotNil(t, message)
	assert.Equal(t, "message", message.Type)
	assert.Equal(t, "file_share", message.SubType)
	assert.Equal(t, "1358877455.000010", message.Timestamp)
	assert.Equal(t, "<@cal> uploaded a file: <https:...7.png|7.png>", message.Text)
	assert.Equal(t, "U2147483697", message.User)
	assert.True(t, message.Upload)
	assert.NotNil(t, message.File)
}
開發者ID:bfontaine,項目名稱:stargazer,代碼行數:13,代碼來源:messages_test.go

示例5: TestBotMessage

func TestBotMessage(t *testing.T) {
	message, err := unmarshalMessage(botMessage)
	assert.Nil(t, err)
	assert.NotNil(t, message)
	assert.Equal(t, "message", message.Type)
	assert.Equal(t, "bot_message", message.SubType)
	assert.Equal(t, "1358877455.000010", message.Timestamp)
	assert.Equal(t, "Pushing is the answer", message.Text)
	assert.Equal(t, "BB12033", message.BotID)
	assert.Equal(t, "github", message.Username)
	assert.NotNil(t, message.Icons)
	assert.Empty(t, message.Icons.IconURL)
	assert.Empty(t, message.Icons.IconEmoji)
}
開發者ID:bfontaine,項目名稱:stargazer,代碼行數:14,代碼來源:messages_test.go

示例6: TestMessageChangedMessage

func TestMessageChangedMessage(t *testing.T) {
	message, err := unmarshalMessage(messageChangedMessage)
	assert.Nil(t, err)
	assert.NotNil(t, message)
	assert.Equal(t, "message", message.Type)
	assert.Equal(t, "message_changed", message.SubType)
	assert.True(t, message.Hidden)
	assert.Equal(t, "C2147483705", message.Channel)
	assert.NotNil(t, message.SubMessage)
	assert.Equal(t, "message", message.SubMessage.Type)
	assert.Equal(t, "U2147483697", message.SubMessage.User)
	assert.Equal(t, "Hello, world!", message.SubMessage.Text)
	assert.Equal(t, "1355517523.000005", message.SubMessage.Timestamp)
	assert.NotNil(t, message.SubMessage.Edited)
	assert.Equal(t, "U2147483697", message.SubMessage.Edited.User)
	assert.Equal(t, "1358878755.000001", message.SubMessage.Edited.Timestamp)
	assert.Equal(t, "1358878755.000001", message.Timestamp)
}
開發者ID:bfontaine,項目名稱:stargazer,代碼行數:18,代碼來源:messages_test.go

示例7: 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)
}
開發者ID:bfontaine,項目名稱:stargazer,代碼行數:10,代碼來源:messages_test.go

示例8: 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)
}
開發者ID:bfontaine,項目名稱:stargazer,代碼行數:10,代碼來源:messages_test.go

示例9: 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)
}
開發者ID:bfontaine,項目名稱:stargazer,代碼行數:10,代碼來源:messages_test.go

示例10: TestChannelUnarchiveMessage

func TestChannelUnarchiveMessage(t *testing.T) {
	message, err := unmarshalMessage(channelUnarchiveMessage)
	assert.Nil(t, err)
	assert.NotNil(t, message)
	assert.Equal(t, "message", message.Type)
	assert.Equal(t, "channel_unarchive", message.SubType)
	assert.Equal(t, "1361482916.000003", message.Timestamp)
	assert.Equal(t, "<U1234|@cal> un-archived the channel", message.Text)
	assert.Equal(t, "U1234", message.User)
}
開發者ID:bfontaine,項目名稱:stargazer,代碼行數:10,代碼來源:messages_test.go

示例11: assertSimpleIM

func assertSimpleIM(t *testing.T, im *IM) {
	assert.NotNil(t, im)
	assert.Equal(t, "D024BFF1M", im.ID)
	assert.Equal(t, true, im.IsIM)
	assert.Equal(t, JSONTime(1360782804), im.Created)
	assert.Equal(t, false, im.IsUserDeleted)
	assert.Equal(t, true, im.IsOpen)
	assert.Equal(t, "1401383885.000061", im.LastRead)
	assert.Equal(t, 0, im.UnreadCount)
	assert.Equal(t, 0, im.UnreadCountDisplay)
}
開發者ID:bfontaine,項目名稱:stargazer,代碼行數:11,代碼來源:conversation_test.go

示例12: 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)
}
開發者ID:bfontaine,項目名稱:stargazer,代碼行數:11,代碼來源:messages_test.go

示例13: 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)
}
開發者ID:bfontaine,項目名稱:stargazer,代碼行數:11,代碼來源:messages_test.go

示例14: 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)
}
開發者ID:bfontaine,項目名稱:stargazer,代碼行數:11,代碼來源:messages_test.go

示例15: 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)
}
開發者ID:bfontaine,項目名稱:stargazer,代碼行數:11,代碼來源:messages_test.go


注:本文中的github.com/bfontaine/stargazer/Godeps/_workspace/src/github.com/stretchr/testify/assert.NotNil函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。