本文整理汇总了Golang中github.com/stretchr/testify/assert.False函数的典型用法代码示例。如果您正苦于以下问题:Golang False函数的具体用法?Golang False怎么用?Golang False使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了False函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestReadDirTrailingSlash
func TestReadDirTrailingSlash(t *testing.T) {
client := getClient(t)
mkdirp(t, "/_test/fulldir2")
mkdirp(t, "/_test/fulldir2/dir")
touch(t, "/_test/fulldir2/1")
touch(t, "/_test/fulldir2/2")
touch(t, "/_test/fulldir2/3")
res, err := client.ReadDir("/_test/fulldir2/")
require.NoError(t, err)
require.Equal(t, len(res), 4)
assert.EqualValues(t, "1", res[0].Name())
assert.False(t, res[0].IsDir())
assert.EqualValues(t, "2", res[1].Name())
assert.False(t, res[1].IsDir())
assert.EqualValues(t, "3", res[2].Name())
assert.False(t, res[2].IsDir())
assert.EqualValues(t, "dir", res[3].Name())
assert.True(t, res[3].IsDir())
}
示例2: TestSearchService_Code
func TestSearchService_Code(t *testing.T) {
setup()
defer tearDown()
stubGet(t, "/search/code", "code_search", nil)
searchResults, result := client.Search().Code(nil, M{
"query": "addClass in:file language:js repo:jquery/jquery"})
assert.False(t, result.HasError())
assert.False(t, searchResults.IncompleteResults)
assert.Equal(t, 7, searchResults.TotalCount)
assert.Equal(t, 7, len(searchResults.Items))
assert.EqualValues(t, "classes.js", searchResults.Items[0].Name)
assert.EqualValues(t, "src/attributes/classes.js", searchResults.Items[0].Path)
assert.EqualValues(t,
"f9dba94f7de43d6b6b7256e05e0d17c4741a4cde", searchResults.Items[0].SHA)
assert.EqualValues(t,
"https://api.github.com/repositories/167174/contents/src/attributes/classes.js?ref=53aa87f3bf4284763405f3eb8affff296e55ba4f", string(searchResults.Items[0].URL))
assert.EqualValues(t,
"https://api.github.com/repositories/167174/git/blobs/f9dba94f7de43d6b6b7256e05e0d17c4741a4cde", searchResults.Items[0].GitURL)
assert.EqualValues(t,
"https://github.com/jquery/jquery/blob/53aa87f3bf4284763405f3eb8affff296e55ba4f/src/attributes/classes.js", searchResults.Items[0].HTMLURL)
assert.Equal(t, 167174, searchResults.Items[0].Repository.ID)
assert.EqualValues(t,
"jquery/jquery", searchResults.Items[0].Repository.FullName)
}
示例3: TestRunAndStopGracefully
func TestRunAndStopGracefully(t *testing.T) {
d1 := &mockDaemon{}
d2 := &mockDaemon{}
h := &Hydre{
Timeout: 1,
Daemons: []Service{d1, d2},
}
go h.Run()
time.Sleep(100 * time.Millisecond)
assert.True(t, d1.IsStarted())
assert.False(t, d1.IsStopped())
assert.False(t, d1.IsKilled())
assert.True(t, d2.IsStarted())
assert.False(t, d2.IsStopped())
assert.False(t, d2.IsKilled())
require.NotNil(t, d1.StopNotifier)
d1.StopNotifier <- "stop daemon 1"
time.Sleep(700 * time.Millisecond)
assert.True(t, d1.IsStarted())
assert.True(t, d1.IsStopped())
assert.True(t, d1.IsKilled())
assert.True(t, d2.IsStarted())
assert.True(t, d2.IsStopped())
assert.True(t, d2.IsKilled())
}
示例4: TestDefaultConfig
func TestDefaultConfig(t *testing.T) {
assert := assert.New(t)
config := DefaultConfig()
assert.False(config.SSL.Enabled)
assert.False(config.Ldap.Enabled)
}
示例5: TestStoreCreateValue
// Ensure that the store can create a new key if it doesn't already exist.
func TestStoreCreateValue(t *testing.T) {
s := newStore()
// Create /foo=bar
e, err := s.Create("/foo", false, "bar", false, Permanent)
assert.Nil(t, err, "")
assert.Equal(t, e.Action, "create", "")
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(1), "")
// Create /empty=""
e, err = s.Create("/empty", false, "", false, Permanent)
assert.Nil(t, err, "")
assert.Equal(t, e.Action, "create", "")
assert.Equal(t, e.Node.Key, "/empty", "")
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(2), "")
}
示例6: TestHttpParser_splitResponse_midHeaderName
func TestHttpParser_splitResponse_midHeaderName(t *testing.T) {
http := httpModForTests()
http.parserConfig.sendHeaders = true
http.parserConfig.sendAllHeaders = true
data1 := "HTTP/1.1 200 OK\r\n" +
"Date: Tue, 14 Aug 2012 22:31:45 GMT\r\n" +
"Expires: -1\r\n" +
"Cache-Control: private, max-age=0\r\n" +
"Content-Type: text/html; charset=UTF-8\r\n" +
"Content-En"
data2 := "coding: gzip\r\n" +
"Server: gws\r\n" +
"Content-Length: 0\r\n" +
"X-XSS-Protection: 1; mode=block\r\n" +
"X-Frame-Options: SAMEORIGIN\r\n" +
"\r\n"
tp := newTestParser(http, data1, data2)
_, ok, complete := tp.parse()
assert.True(t, ok)
assert.False(t, complete)
message, ok, complete := tp.parse()
assert.True(t, ok)
assert.True(t, complete)
assert.False(t, message.isRequest)
assert.Equal(t, 200, int(message.statusCode))
assert.Equal(t, "OK", string(message.statusPhrase))
assert.True(t, isVersion(message.version, 1, 1))
assert.Equal(t, 262, int(message.size))
assert.Equal(t, 0, message.contentLength)
}
示例7: TestEmailsService_All
func TestEmailsService_All(t *testing.T) {
setup()
defer tearDown()
link := fmt.Sprintf(`<%s>; rel="next", <%s>; rel="last"`, testURLOf("/user/emails?page=2"), testURLOf("/user/emails?page=3"))
respHeaderParams := map[string]string{"Link": link}
stubGet(t, "/user/emails", "emails", respHeaderParams)
url, _ := EmailUrl.Expand(nil)
allEmails, result := client.Emails(url).All()
assert.False(t, result.HasError())
assert.Len(t, allEmails, 1)
email := allEmails[0]
assert.Equal(t, "[email protected]", email.Email)
assert.Equal(t, true, email.Verified)
assert.Equal(t, true, email.Primary)
assert.Equal(t, testURLStringOf("/user/emails?page=2"), string(*result.NextPage))
assert.Equal(t, testURLStringOf("/user/emails?page=3"), string(*result.LastPage))
nextPageURL, err := result.NextPage.Expand(nil)
assert.NoError(t, err)
allEmails, result = client.Emails(nextPageURL).All()
assert.False(t, result.HasError())
assert.Len(t, allEmails, 1)
}
示例8: TestAfterRetryRefreshCreds
func TestAfterRetryRefreshCreds(t *testing.T) {
os.Clearenv()
credProvider := &mockCredsProvider{}
svc := awstesting.NewClient(&aws.Config{
Credentials: credentials.NewCredentials(credProvider),
MaxRetries: aws.Int(1),
})
svc.Handlers.Clear()
svc.Handlers.ValidateResponse.PushBack(func(r *request.Request) {
r.Error = awserr.New("UnknownError", "", nil)
r.HTTPResponse = &http.Response{StatusCode: 400}
})
svc.Handlers.UnmarshalError.PushBack(func(r *request.Request) {
r.Error = awserr.New("ExpiredTokenException", "", nil)
})
svc.Handlers.AfterRetry.PushBackNamed(corehandlers.AfterRetryHandler)
assert.True(t, svc.Config.Credentials.IsExpired(), "Expect to start out expired")
assert.False(t, credProvider.retrieveCalled)
req := svc.NewRequest(&request.Operation{Name: "Operation"}, nil, nil)
req.Send()
assert.True(t, svc.Config.Credentials.IsExpired())
assert.False(t, credProvider.retrieveCalled)
_, err := svc.Config.Credentials.Get()
assert.NoError(t, err)
assert.True(t, credProvider.retrieveCalled)
}
示例9: TestFilter
func TestFilter(t *testing.T) {
assert := assert.New(t)
str := "This is a topic string"
filters0 := []Filter{}
assert.True(filteredAny(str, filters0))
filters1 := []Filter{""}
assert.True(filteredAny(str, filters1))
filters2 := []Filter{"This"}
assert.True(filteredAny(str, filters2))
filters3 := []Filter{"this is"}
assert.True(filteredAny(str, filters3))
filters4 := []Filter{"this is", "topic"}
assert.True(filteredAny(str, filters4))
filters5 := []Filter{"this is", "other string"}
assert.True(filteredAny(str, filters5))
filters6 := []Filter{"not"}
assert.False(filteredAny(str, filters6))
filters7 := []Filter{"not", "appear"}
assert.False(filteredAny(str, filters7))
}
示例10: TestCheckLevel
func TestCheckLevel(t *testing.T) {
logger := DefaultLogger()
SetDefaultLogLevel(ERROR)
assert.True(t, logger.CheckLevel(ERROR, nil), "Error should be valid when level set to Error")
assert.False(t, logger.CheckLevel(WARN, nil), "Warning should not be valid when level set to Error")
assert.False(t, logger.CheckLevel(INFO, nil), "Info should not be valid when level set to Error")
assert.False(t, logger.CheckLevel(DEBUG, nil), "Debug should not be valid when level set to Error")
assert.False(t, logger.CheckLevel(VERBOSE, nil), "Verbose should not be valid when level set to Error")
SetDefaultLogLevel(WARN)
assert.True(t, logger.CheckLevel(ERROR, nil), "Error should be valid when level set to Warn")
assert.True(t, logger.CheckLevel(WARN, nil), "Warning should be valid when level set to Warn")
assert.False(t, logger.CheckLevel(INFO, nil), "Info should not be valid when level set to Warn")
assert.False(t, logger.CheckLevel(DEBUG, nil), "Debug should not be valid when level set to Warn")
assert.False(t, logger.CheckLevel(VERBOSE, nil), "Verbose should not be valid when level set to Warn")
SetDefaultLogLevel(INFO)
assert.True(t, logger.CheckLevel(ERROR, nil), "Error should be valid when level set to Info")
assert.True(t, logger.CheckLevel(WARN, nil), "Warning should be valid when level set to Info")
assert.True(t, logger.CheckLevel(INFO, nil), "Info should be valid when level set to Info")
assert.False(t, logger.CheckLevel(DEBUG, nil), "Debug should not be valid when level set to Info")
assert.False(t, logger.CheckLevel(VERBOSE, nil), "Verbose should not be valid when level set to Info")
SetDefaultLogLevel(DEBUG)
assert.True(t, logger.CheckLevel(ERROR, nil), "Error should be valid when level set to Debug")
assert.True(t, logger.CheckLevel(WARN, nil), "Warning should be valid when level set to Debug")
assert.True(t, logger.CheckLevel(INFO, nil), "Info should be valid when level set to Debug")
assert.True(t, logger.CheckLevel(DEBUG, nil), "Debug should be valid when level set to Debug")
assert.False(t, logger.CheckLevel(VERBOSE, nil), "Verbose should not be valid when level set to Debug")
SetDefaultLogLevel(VERBOSE)
assert.True(t, logger.CheckLevel(VERBOSE, nil), "Verbose should be valid when level set to Verbose")
}
示例11: TestClearHighestLowest
func TestClearHighestLowest(t *testing.T) {
ba := newBitArray(10)
ba.SetBit(5)
ba.ClearBit(5)
assert.False(t, ba.anyset)
assert.Equal(t, uint64(0), ba.lowest)
assert.Equal(t, uint64(0), ba.highest)
ba.SetBit(3)
ba.SetBit(5)
ba.SetBit(7)
ba.ClearBit(7)
assert.True(t, ba.anyset)
assert.Equal(t, uint64(5), ba.highest)
assert.Equal(t, uint64(3), ba.lowest)
ba.SetBit(7)
ba.ClearBit(3)
assert.True(t, ba.anyset)
assert.Equal(t, uint64(5), ba.lowest)
assert.Equal(t, uint64(7), ba.highest)
ba.ClearBit(7)
assert.True(t, ba.anyset)
assert.Equal(t, uint64(5), ba.lowest)
assert.Equal(t, uint64(5), ba.highest)
ba.ClearBit(5)
assert.False(t, ba.anyset)
assert.Equal(t, uint64(0), ba.lowest)
assert.Equal(t, uint64(0), ba.highest)
}
示例12: TestContextInvalidResponseFormat
func TestContextInvalidResponseFormat(t *testing.T) {
ct := "application/x-yaml"
other := "application/sgml"
spec, api := petstore.NewAPI(t)
ctx := NewContext(spec, api, nil)
ctx.router = DefaultRouter(spec, ctx.api)
request, _ := http.NewRequest("GET", "http://localhost:8080", nil)
request.Header.Set(httpkit.HeaderAccept, ct)
// check there's nothing there
cached, ok := context.GetOk(request, ctxResponseFormat)
assert.False(t, ok)
assert.Empty(t, cached)
// trigger the parse
mt := ctx.ResponseFormat(request, []string{other})
assert.Empty(t, mt)
// check it was cached
cached, ok = context.GetOk(request, ctxResponseFormat)
assert.False(t, ok)
assert.Empty(t, cached)
// check if the cast works and fetch from cache too
mt = ctx.ResponseFormat(request, []string{other})
assert.Empty(t, mt)
}
示例13: TestIsHijacked
func TestIsHijacked(t *testing.T) {
//t.SkipNow()
assert.False(t, IsHijacked(nil))
assert.False(t, IsHijacked(errors.New("Foo")))
assert.True(t, IsHijacked(newErrorCode(ErrHijacked, "hijacked")))
assert.True(t, IsHijacked(Hijacked))
}
示例14: TestUserHasAccess
func TestUserHasAccess(t *testing.T) {
f := FeatureFlag{
Key: "foo",
Enabled: false,
Users: []uint32{42},
Groups: []string{},
Percentage: 20,
}
// Make sure the feature is not enabled
assert.False(t, f.IsEnabled())
assert.True(t, f.UserHasAccess(42))
assert.False(t, f.UserHasAccess(1337))
f.Users = []uint32{42, 1337}
assert.True(t, f.UserHasAccess(1337))
f.Enabled = true
assert.True(t, f.UserHasAccess(222))
f.Users = []uint32{}
f.Percentage = 100
f.Enabled = false
assert.True(t, f.UserHasAccess(222))
}
示例15: TestValidateDomain
func TestValidateDomain(t *testing.T) {
assert.False(t, ValidateDomainPart(strings.Repeat("a", 256)),
"Max domain length is 255")
assert.False(t, ValidateDomainPart(strings.Repeat("a", 64)+".com"),
"Max label length is 63")
assert.True(t, ValidateDomainPart(strings.Repeat("a", 63)+".com"),
"Should allow 63 char label")
var testTable = []struct {
input string
expect bool
msg string
}{
{"", false, "Empty domain is not valid"},
{"hostname", true, "Just a hostname is valid"},
{"github.com", true, "Two labels should be just fine"},
{"my-domain.com", true, "Hyphen is allowed mid-label"},
{"_domainkey.foo.com", true, "Underscores are allowed"},
{"bar.com.", true, "Must be able to end with a dot"},
{"ABC.6DBS.com", true, "Mixed case is OK"},
{"mail.123.com", true, "Number only label valid"},
{"123.com", true, "Number only label valid"},
{"google..com", false, "Double dot not valid"},
{".foo.com", false, "Cannot start with a dot"},
{"google\r.com", false, "Special chars not allowed"},
{"foo.-bar.com", false, "Label cannot start with hyphen"},
{"foo-.bar.com", false, "Label cannot end with hyphen"},
}
for _, tt := range testTable {
if ValidateDomainPart(tt.input) != tt.expect {
t.Errorf("Expected %v for %q: %s", tt.expect, tt.input, tt.msg)
}
}
}