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


Golang assert.True函數代碼示例

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


在下文中一共展示了True函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestSet

func TestSet(t *testing.T) {
	s := newStore()

	// Set /foo=""
	e, err := s.Set("/foo", false, "", Permanent)
	assert.Nil(t, err, "")
	assert.Equal(t, e.Action, "set", "")
	assert.Equal(t, e.Node.Key, "/foo", "")
	assert.False(t, e.Node.Dir, "")
	assert.Equal(t, e.Node.Value, "", "")
	assert.Nil(t, e.Node.Nodes, "")
	assert.Nil(t, e.Node.Expiration, "")
	assert.Equal(t, e.Node.TTL, 0, "")
	assert.Equal(t, e.Node.ModifiedIndex, uint64(1), "")

	// Set /foo="bar"
	e, err = s.Set("/foo", false, "bar", Permanent)
	assert.Nil(t, err, "")
	assert.Equal(t, e.Action, "set", "")
	assert.Equal(t, e.Node.Key, "/foo", "")
	assert.False(t, e.Node.Dir, "")
	assert.Equal(t, e.Node.Value, "bar", "")
	assert.Nil(t, e.Node.Nodes, "")
	assert.Nil(t, e.Node.Expiration, "")
	assert.Equal(t, e.Node.TTL, 0, "")
	assert.Equal(t, e.Node.ModifiedIndex, uint64(2), "")
	// check prevNode
	assert.NotNil(t, e.PrevNode, "")
	assert.Equal(t, e.PrevNode.Key, "/foo", "")
	assert.Equal(t, e.PrevNode.Value, "", "")
	assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(1), "")
	// Set /foo="baz" (for testing prevNode)
	e, err = s.Set("/foo", false, "baz", Permanent)
	assert.Nil(t, err, "")
	assert.Equal(t, e.Action, "set", "")
	assert.Equal(t, e.Node.Key, "/foo", "")
	assert.False(t, e.Node.Dir, "")
	assert.Equal(t, e.Node.Value, "baz", "")
	assert.Nil(t, e.Node.Nodes, "")
	assert.Nil(t, e.Node.Expiration, "")
	assert.Equal(t, e.Node.TTL, 0, "")
	assert.Equal(t, e.Node.ModifiedIndex, uint64(3), "")
	// check prevNode
	assert.NotNil(t, e.PrevNode, "")
	assert.Equal(t, e.PrevNode.Key, "/foo", "")
	assert.Equal(t, e.PrevNode.Value, "bar", "")
	assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(2), "")

	// Set /dir as a directory
	e, err = s.Set("/dir", true, "", Permanent)
	assert.Nil(t, err, "")
	assert.Equal(t, e.Action, "set", "")
	assert.Equal(t, e.Node.Key, "/dir", "")
	assert.True(t, e.Node.Dir, "")
	assert.Equal(t, e.Node.Value, "", "")
	assert.Nil(t, e.Node.Nodes, "")
	assert.Nil(t, e.Node.Expiration, "")
	assert.Equal(t, e.Node.TTL, 0, "")
	assert.Equal(t, e.Node.ModifiedIndex, uint64(4), "")
}
開發者ID:rwindelz,項目名稱:etcd,代碼行數:60,代碼來源:store_test.go

示例2: TestStoreCreateDirectory

// Ensure that the store can create a new directory if it doesn't already exist.
func TestStoreCreateDirectory(t *testing.T) {
	s := newStore()
	e, err := s.Create("/foo", true, "", false, Permanent)
	assert.Nil(t, err, "")
	assert.Equal(t, e.Action, "create", "")
	assert.Equal(t, e.Node.Key, "/foo", "")
	assert.True(t, e.Node.Dir, "")
}
開發者ID:rwindelz,項目名稱:etcd,代碼行數:9,代碼來源:store_test.go

示例3: TestConfigVersionFlag

// Ensures that the "version" flag can be parsed.
func TestConfigVersionFlag(t *testing.T) {
	c := New()
	assert.Nil(t, c.LoadFlags([]string{"-version"}), "")
	assert.True(t, c.ShowVersion)
}
開發者ID:RubanDeventhiran,項目名稱:etcd,代碼行數:6,代碼來源:config_test.go

示例4: TestConfigAbbreviatedForceFlag

// Ensures that the abbreviated "force config" flag can be parsed.
func TestConfigAbbreviatedForceFlag(t *testing.T) {
	c := New()
	assert.Nil(t, c.LoadFlags([]string{"-f"}), "")
	assert.True(t, c.Force)
}
開發者ID:RubanDeventhiran,項目名稱:etcd,代碼行數:6,代碼來源:config_test.go

示例5: TestConfigAbbreviatedHelpFlag

// Ensures that the abbreviated "help" flag can be parsed.
func TestConfigAbbreviatedHelpFlag(t *testing.T) {
	c := New()
	assert.Nil(t, c.LoadFlags([]string{"-h"}), "")
	assert.True(t, c.ShowHelp)
}
開發者ID:RubanDeventhiran,項目名稱:etcd,代碼行數:6,代碼來源:config_test.go


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