• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang assert.Tf函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/bmizerany/assert.Tf函数的典型用法代码示例。如果您正苦于以下问题:Golang Tf函数的具体用法?Golang Tf怎么用?Golang Tf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Tf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: testSubselect

// sub-select not implemented in exec yet
func testSubselect(t *testing.T) {
	sqlText := `
		select 
	        user_id, email
	    FROM users
	    WHERE user_id in 
	        (select user_id from orders)
    `
	job, err := BuildSqlJob(rtConf, "mockcsv", sqlText)
	assert.Tf(t, err == nil, "no error %v", err)

	//writeCtx := NewContextSimple()
	msgs := make([]datasource.Message, 0)
	go func() {
		outChan := job.DrainChan()
		for msg := range outChan {
			u.Infof("msg: %v", msg)
			msgs = append(msgs, msg)
		}
	}()
	err = job.Run()
	time.Sleep(time.Millisecond * 30)
	assert.Tf(t, err == nil, "no error %v", err)
	assert.Tf(t, len(msgs) == 1, "should have filtered out 2 messages")

}
开发者ID:schmichael,项目名称:qlbridge,代码行数:27,代码来源:exec_test.go


示例2: TestPatch

// Test an actual file patch on the munged file scenario from TestMatchMunge.
// Resulting patched file should be identical to the source file.
func TestPatch(t *testing.T) {
	srcPath := "../../testroot/My Music/0 10k 30.mp4"
	dstPath := filepath.Join(os.TempDir(), "foo.mp4")

	os.Remove(dstPath)

	origDstF, err := os.Open("../../testroot/My Music/0 10k 30 munged.mp4")
	assert.Tf(t, err == nil, "%v", err)

	dstF, err := os.Create(dstPath)
	assert.Tf(t, err == nil, "%v", err)

	_, err = io.Copy(dstF, origDstF)
	assert.Tf(t, err == nil, "%v", err)

	origDstF.Close()
	dstF.Close()

	err = PatchFile(srcPath, dstPath)
	if err != nil {
		fmt.Print(err.Error())
	}
	assert.T(t, err == nil)

	srcFile, err := fs.IndexFile(srcPath)
	assert.T(t, err == nil)

	dstFile, err := fs.IndexFile(dstPath)
	assert.Tf(t, err == nil, "%v", err)

	assert.Equal(t, srcFile.Strong(), dstFile.Strong())
}
开发者ID:vanackere,项目名称:replican-sync,代码行数:34,代码来源:merge_test.go


示例3: TestMatchAppend

// Test the matcher on a case where the source file has the same 
// prefix as destination, but has been appended to.
func TestMatchAppend(t *testing.T) {
	tg := treegen.New()
	treeSpec := tg.F("bar", tg.B(42, 65537), tg.B(43, 65537))

	srcpath := treegen.TestTree(t, treeSpec)
	defer os.RemoveAll(srcpath)

	// Try indexing root dir as a file
	srcFile, err := fs.IndexFile(srcpath)
	assert.Tf(t, err != nil, "%v", err)

	// Ok, for real this time
	srcFile, err = fs.IndexFile(filepath.Join(srcpath, "bar"))
	assert.Tf(t, err == nil, "%v", err)
	assert.Equal(t, 17, len(srcFile.Blocks))

	tg = treegen.New()
	treeSpec = tg.F("bar", tg.B(42, 65537))

	dstpath := treegen.TestTree(t, treeSpec)
	defer os.RemoveAll(dstpath)
	dstFile, err := fs.IndexFile(filepath.Join(dstpath, "bar"))
	assert.Equal(t, 9, len(dstFile.Blocks))

	match, err := MatchFile(srcFile, filepath.Join(dstpath, "bar"))
	assert.T(t, err == nil, "%v", err)

	assert.Equal(t, 8, len(match.BlockMatches))

	notMatched := match.NotMatched()
	assert.Equal(t, 1, len(notMatched))
	assert.Equal(t, int64(65536), notMatched[0].From)
	assert.Equal(t, int64(65537+65537), notMatched[0].To)
}
开发者ID:vanackere,项目名称:replican-sync,代码行数:36,代码来源:merge_test.go


示例4: TestSqlShow

func TestSqlShow(t *testing.T) {
	/*
		SHOW [FULL] TABLES [{FROM | IN} db_name]
		[LIKE 'pattern' | WHERE expr]
	*/
	sql := `show tables`
	req, err := ParseSql(sql)
	assert.Tf(t, err == nil && req != nil, "Must parse: %s  \n\t%v", sql, err)
	cmd, ok := req.(*SqlShow)
	assert.Tf(t, ok, "is SqlShow: %T", req)
	assert.Tf(t, cmd.Identity == "tables", "has SHOW kw: %#v", cmd)
	/*
		assert.Tf(t, len(cmd.Columns) == 1 && cmd.Columns[0].Name == "autocommit", "has autocommit: %#v", cmd.Columns)

		sql = `SET @@local.sort_buffer_size=10000;`
		req, err = ParseSql(sql)
		assert.Tf(t, err == nil && req != nil, "Must parse: %s  \n\t%v", sql, err)
		cmd, ok = req.(*SqlCommand)
		assert.Tf(t, ok, "is SqlCommand: %T", req)
		assert.Tf(t, cmd.Keyword() == lex.TokenSet, "has SET kw: %#v", cmd)
		assert.Tf(t, len(cmd.Columns) == 1 && cmd.Columns[0].Name == "@@local.sort_buffer_size", "has autocommit: %#v", cmd.Columns)

		sql = "USE `myschema`;"
		req, err = ParseSql(sql)
		assert.Tf(t, err == nil && req != nil, "Must parse: %s  \n\t%v", sql, err)
		cmd, ok = req.(*SqlCommand)
		assert.Tf(t, ok, "is SqlCommand: %T", req)
		assert.Tf(t, cmd.Keyword() == lex.TokenUse, "has USE kw: %#v", cmd)
		assert.Tf(t, len(cmd.Columns) == 1 && cmd.Columns[0].Name == "myschema", "has myschema: %#v", cmd.Columns[0])
	*/
}
开发者ID:schmichael,项目名称:qlbridge,代码行数:31,代码来源:parse_sql_test.go


示例5: TestWithJson

func TestWithJson(t *testing.T) {
	// This is obviously not exactly sql standard
	// but is nice for proxy's
	sql := `
		SELECT id, name FROM user
		WITH {
			"key":"value2"
			,"keyint":45,
			"keyfloat":55.5, 
			"keybool": true,
			"keyarraymixed":["a",2,"b"],
			"keyarrayobj":[
				{"hello":"value","age":55},
				{"hello":"value","age":55}
			],
			"keyobj":{"hello":"value","age":55},
			"keyobjnested":{
				"hello":"value",
				"array":[
					"a",
					2,
					"b"
				]
			}
		}
		`
	req, err := ParseSql(sql)
	assert.Tf(t, err == nil && req != nil, "Must parse: %s  \n\t%v", sql, err)
	sel, ok := req.(*SqlSelect)
	assert.Tf(t, ok, "is SqlSelect: %T", req)
	assert.Tf(t, len(sel.From) == 1 && sel.From[0].Name == "user", "has 1 from: %v", sel.From)
	assert.Tf(t, len(sel.With) == 8, "has with: %v", sel.With)
	assert.Tf(t, len(sel.With.Helper("keyobj")) == 2, "has 2obj keys: %v", sel.With.Helper("keyobj"))
	u.Infof("sel.With:  \n%s", sel.With.PrettyJson())
}
开发者ID:schmichael,项目名称:qlbridge,代码行数:35,代码来源:parse_sql_test.go


示例6: TestSqlDelete

func TestSqlDelete(t *testing.T) {

	db := datasource.NewContextSimple()
	user1 := map[string]value.Value{
		"user_id":    value.NewIntValue(5),
		"item_count": value.NewStringValue("5"),
		"bval":       value.NewBoolValue(true),
		"bvalf":      value.NewBoolValue(false),
		"reg_date":   value.NewStringValue("2014/11/01"),
		"name":       value.NewStringValue("bob")}
	db.Insert(user1)
	user2 := map[string]value.Value{
		"user_id":    value.NewIntValue(6),
		"item_count": value.NewStringValue("5"),
		"reg_date":   value.NewStringValue("2012/11/01"),
		"name":       value.NewStringValue("allison")}
	db.Insert(user2)
	assert.Tf(t, len(db.Rows) == 2, "has 2 users")
	verifySqlDelete(t, `
		DELETE FROM mytable
		WHERE yy(reg_date) == 14
		`, db)

	assert.Tf(t, len(db.Rows) == 1, "must have 1 rows: %v  %v", len(db.Rows), db.Rows)
	assert.Tf(t, db.Rows[0]["name"].ToString() == "allison", "%v", db.Rows)
}
开发者ID:kyledj,项目名称:qlbridge,代码行数:26,代码来源:vm_sql_test.go


示例7: TestFindNodeByExactMatch

// 18.9.9. Find node by exact match
func TestFindNodeByExactMatch(t *testing.T) {
	db := connectTest(t)
	defer cleanup(t, db)
	// Create
	idxName := rndStr(t)
	key0 := rndStr(t)
	key1 := rndStr(t)
	value0 := rndStr(t)
	value1 := rndStr(t)
	idx0, _ := db.CreateLegacyNodeIndex(idxName, "", "")
	defer idx0.Delete()
	n0, _ := db.CreateNode(Props{})
	n1, _ := db.CreateNode(Props{})
	n2, _ := db.CreateNode(Props{})
	// These two will be located by Find() below
	idx0.Add(n0, key0, value0)
	idx0.Add(n1, key0, value0)
	// These two will NOT be located by Find() below
	idx0.Add(n2, key1, value0)
	idx0.Add(n2, key0, value1)
	//
	nodes, err := idx0.Find(key0, value0)
	if err != nil {
		t.Error(err)
	}
	// This query should have returned a map containing just two nodes, n1 and n0.
	assert.Equal(t, len(nodes), 2)
	_, present := nodes[n0.Id()]
	assert.Tf(t, present, "Find() failed to return node with id "+strconv.Itoa(n0.Id()))
	_, present = nodes[n1.Id()]
	assert.Tf(t, present, "Find() failed to return node with id "+strconv.Itoa(n1.Id()))
}
开发者ID:jmcvetta,项目名称:neo4j,代码行数:33,代码来源:node_index_test.go


示例8: 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


示例9: TestThrottleer

func TestThrottleer(t *testing.T) {
	th := NewThrottler(10, 10*time.Second)
	for i := 0; i < 10; i++ {
		thb, tc := th.Throttle()
		assert.Tf(t, thb == false, "Should not throttle %v", i)
		assert.Tf(t, tc < 10, "Throttle count should remain below 10 %v", tc)
		time.Sleep(time.Millisecond * 10)
	}

	throttled := 0
	th = NewThrottler(10, 1*time.Second)
	// We are going to loop 20 times, first 10 should make it, next 10 throttled
	for i := 0; i < 20; i++ {
		LogThrottleKey(WARN, 10, "throttle", "hello %v", i)
		thb, tc := th.Throttle()

		if thb {
			throttled += 1
			assert.Tf(t, int(tc) == i-9, "Throttle count should rise %v, i: %d", tc, i)
		}
	}
	assert.Tf(t, throttled == 10, "Should throttle 10 of 20 requests: %v", throttled)

	// Now sleep for 1 second so that we should
	// no longer be throttled
	time.Sleep(time.Second * 2)
	thb, _ := th.Throttle()
	assert.Tf(t, thb == false, "We should not have been throttled")
}
开发者ID:araddon,项目名称:gou,代码行数:29,代码来源:throttle_test.go


示例10: TestGetTypedRelationships

// 18.5.12. Get typed relationships
func TestGetTypedRelationships(t *testing.T) {
	db := connectTest(t)
	defer cleanup(t, db)
	// Create
	relType0 := rndStr(t)
	relType1 := rndStr(t)
	n0, _ := db.CreateNode(Props{})
	n1, _ := db.CreateNode(Props{})
	r0, _ := n0.Relate(relType0, n1.Id(), Props{})
	r1, _ := n0.Relate(relType1, n1.Id(), Props{})
	// Check one type of relationship
	rels, err := n0.Relationships(relType0)
	if err != nil {
		t.Error(err)
	}
	assert.Equalf(t, len(rels), 1, "Wrong number of relationships")
	_, present := rels.Map()[r0.Id()]
	assert.Tf(t, present, "Missing expected relationship")
	// Check two types of relationship together
	rels, err = n0.Relationships(relType0, relType1)
	if err != nil {
		t.Error(err)
	}
	assert.Equalf(t, len(rels), 2, "Wrong number of relationships")
	for _, r := range []*Relationship{r0, r1} {
		_, present := rels.Map()[r.Id()]
		assert.Tf(t, present, "Missing expected relationship")
	}
}
开发者ID:jmcvetta,项目名称:neo4j,代码行数:30,代码来源:relationship_test.go


示例11: ExecSpec

func ExecSpec(t *testing.T, q *QuerySpec) {
	ctx := td.TestContext(q.sql)
	job, err := exec.BuildSqlJob(ctx)
	if !q.haserr {
		assert.Tf(t, err == nil, "expected no error but got %v for %s", err, q.sql)
	} else {
		assert.Tf(t, err != nil, "expected error but got %v for %s", err, q.sql)
		return
	}

	msgs := make([]schema.Message, 0)
	resultWriter := exec.NewResultBuffer(ctx, &msgs)
	job.RootTask.Add(resultWriter)

	err = job.Setup()
	if !q.haserr {

	}
	assert.T(t, err == nil)
	err = job.Run()
	//time.Sleep(time.Millisecond * 1)
	assert.Tf(t, err == nil, "got err=%v for sql=%s", err, q.sql)
	assert.Tf(t, len(msgs) == q.rowct, "expected %d rows but got %v for %s", q.rowct, len(msgs), q.sql)
	for rowi, msg := range msgs {
		row := msg.(*datasource.SqlDriverMessageMap).Values()
		expect := q.expect[rowi]
		//u.Debugf("msg?  %#v", msg)
		assert.Tf(t, len(row) == len(expect), "expects %d cols but got %v for sql=%s", len(expect), len(row), q.sql)
		for i, v := range row {
			assert.Equalf(t, expect[i], v, "Comparing values, col:%d expected %v:%T got %v:%T for sql=%s",
				i, expect[i], expect[i], v, v, q.sql)
		}
	}
}
开发者ID:allisonmorgan,项目名称:qlbridge,代码行数:34,代码来源:harness.go


示例12: DoTestPatchFileAppend

func DoTestPatchFileAppend(t *testing.T, mkrepo repoMaker) {
	tg := treegen.New()
	treeSpec := tg.D("foo", tg.F("bar", tg.B(42, 65537), tg.B(43, 65537)))

	srcpath := treegen.TestTree(t, treeSpec)
	defer os.RemoveAll(srcpath)
	srcRepo := mkrepo(t)
	defer srcRepo.Close()
	srcStore, err := fs.NewLocalStore(srcpath, srcRepo)
	assert.T(t, err == nil)

	tg = treegen.New()
	treeSpec = tg.D("foo", tg.F("bar", tg.B(42, 65537)))

	dstpath := treegen.TestTree(t, treeSpec)
	defer os.RemoveAll(dstpath)
	dstRepo := mkrepo(t)
	defer dstRepo.Close()
	dstStore, err := fs.NewLocalStore(dstpath, dstRepo)
	assert.T(t, err == nil)

	patchPlan := NewPatchPlan(srcStore, dstStore)
	//	printPlan(patchPlan)

	complete := false
	for i, cmd := range patchPlan.Cmds {
		switch {
		case i == 0:
			localTemp, isTemp := cmd.(*LocalTemp)
			assert.T(t, isTemp)
			assert.Equal(t, filepath.Join(dstpath, "foo", "bar"), localTemp.Path.Resolve())
		case i >= 1 && i <= 8:
			ltc, isLtc := cmd.(*LocalTempCopy)
			assert.Tf(t, isLtc, "cmd %d", i)
			assert.Equal(t, ltc.LocalOffset, ltc.TempOffset)
			assert.Equal(t, int64(fs.BLOCKSIZE), ltc.Length)
			assert.Equal(t, int64(0), ltc.LocalOffset%int64(fs.BLOCKSIZE))
		case i == 9:
			stc, isStc := cmd.(*SrcTempCopy)
			assert.T(t, isStc)
			assert.Equal(t, int64(65538), stc.Length)
		case i == 10:
			_, isRwt := cmd.(*ReplaceWithTemp)
			assert.T(t, isRwt)
			complete = true
		case i > 10:
			t.Fatalf("too many commands")
		}
	}
	assert.T(t, complete, "missing expected number of commands")

	failedCmd, err := patchPlan.Exec()
	assert.Tf(t, failedCmd == nil && err == nil, "%v: %v", failedCmd, err)

	srcRoot, errors := fs.IndexDir(srcpath, fs.NewMemRepo())
	assert.Equalf(t, 0, len(errors), "%v", errors)
	dstRoot, errors := fs.IndexDir(dstpath, fs.NewMemRepo())
	assert.Equalf(t, 0, len(errors), "%v", errors)
	assert.Equal(t, srcRoot.Info().Strong, dstRoot.Info().Strong)
}
开发者ID:cmars,项目名称:replican-sync,代码行数:60,代码来源:patch_test.go


示例13: TestMainWriter_Write

func TestMainWriter_Write(t *testing.T) {
	var out bytes.Buffer
	b := mainWriter{
		&task.TaskSet{
			ImportPath: "github.com/jingweno/gotask/examples",
			Tasks: []task.Task{
				{
					Name:        "HelloWorld",
					ActionName:  "TaskHelloWorld",
					Usage:       "Say Hello world",
					Description: "Print out Hello World",
					Flags: []task.Flag{
						task.NewBoolFlag("v, verbose", "Run in verbose mode"),
					},
				},
			},
		},
	}
	b.Write(&out)

	assert.Tf(t, strings.Contains(out.String(), `_task "github.com/jingweno/gotask/examples"`), "%v", out.String())
	assert.Tf(t, strings.Contains(out.String(), `Name: "HelloWorld"`), "%v", out.String())
	assert.Tf(t, strings.Contains(out.String(), `Usage: "Say Hello world"`), "%v", out.String())
	assert.Tf(t, strings.Contains(out.String(), `Description: "Print out Hello World`), "%v", out.String())
	assert.Tf(t, strings.Contains(out.String(), `task.NewBoolFlag("v, verbose", "Run in verbose mode")`), "%v", out.String())
}
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:26,代码来源:main_writer_test.go


示例14: TestBuiltins

func TestBuiltins(t *testing.T) {
	for _, biTest := range builtinTests {
		node, err := ParseExpression(biTest.expr)
		assert.Tf(t, err == nil, "nil err: %v", err)
		assert.Tf(t, node != nil, "has node: %v", node)
	}
}
开发者ID:kyledj,项目名称:qlbridge,代码行数:7,代码来源:nativefunc_test.go


示例15: TestResponseError_Error_401

func TestResponseError_Error_401(t *testing.T) {
	setup()
	defer tearDown()

	mux.HandleFunc("/error", func(w http.ResponseWriter, r *http.Request) {
		head := w.Header()
		head.Set("Content-Type", "application/json")
		w.WriteHeader(http.StatusUnauthorized)
		respondWith(w, `{"message":"Unauthorized"}`)
	})

	req, _ := client.NewRequest("error")
	_, err := req.Get(nil)
	assert.Tf(t, strings.Contains(err.Error(), "401 - Unauthorized"), "%s", err.Error())

	e := err.(*ResponseError)
	assert.Equal(t, ErrorUnauthorized, e.Type)

	mux.HandleFunc("/error_2fa", func(w http.ResponseWriter, r *http.Request) {
		head := w.Header()
		head.Set("Content-Type", "application/json")
		head.Set("X-GitHub-OTP", "required; app")
		w.WriteHeader(http.StatusUnauthorized)
		respondWith(w, `{"message":"Unauthorized"}`)
	})

	req, _ = client.NewRequest("error_2fa")
	_, err = req.Get(nil)
	assert.Tf(t, strings.Contains(err.Error(), "401 - Unauthorized"), "%s", err.Error())

	e = err.(*ResponseError)
	assert.Equal(t, ErrorOneTimePasswordRequired, e.Type)
}
开发者ID:rahulteni,项目名称:hub,代码行数:33,代码来源:error_test.go


示例16: TestFromReader

func TestFromReader(t *testing.T) {
	raw := `{"testing": 123}`
	reader := strings.NewReader(raw)
	jh, err := NewJsonHelperReader(reader)
	assert.Tf(t, err == nil, "Unexpected error decoding json: %s", err)
	assert.Tf(t, jh.Int("testing") == 123, "Unexpected value in json: %d", jh.Int("testing"))
}
开发者ID:admpub,项目名称:gou,代码行数:7,代码来源:jsonhelper_test.go


示例17: TestClean

func TestClean(t *testing.T) {
	tg := treegen.New()
	treeSpec := tg.D("foo",
		tg.D("bar",
			tg.D("aleph",
				tg.F("A", tg.B(42, 65537)),
				tg.F("a", tg.B(42, 65537)))))
	srcpath := treegen.TestTree(t, treeSpec)
	defer os.RemoveAll(srcpath)
	srcStore, err := fs.NewLocalStore(srcpath)
	assert.T(t, err == nil)

	tg = treegen.New()
	treeSpec = tg.D("foo",
		tg.D("bar",
			tg.D("aleph",
				tg.F("A", tg.B(42, 65537)),
				tg.F("a", tg.B(42, 65537))),
			tg.D("beth",
				tg.F("B", tg.B(43, 65537)),
				tg.F("b", tg.B(43, 65537))),
			tg.D("jimmy",
				tg.F("G", tg.B(44, 65537)),
				tg.F("g", tg.B(44, 65537)))),
		tg.D("baz",
			tg.D("uno",
				tg.F("1", tg.B(1, 65537)),
				tg.F("I", tg.B(1, 65537))),
			tg.D("dos",
				tg.F("2", tg.B(11, 65537)),
				tg.F("II", tg.B(11, 65537))),
			tg.D("tres",
				tg.F("3", tg.B(111, 65537)),
				tg.F("III", tg.B(111, 65537)))))
	dstpath := treegen.TestTree(t, treeSpec)
	defer os.RemoveAll(dstpath)
	dstStore, err := fs.NewLocalStore(dstpath)
	assert.T(t, err == nil)

	onePath := dstStore.Resolve(filepath.Join("foo", "baz", "uno", "1"))
	_, err = os.Stat(onePath)
	assert.Tf(t, err == nil, "%v", err)

	patchPlan := NewPatchPlan(srcStore, dstStore)
	failedCmd, err := patchPlan.Exec()
	assert.Tf(t, failedCmd == nil, "%v", failedCmd)
	assert.Tf(t, err == nil, "%v", err)

	errors := make(chan error, 10)
	patchPlan.Clean(errors)
	close(errors)
	for err := range errors {
		assert.Tf(t, err == nil, "%v", err)
	}

	onePath = dstStore.Resolve(filepath.Join("foo", "baz", "uno", "1"))
	_, err = os.Stat(onePath)
	assert.Tf(t, err != nil, "%v", err)
}
开发者ID:vanackere,项目名称:replican-sync,代码行数:59,代码来源:merge_test.go


示例18: TestJsonPathNotation

func TestJsonPathNotation(t *testing.T) {
	// Now lets test xpath type syntax
	assert.Tf(t, jh.Int("/MaxSize") == 1048576, "get int, test capitalization? ")
	assert.Tf(t, jh.String("/nested/nest") == "string2", "should get string %s", jh.String("/nested/nest"))
	assert.Tf(t, jh.String("/nested/list[0]") == "value", "get string from array")
	// note this one has period in name
	assert.Tf(t, jh.String("/period.name") == "value", "test period in name ")
}
开发者ID:admpub,项目名称:gou,代码行数:8,代码来源:jsonhelper_test.go


示例19: TestLexRegex

func TestLexRegex(t *testing.T) {
	tok := token(` /^stats\./i `, LexRegex)
	assert.Tf(t, tok.T == TokenRegex && tok.V == `/^stats\./i`, "%v", tok)
	tok = token(` /^[a-z0-9_-]{3,16}$/ `, LexRegex)
	assert.Tf(t, tok.T == TokenRegex && tok.V == `/^[a-z0-9_-]{3,16}$/`, "%v", tok)
	tok = token(` /<TAG\b[^>]*>(.*?)</TAG>/ `, LexRegex)
	assert.Tf(t, tok.T == TokenRegex && tok.V == `/<TAG\b[^>]*>(.*?)</TAG>/`, "%v", tok)
}
开发者ID:allisonmorgan,项目名称:qlbridge,代码行数:8,代码来源:lexer_test.go


示例20: TestManPageParser_Parse

func TestManPageParser_Parse(t *testing.T) {
	doc := `NAME
    say-hello - Say hello to current user

DESCRIPTION
    Print out hello to current user
    one more line

OPTIONS
    -n, --name=[NAME]
        Say hello to the given name
    -v, --verbose
        Run in verbose mode
    -g, --greeting=Hello
        Say hello with a custom type of greeting
`
	p := &manPageParser{doc}
	mp, err := p.Parse()

	assert.Equal(t, nil, err)
	assert.Equal(t, "say-hello", mp.Name)
	assert.Equal(t, "Say hello to current user", mp.Usage)
	assert.Equal(t, "Print out hello to current user\n   one more line", mp.Description)
	assert.Equal(t, 3, len(mp.Flags))

	stringFlag, ok := mp.Flags[0].(task.StringFlag)
	assert.Tf(t, ok, "Can't convert flag to task.StringFlag")
	assert.Equal(t, "n, name", stringFlag.Name)
	assert.Equal(t, "", stringFlag.Value)
	assert.Equal(t, "Say hello to the given name", stringFlag.Usage)

	boolFlag, ok := mp.Flags[1].(task.BoolFlag)
	assert.Tf(t, ok, "Can't convert flag to task.BoolFlag")
	assert.Equal(t, "v, verbose", boolFlag.Name)
	assert.Equal(t, "Run in verbose mode", boolFlag.Usage)

	stringFlag, ok = mp.Flags[2].(task.StringFlag)
	assert.Tf(t, ok, "Can't convert flag to task.StringFlag")
	assert.Equal(t, "g, greeting", stringFlag.Name)
	assert.Equal(t, "Hello", stringFlag.Value)
	assert.Equal(t, "Say hello with a custom type of greeting", stringFlag.Usage)

	doc = `Name
    say-hello - Say hello to current user

Description
    Print out hello to current user
`
	p = &manPageParser{doc}
	mp, err = p.Parse()

	assert.Equal(t, nil, err)
	assert.Equal(t, "", mp.Name)
	assert.Equal(t, "", mp.Usage)
	assert.Equal(t, "", mp.Description)
	assert.Equal(t, 0, len(mp.Flags))
}
开发者ID:remogatto,项目名称:gotask,代码行数:57,代码来源:man_page_test.go



注:本文中的github.com/bmizerany/assert.Tf函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang pat.New函数代码示例发布时间:2022-05-24
下一篇:
Golang assert.T函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap