本文整理汇总了Golang中github.com/bmizerany/assert.T函数的典型用法代码示例。如果您正苦于以下问题:Golang T函数的具体用法?Golang T怎么用?Golang T使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了T函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestExecHaving
func TestExecHaving(t *testing.T) {
sqlText := `
select
user_id, count(user_id) AS order_ct
FROM orders
GROUP BY user_id
HAVING order_ct > 1
`
ctx := td.TestContext(sqlText)
job, err := exec.BuildSqlJob(ctx)
assert.Tf(t, err == nil, "no error %v", err)
msgs := make([]schema.Message, 0)
resultWriter := exec.NewResultBuffer(ctx, &msgs)
job.RootTask.Add(resultWriter)
err = job.Setup()
assert.T(t, err == nil)
err = job.Run()
time.Sleep(time.Millisecond * 10)
assert.Tf(t, err == nil, "no error %v", err)
assert.Tf(t, len(msgs) == 1, "should have filtered HAVING orders into 1 users %v", len(msgs))
u.Debugf("msg: %#v", msgs[0])
row := msgs[0].(*datasource.SqlDriverMessageMap).Values()
u.Debugf("row: %#v", row)
assert.Tf(t, len(row) == 2, "expects 2 cols but got %v", len(row))
assert.T(t, row[0] == "9Ip1aKbeZe2njCDM")
// I really don't like this float behavior?
assert.Tf(t, int(row[1].(int64)) == 2, "expected 2 orders for %v", row)
}
示例2: DoTestStoreRelPath
func DoTestStoreRelPath(t *testing.T, repo fs.NodeRepo) {
tg := treegen.New()
treeSpec := tg.D("foo", tg.F("bar", tg.B(42, 65537)))
path := treegen.TestTree(t, treeSpec)
defer os.RemoveAll(path)
store, err := fs.NewLocalStore(path, repo)
assert.T(t, err == nil)
relFoo := store.RelPath(filepath.Join(path, "foo"))
assert.Equalf(t, "foo", relFoo, "'%v': not a foo", relFoo)
// Relocate bar
newBar, err := store.Relocate(filepath.Join(filepath.Join(path, "foo"), "bar"))
assert.T(t, err == nil)
// new bar's parent should still be foo
newBarParent, _ := filepath.Split(newBar)
newBarParent = strings.TrimRight(newBarParent, "/\\")
// old bar should not exist
_, err = os.Stat(filepath.Join(filepath.Join(path, "foo"), "bar"))
assert.T(t, err != nil)
foobar := filepath.Join("foo", "bar")
assert.Equal(t, newBar, store.Resolve(foobar), "reloc path %s != resolve foo/bar %s",
newBar, store.Resolve(foobar))
}
示例3: TestDoozerWaitSimple
func TestDoozerWaitSimple(t *testing.T) {
l := mustListen()
defer l.Close()
u := mustListenUDP(l.Addr().String())
defer u.Close()
go Main("a", "X", "", "", "", nil, u, l, nil, 1e9, 2e9, 3e9, 101)
cl := dial(l.Addr().String())
var rev int64 = 1
cl.Set("/test/foo", store.Clobber, []byte("bar"))
ev, err := cl.Wait("/test/**", rev)
assert.Equal(t, nil, err)
assert.Equal(t, "/test/foo", ev.Path)
assert.Equal(t, []byte("bar"), ev.Body)
assert.T(t, ev.IsSet())
rev = ev.Rev + 1
cl.Set("/test/fun", store.Clobber, []byte("house"))
ev, err = cl.Wait("/test/**", rev)
assert.Equal(t, nil, err)
assert.Equal(t, "/test/fun", ev.Path)
assert.Equal(t, []byte("house"), ev.Body)
assert.T(t, ev.IsSet())
rev = ev.Rev + 1
cl.Del("/test/foo", store.Clobber)
ev, err = cl.Wait("/test/**", rev)
assert.Equal(t, nil, err)
assert.Equal(t, "/test/foo", ev.Path)
assert.T(t, ev.IsDel())
}
示例4: TestAuthorizationsService_All
func TestAuthorizationsService_All(t *testing.T) {
setup()
defer tearDown()
mux.HandleFunc("/authorizations", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
respondWithJSON(w, loadFixture("authorizations.json"))
})
url, err := AuthorizationsURL.Expand(nil)
assert.Equal(t, nil, err)
auths, result := client.Authorizations(url).All()
assert.T(t, !result.HasError())
firstAuth := auths[0]
assert.Equal(t, 1, firstAuth.ID)
assert.Equal(t, "https://api.github.com/authorizations/1", firstAuth.URL)
assert.Equal(t, "456", firstAuth.Token)
assert.Equal(t, "", firstAuth.Note)
assert.Equal(t, "", firstAuth.NoteURL)
assert.Equal(t, "2012-11-16 01:05:51 +0000 UTC", firstAuth.CreatedAt.String())
assert.Equal(t, "2013-08-21 03:29:51 +0000 UTC", firstAuth.UpdatedAt.String())
app := App{ClientID: "123", URL: "http://localhost:8080", Name: "Test"}
assert.Equal(t, app, firstAuth.App)
assert.Equal(t, 2, len(firstAuth.Scopes))
scopes := []string{"repo", "user"}
assert.T(t, reflect.DeepEqual(firstAuth.Scopes, scopes))
}
示例5: TestDoozerWalk
func TestDoozerWalk(t *testing.T) {
l := mustListen()
defer l.Close()
u := mustListenPacket(l.Addr().String())
defer u.Close()
go Main("a", "X", "", "", nil, u, l, nil, 1e9, 2e9, 3e9)
cl := dial(l.Addr().String())
cl.Set("/test/foo", store.Clobber, []byte("bar"))
cl.Set("/test/fun", store.Clobber, []byte("house"))
rev, err := cl.Rev()
if err != nil {
panic(err)
}
info, err := cl.Walk("/test/**", rev, 0, -1)
assert.Equal(t, nil, err)
assert.Equal(t, 2, len(info))
assert.Equal(t, "/test/foo", info[0].Path)
assert.Equal(t, "bar", string(info[0].Body))
assert.T(t, info[0].IsSet())
assert.Equal(t, "/test/fun", info[1].Path)
assert.Equal(t, "house", string(info[1].Body))
assert.T(t, info[1].IsSet())
}
示例6: TestRepositoresService_CreateFork
func TestRepositoresService_CreateFork(t *testing.T) {
setup()
defer tearDown()
mux.HandleFunc("/repos/jingweno/octokat/forks", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
testBody(t, r, "{\"organization\":\"github\"}\n")
respondWithJSON(w, loadFixture("create_repository.json"))
})
reposService, err := client.Repositories(&ForksURL, M{"owner": "jingweno", "repo": "octokat"})
assert.Equal(t, nil, err)
repo, result := reposService.Create(M{"organization": "github"})
assert.T(t, !result.HasError())
assert.Equal(t, 1296269, repo.ID)
assert.Equal(t, "Hello-World", repo.Name)
assert.Equal(t, "octocat/Hello-World", repo.FullName)
assert.Equal(t, "This is your first repo", repo.Description)
assert.T(t, !repo.Private)
assert.T(t, repo.Fork)
assert.Equal(t, "https://api.github.com/repos/octocat/Hello-World", repo.URL)
assert.Equal(t, "https://github.com/octocat/Hello-World", repo.HTMLURL)
assert.Equal(t, "https://github.com/octocat/Hello-World.git", repo.CloneURL)
assert.Equal(t, "git://github.com/octocat/Hello-World.git", repo.GitURL)
assert.Equal(t, "[email protected]:octocat/Hello-World.git", repo.SSHURL)
assert.Equal(t, "master", repo.MasterBranch)
}
示例7: TestModelReload
func TestModelReload(t *testing.T) {
// Preparations
client := setupConnection(t)
assert.T(t, client != nil)
// Create a new "DocumentModel" and save it
doc := DocumentModel{FieldS: "text", FieldF: 1.2, FieldB: true}
err := client.New("testmodel.go", "TestModelKey", &doc)
assert.T(t, err == nil)
err = doc.Save()
assert.T(t, err == nil)
doc2 := DocumentModel{FieldS: "text22", FieldF: 1.4, FieldB: true}
err = client.New("testmodel.go", "TestModelKey", &doc2)
err = doc2.Save()
assert.T(t, err == nil)
vclock := string(doc.robject.Vclock)
err = (&doc).Reload()
assert.T(t, err == nil)
assert.T(t, string(doc.robject.Vclock) != vclock)
assert.T(t, string(doc.robject.Vclock) == string(doc2.robject.Vclock))
assert.T(t, doc.FieldS == doc2.FieldS)
assert.T(t, doc.FieldF == doc2.FieldF)
assert.T(t, doc.FieldB == doc2.FieldB)
}
示例8: TestDoozerWatchWithRev
func TestDoozerWatchWithRev(t *testing.T) {
l := mustListen()
defer l.Close()
u := mustListenPacket(l.Addr().String())
defer u.Close()
go Main("a", "X", "", nil, u, l, nil, 1e9, 2e9, 3e9)
cl := doozer.New("foo", l.Addr().String())
// Create some history
cl.Set("/test/foo", store.Clobber, []byte("bar"))
cl.Set("/test/fun", store.Clobber, []byte("house"))
// Ask doozer for the history
w, err := cl.Watch("/test/**", 1)
assert.Equal(t, nil, err, err)
defer w.Cancel()
ev := <-w.C
assert.Equal(t, "/test/foo", ev.Path)
assert.Equal(t, []byte("bar"), ev.Body)
assert.T(t, ev.IsSet())
ev = <-w.C
assert.Equal(t, "/test/fun", ev.Path)
assert.Equal(t, []byte("house"), ev.Body)
assert.T(t, ev.IsSet())
}
示例9: TestDoozerWalk
func TestDoozerWalk(t *testing.T) {
l := mustListen()
defer l.Close()
u := mustListenPacket(l.Addr().String())
defer u.Close()
go Main("a", "X", "", nil, u, l, nil, 1e9, 2e9, 3e9)
cl := doozer.New("foo", l.Addr().String())
cl.Set("/test/foo", store.Clobber, []byte("bar"))
cl.Set("/test/fun", store.Clobber, []byte("house"))
w, err := cl.Walk("/test/**", nil, nil, nil)
assert.Equal(t, nil, err, err)
ev := <-w.C
assert.NotEqual(t, (*doozer.Event)(nil), ev)
assert.Equal(t, "/test/foo", ev.Path)
assert.Equal(t, "bar", string(ev.Body))
assert.T(t, ev.IsSet())
ev = <-w.C
assert.NotEqual(t, (*doozer.Event)(nil), ev)
assert.Equal(t, "/test/fun", ev.Path)
assert.Equal(t, "house", string(ev.Body))
assert.T(t, ev.IsSet())
ev = <-w.C
assert.Tf(t, closed(w.C), "got %v", ev)
}
示例10: TestDirDescent
func TestDirDescent(t *testing.T) {
tg := treegen.New()
treeSpec := tg.D("foo",
tg.F("baobab", tg.B(91, 65537)),
tg.D("bar",
tg.D("aleph",
tg.F("a", tg.B(42, 65537)))),
tg.F("bar3003", tg.B(777, 65537)))
path := treegen.TestTree(t, treeSpec)
defer os.RemoveAll(path)
dir, err := IndexDir(path)
assert.T(t, err == nil)
for _, fpath := range []string{
filepath.Join("foo", "baobab"),
filepath.Join("foo", "bar", "aleph", "a"),
filepath.Join("foo", "bar3003")} {
node, found := dir.Resolve(fpath)
assert.Tf(t, found, "not found: %s", fpath)
_, isFile := node.(*File)
assert.T(t, isFile)
}
node, found := dir.Resolve(filepath.Join("foo", "bar"))
assert.T(t, found)
_, isDir := node.(*Dir)
assert.T(t, isDir)
}
示例11: TestDoozerWatchSimple
func TestDoozerWatchSimple(t *testing.T) {
l := mustListen()
defer l.Close()
u := mustListenPacket(l.Addr().String())
defer u.Close()
go Main("a", "X", "", nil, u, l, nil, 1e9, 2e9, 3e9)
cl := doozer.New("foo", l.Addr().String())
w, err := cl.Watch("/test/**", 0)
assert.Equal(t, nil, err, err)
defer w.Cancel()
cl.Set("/test/foo", store.Clobber, []byte("bar"))
ev := <-w.C
assert.Equal(t, "/test/foo", ev.Path)
assert.Equal(t, []byte("bar"), ev.Body)
assert.T(t, ev.IsSet())
cl.Set("/test/fun", store.Clobber, []byte("house"))
ev = <-w.C
assert.Equal(t, "/test/fun", ev.Path)
assert.Equal(t, []byte("house"), ev.Body)
assert.T(t, ev.IsSet())
cl.Del("/test/foo", store.Clobber)
ev = <-w.C
assert.Equal(t, "/test/foo", ev.Path)
assert.T(t, ev.IsDel())
w.Cancel()
ev = <-w.C
assert.Tf(t, closed(w.C), "got %v", ev)
}
示例12: TestOpenCloseStore
func TestOpenCloseStore(t *testing.T) {
go func() {
log.Debugf("Error creating http server %v\n", http.ListenAndServe("localhost:6060", nil))
}()
for i := 0; i < 100; i++ {
store, err := OpenStore("test.db")
assert.T(t, err == nil, err)
init := store.getWritePointer()
acks := make(chan bool)
for i := 0; i < 100; i++ {
store.eventsInChannel() <- &EventIn{event: &Event{Channel: "test", Body: []byte("BODY-TestOpenCloseStore")}, saved: acks}
<-acks
}
curr := store.getWritePointer()
assert.Equal(t, init+100, curr)
store.Close()
store, err = OpenStore("test.db")
assert.T(t, err == nil, err)
init = store.getWritePointer()
assert.Equal(t, init, curr)
store.Close()
}
}
示例13: TestSerialize
func TestSerialize(t *testing.T) {
for i := 1; i < 100000; i++ {
read, err := readSequence(writeSequence(int64(i)))
assert.T(t, err == nil, err)
assert.T(t, read == int64(i))
}
}
示例14: TestSession
func TestSession(t *testing.T) {
st := store.New()
defer close(st.Ops)
fp := &test.FakeProposer{Store: st}
go Clean(st, fp)
ch := make(chan store.Event, 100)
go func(c <-chan store.Event) {
for e := range c {
ch <- e
}
close(ch)
}(st.Watch("/session/*"))
// check-in with less than a nanosecond to live
body := strconv.Itoa64(time.Nanoseconds() + 1)
fp.Propose(store.MustEncodeSet("/session/a", body, store.Clobber))
// Throw away the set
assert.T(t, (<-ch).IsSet())
ev := <-ch
assert.T(t, ev.IsDel())
assert.Equal(t, "/session/a", ev.Path)
}
示例15: TestGet
// Should create a new Spotify Object.
func TestGet(t *testing.T) {
result, err := spotify.Get("albums/%s", nil, "0sNOF9WDwhWunNAHPD3Baj")
assert.T(t, result != nil, "Shouldnt be null")
assert.T(t, err == nil, "Should be null")
}