本文整理匯總了Golang中github.com/facebookgo/ensure.False函數的典型用法代碼示例。如果您正苦於以下問題:Golang False函數的具體用法?Golang False怎麽用?Golang False使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了False函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestCmdScoreLess
func TestCmdScoreLess(t *testing.T) {
t.Parallel()
scores := cmdScores([]cmdScore{
{levenshtein: 1, jaroWinkler: 0.9},
{levenshtein: 2, jaroWinkler: 0.8},
})
ensure.True(t, scores.Less(0, 1))
scores = cmdScores([]cmdScore{
{levenshtein: 1, jaroWinkler: 0.9},
{levenshtein: 1, jaroWinkler: 0.8},
})
ensure.True(t, scores.Less(0, 1))
scores = cmdScores([]cmdScore{
{levenshtein: 1, jaroWinkler: 0.8},
{levenshtein: 1, jaroWinkler: 0.9},
})
ensure.False(t, scores.Less(0, 1))
scores = cmdScores([]cmdScore{
{levenshtein: 2, jaroWinkler: 0.9},
{levenshtein: 1, jaroWinkler: 0.8},
})
ensure.False(t, scores.Less(0, 1))
}
示例2: TestShouldFilterOp
func TestShouldFilterOp(t *testing.T) {
t.Parallel()
ensure.True(t, shouldFilterOp(&Op{Type: Update}, []OpType{Update}))
ensure.True(t, shouldFilterOp(&Op{Type: Update}, []OpType{Update, Query}))
ensure.True(t, shouldFilterOp(&Op{Type: Query}, []OpType{Update, Query}))
ensure.False(t, shouldFilterOp(&Op{Type: Command}, []OpType{Update, Query}))
ensure.False(t, shouldFilterOp(&Op{Type: Command}, []OpType{}))
}
示例3: TestIsFileName
func TestIsFileName(t *testing.T) {
t.Parallel()
ensure.True(t, isFilename("file"))
ensure.True(t, isFilename("star\\*"))
ensure.True(t, isFilename("bracket\\["))
ensure.True(t, isFilename("question\\?"))
ensure.False(t, isFilename("*"))
ensure.False(t, isFilename("?"))
ensure.False(t, isFilename("["))
}
示例4: TestCancelRequest
func TestCancelRequest(t *testing.T) {
var called bool
timer := time.AfterFunc(time.Hour, func() { called = true })
var r Transport
r.CancelRequest(&http.Request{
Body: &bodyCloser{
timer: timer,
},
})
ensure.False(t, called)
ensure.False(t, timer.Stop())
}
示例5: TestAcceptsPath
func TestAcceptsPath(t *testing.T) {
t.Parallel()
i := iosSymbolUploader{Path: testDwarfPath}
ensure.True(t, i.acceptsPath())
i.Path = ""
ensure.False(t, i.acceptsPath())
}
示例6: CheckOpsReader
// Verify if the items being read are as expected.
func CheckOpsReader(t *testing.T, loader OpsReader) {
expectedOpsRead := 0
const startingTs = 1396456709420
for op := loader.Next(); op != nil; op = loader.Next() {
expectedOpsRead += 1
ensure.NotNil(t, op)
ensure.DeepEqual(t, loader.OpsRead(), expectedOpsRead)
// check the "ts" field
CheckTime(t, float64(startingTs+loader.OpsRead()), op.Timestamp)
// check the insert doc
// certain key exists
for i := 1; i <= 5; i++ {
logTypeKey := fmt.Sprintf("logType%d", i)
logType, ok := GetElem(op.InsertDoc, logTypeKey)
if i != expectedOpsRead {
ensure.False(t, ok)
ensure.Nil(t, logType)
} else {
ensure.True(t, ok)
ensure.NotNil(t, logType)
}
}
// check the value for the shared key
message := fmt.Sprintf("m%d", expectedOpsRead)
actualMessage, ok := GetElem(op.InsertDoc, "message")
ensure.True(t, ok)
ensure.DeepEqual(t, actualMessage.(string), message)
}
ensure.DeepEqual(t, expectedOpsRead, 5)
}
示例7: TestCheckExistingWithoutDesiredBindsWithRemoveExisting
func TestCheckExistingWithoutDesiredBindsWithRemoveExisting(t *testing.T) {
const imageID = "ii1"
const imageName = "in1"
container := &Container{
removeExisting: true,
containerConfig: &dockerclient.ContainerConfig{
Image: imageName,
},
hostConfig: &dockerclient.HostConfig{
Binds: []string{"a:b"},
},
}
client := &mockClient{
listImages: func() ([]*dockerclient.Image, error) {
return []*dockerclient.Image{
{
RepoTags: []string{imageName},
Id: imageID,
},
}, nil
},
}
ci := &dockerclient.ContainerInfo{
Image: imageID,
Id: "y",
Config: &dockerclient.ContainerConfig{},
Volumes: map[string]string{"a": "d"},
}
ok, err := container.checkExisting(client, ci)
ensure.Nil(t, err)
ensure.False(t, ok)
}
示例8: TestCheckExistingWithoutDesiredBinds
func TestCheckExistingWithoutDesiredBinds(t *testing.T) {
const imageID = "ii1"
const imageName = "in1"
container := &Container{
containerConfig: &dockerclient.ContainerConfig{
Image: imageName,
},
hostConfig: &dockerclient.HostConfig{
Binds: []string{"a:b"},
},
}
client := &mockClient{
listImages: func() ([]*dockerclient.Image, error) {
return []*dockerclient.Image{
{
RepoTags: []string{imageName},
Id: imageID,
},
}, nil
},
}
ci := &dockerclient.ContainerInfo{
Image: imageID,
Id: "y",
Config: &dockerclient.ContainerConfig{},
}
ok, err := container.checkExisting(client, ci)
ensure.Err(t, err, regexp.MustCompile("but desired volumes are"))
ensure.False(t, ok)
}
示例9: TestCheckExistingWithoutDesiredImageWithRemoveExisting
func TestCheckExistingWithoutDesiredImageWithRemoveExisting(t *testing.T) {
const image = "x"
container := &Container{
containerConfig: &dockerclient.ContainerConfig{
Image: image,
},
removeExisting: true,
}
client := &mockClient{
listImages: func() ([]*dockerclient.Image, error) {
return []*dockerclient.Image{
{
RepoTags: []string{image},
Id: "y",
},
}, nil
},
}
ci := &dockerclient.ContainerInfo{
Image: "z",
Id: "y",
}
ok, err := container.checkExisting(client, ci)
ensure.Nil(t, err)
ensure.False(t, ok)
}
示例10: TestWriteBatchIterator
func TestWriteBatchIterator(t *testing.T) {
db := newTestDB(t, "TestWriteBatchIterator", nil)
defer db.Close()
var (
givenKey1 = []byte("key1")
givenVal1 = []byte("val1")
givenKey2 = []byte("key2")
)
// create and fill the write batch
wb := NewWriteBatch()
defer wb.Destroy()
wb.Put(givenKey1, givenVal1)
wb.Delete(givenKey2)
ensure.DeepEqual(t, wb.Count(), 2)
// iterate over the batch
iter := wb.NewIterator()
ensure.True(t, iter.Next())
record := iter.Record()
ensure.DeepEqual(t, record.Type, WriteBatchRecordTypeValue)
ensure.DeepEqual(t, record.Key, givenKey1)
ensure.DeepEqual(t, record.Value, givenVal1)
ensure.True(t, iter.Next())
record = iter.Record()
ensure.DeepEqual(t, record.Type, WriteBatchRecordTypeDeletion)
ensure.DeepEqual(t, record.Key, givenKey2)
// there shouldn't be any left
ensure.False(t, iter.Next())
}
示例11: TestGetElem
func TestGetElem(t *testing.T) {
doc := bson.D{{"a", 1}}
value, exists := GetElem(doc, "a")
ensure.True(t, exists)
ensure.DeepEqual(t, value.(int), 1)
value, exists = GetElem(doc, "b")
ensure.False(t, exists)
ensure.Nil(t, value)
}
示例12: TestFunctionHookExists
func TestFunctionHookExists(t *testing.T) {
t.Parallel()
h := newFunctionsHarness(t)
c := &configureCmd{}
exists, err := c.functionHookExists(h.env, "foo")
ensure.Nil(t, err)
ensure.True(t, exists)
exists, err = c.functionHookExists(h.env, "bar")
ensure.Nil(t, err)
ensure.False(t, exists)
}
示例13: TestTriggerHookExists
func TestTriggerHookExists(t *testing.T) {
t.Parallel()
h := newTriggersHarness(t)
c := &configureCmd{}
exists, err := c.triggerHookExists(h.env, "foo", "beforeSave")
ensure.Nil(t, err)
ensure.True(t, exists)
exists, err = c.triggerHookExists(h.env, "bar", "other")
ensure.Nil(t, err)
ensure.False(t, exists)
}
示例14: TestPruneEmptyKeys
func TestPruneEmptyKeys(t *testing.T) {
t.Parallel()
// Check findAndModify and update structures to ensure nil $unsets are removed
testOps := []Op{
Op{
Ns: "foo.bar",
Timestamp: time.Unix(1396457119, int64(032*time.Millisecond)),
Type: Update,
QueryDoc: bson.D{{"_id", "foo"}},
UpdateDoc: bson.D{{"$set", bson.D{{"a", 1}}}, {"$unset", bson.D{}}},
},
Op{
Ns: "foo.$cmd",
Timestamp: time.Unix(1396457119, int64(032*time.Millisecond)),
Type: Command,
CommandDoc: bson.D{
{"findandmodify", "bar"},
{"query", bson.D{{"_id", "foo"}}},
{"update", bson.D{{"$set", bson.D{{"b", 1}}}, {"$unset", bson.D{}}}},
},
},
}
reader := newMockOpsStreamReader(t, testOps)
err, loader := NewByLineOpsReader(reader, logger, "")
ensure.Nil(t, err)
for op := loader.Next(); op != nil; op = loader.Next() {
if op.Type == Command {
updateDoc, ok := GetElem(op.CommandDoc, "update")
ensure.True(t, ok)
_, found := GetElem(updateDoc.(bson.D), "$unset")
ensure.False(t, found)
} else if op.Type == Update {
_, found := GetElem(op.UpdateDoc, "$unset")
ensure.False(t, found)
}
}
}
示例15: TestCheckExistingImageIdentifyError
func TestCheckExistingImageIdentifyError(t *testing.T) {
givenErr := errors.New("")
const image = "x"
container := &Container{
containerConfig: &dockerclient.ContainerConfig{
Image: image,
},
}
client := &mockClient{
listImages: func() ([]*dockerclient.Image, error) {
return nil, givenErr
},
}
ok, err := container.checkExisting(client, &dockerclient.ContainerInfo{Image: "z"})
ensure.True(t, stackerr.HasUnderlying(err, stackerr.Equals(givenErr)))
ensure.False(t, ok)
}