本文整理汇总了Golang中github.com/bmizerany/assert.T函数的典型用法代码示例。如果您正苦于以下问题:Golang T函数的具体用法?Golang T怎么用?Golang T使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了T函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:allisonmorgan,项目名称:qlbridge,代码行数:30,代码来源:exec_test.go
示例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))
}
开发者ID:cmars,项目名称:replican-sync,代码行数:29,代码来源:test.go
示例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())
}
开发者ID:dcjones,项目名称:doozerd,代码行数:33,代码来源:peer_test.go
示例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))
}
开发者ID:jingweno,项目名称:gh,代码行数:31,代码来源:authorizations_test.go
示例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())
}
开发者ID:foamdino,项目名称:doozerd,代码行数:30,代码来源:peer_test.go
示例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)
}
开发者ID:johnbellone,项目名称:go-octokit,代码行数:29,代码来源:repositories_test.go
示例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)
}
开发者ID:cupcake,项目名称:go-riak,代码行数:26,代码来源:model_test.go
示例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())
}
开发者ID:chrismoos,项目名称:doozerd,代码行数:29,代码来源:peer_test.go
示例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)
}
开发者ID:chrismoos,项目名称:doozerd,代码行数:31,代码来源:peer_test.go
示例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)
}
开发者ID:vanackere,项目名称:replican-sync,代码行数:30,代码来源:fs_test.go
示例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)
}
开发者ID:chrismoos,项目名称:doozerd,代码行数:35,代码来源:peer_test.go
示例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()
}
}
开发者ID:wojtekzw,项目名称:event-shuttle,代码行数:25,代码来源:store_test.go
示例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))
}
}
开发者ID:wojtekzw,项目名称:event-shuttle,代码行数:7,代码来源:store_test.go
示例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)
}
开发者ID:andradeandrey,项目名称:doozer,代码行数:25,代码来源:session_test.go
示例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")
}
开发者ID:leobcn,项目名称:go-spotify,代码行数:8,代码来源:spotify_test.go
示例16: TestDoozerWaitSimple
func TestDoozerWaitSimple(t *testing.T) {
var (
l = mustListen()
st = store.New(store.DefaultInitialRev)
)
defer l.Close()
go Main("a", "X", nil, l, nil, st, 1e6)
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())
}
开发者ID:soundcloud,项目名称:doozerd,代码行数:34,代码来源:solo_test.go
示例17: TestRepositoresService_Get
func TestRepositoresService_Get(t *testing.T) {
setup()
defer tearDown()
mux.HandleFunc("/repos/jingweno/octokat", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
respondWithJSON(w, loadFixture("repository.json"))
})
reposService, err := client.Repositories(&RepositoryURL, M{"owner": "jingweno", "repo": "octokat"})
assert.Equal(t, nil, err)
repo, result := reposService.Get()
assert.T(t, !result.HasError())
assert.Equal(t, 10575811, repo.ID)
assert.Equal(t, "octokat", repo.Name)
assert.Equal(t, "jingweno/octokat", repo.FullName)
assert.T(t, !repo.Private)
assert.T(t, !repo.Fork)
assert.Equal(t, "https://api.github.com/repos/jingweno/octokat", repo.URL)
assert.Equal(t, "https://github.com/jingweno/octokat", repo.HTMLURL)
assert.Equal(t, "https://github.com/jingweno/octokat.git", repo.CloneURL)
assert.Equal(t, "git://github.com/jingweno/octokat.git", repo.GitURL)
assert.Equal(t, "[email protected]:jingweno/octokat.git", repo.SSHURL)
assert.Equal(t, "master", repo.MasterBranch)
}
开发者ID:johnbellone,项目名称:go-octokit,代码行数:27,代码来源:repositories_test.go
示例18: TestInclude
func TestInclude(t *testing.T) {
t.Parallel()
e1 := datasource.NewContextSimpleNative(map[string]interface{}{"x": 6, "y": "1"})
e2 := datasource.NewContextSimpleNative(map[string]interface{}{"x": 4, "y": "1"})
q, err := rel.ParseFilterQL("FILTER AND (x < 9000, INCLUDE test)")
assert.Equal(t, nil, err)
filterVm := NewFilterVm(includer{})
{
match, err := filterVm.Matches(e1, q)
assert.Equal(t, nil, err)
assert.T(t, match)
}
{
match, err := filterVm.Matches(e2, q)
assert.Equal(t, nil, err)
assert.T(t, !match)
}
// Matches should return an error when the query includes an invalid INCLUDE
{
q, err := rel.ParseFilterQL("FILTER AND (x < 9000, INCLUDE shouldfail)")
assert.Equal(t, nil, err)
_, err = filterVm.Matches(e1, q)
assert.NotEqual(t, nil, err)
}
}
开发者ID:allisonmorgan,项目名称:qlbridge,代码行数:31,代码来源:filterqlvm_test.go
示例19: TestJsonHelperGobEncoding
func TestJsonHelperGobEncoding(t *testing.T) {
raw := `{"testing": 123,"name":"bob & more"}`
reader := strings.NewReader(raw)
jh, err := NewJsonHelperReader(reader)
assert.Tf(t, err == nil, "Unexpected error decoding gob: %s", err)
assert.Tf(t, jh.Int("testing") == 123, "Unexpected value in gob: %d", jh.Int("testing"))
var buf bytes.Buffer
err = gob.NewEncoder(&buf).Encode(&jh)
assert.T(t, err == nil, err)
var jhNew JsonHelper
err = gob.NewDecoder(&buf).Decode(&jhNew)
assert.T(t, err == nil, err)
assert.Tf(t, jhNew.Int("testing") == 123, "Unexpected value in gob: %d", jhNew.Int("testing"))
assert.Tf(t, jhNew.String("name") == "bob & more", "Unexpected value in gob: %d", jhNew.String("name"))
buf2 := bytes.Buffer{}
gt := GobTest{"Hello", jh}
err = gob.NewEncoder(&buf2).Encode(>)
assert.T(t, err == nil, err)
var gt2 GobTest
err = gob.NewDecoder(&buf2).Decode(>2)
assert.T(t, err == nil, err)
assert.Tf(t, gt2.Name == "Hello", "Unexpected value in gob: %d", gt2.Name)
assert.Tf(t, gt2.Data.Int("testing") == 123, "Unexpected value in gob: %d", gt2.Data.Int("testing"))
assert.Tf(t, gt2.Data.String("name") == "bob & more", "Unexpected value in gob: %d", gt2.Data.String("name"))
}
开发者ID:admpub,项目名称:gou,代码行数:28,代码来源:jsonhelper_test.go
示例20: TestRequest
// Should make a new Request
func TestRequest(t *testing.T) {
result, error := shop.Request("GET", "products", nil)
assert.T(t, error == nil, "should be null")
assert.T(t, result != nil, "shouldnt be null")
}
开发者ID:CodyGuo,项目名称:go-shopify,代码行数:8,代码来源:shopify_test.go
注:本文中的github.com/bmizerany/assert.T函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论