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

Golang wcg.NewAssert函数代码示例

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

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



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

示例1: TestObjectValidation

func TestObjectValidation(t *testing.T) {
	type TestObject struct {
		Str1 string
		Str2 string
	}
	assert := wcg.NewAssert(t)
	obj := &TestObject{}
	v := NewObjectValidator()
	v.Func(func(v interface{}) *FieldValidationError {
		obj := v.(*TestObject)
		if obj.Str1 == obj.Str2 {
			return NewFieldValidationError(
				"Same!!", nil,
			)
		}
		return nil
	})

	obj.Str1 = "foo"
	obj.Str2 = "foo"
	result := v.Eval(obj).(*ValidationError)
	assert.NotNil(result.Errors["."], "ValidationError should claims on 'Str'")
	assert.EqStr("Same!!", result.Errors["."][0].String(), "ValidationError Error message")

	obj.Str2 = "bar"
	assert.Nil(v.Eval(obj), "Eval(obj) should return nil when validation passed.")
}
开发者ID:speedland,项目名称:wcg,代码行数:27,代码来源:object_validator_test.go


示例2: TestRecorderStart_CancelBeforeStart

func TestRecorderStart_CancelBeforeStart(t *testing.T) {
	assert := wcg.NewAssert(t)
	receiver := make(chan []Record)
	recorder := NewRecorder((<-chan []Record)(receiver))

	interval := time.Duration(30) * time.Millisecond
	wait := 10
	go recorder.Start(interval)

	now := time.Now()
	r1 := NewDummyRecord("r1") // cancel before starting
	r1.startAt = now.Add(time.Duration(30 * time.Minute))
	r1.endAt = now.Add(time.Duration(60 * time.Minute))
	// r2 := NewDummyRecord("r2") // cancel after starting
	// r3 := NewDummyRecord("r3") // succeeded
	// r4 := NewDummyRecord("r4") // failed

	receiver <- []Record{r1}
	err := util.WaitFor(func() bool {
		return len(recorder.controls) == 1
	}, wait)
	assert.Nil(err, "check r1 in controls.")
	assert.EqStr(r1.Key(), recorder.controls[r1.Key()].record.Key(), "check r1 in controls.")

	receiver <- []Record{}
	err = util.WaitFor(func() bool {
		return len(recorder.controls) == 0
	}, wait)
	assert.Nil(err, "check r1 removed from controls.")

	recorder.Stop()
}
开发者ID:speedland,项目名称:apps,代码行数:32,代码来源:record_test.go


示例3: TestRecordValidator

func TestRecordValidator(t *testing.T) {
	var err error
	assert := wcg.NewAssert(t)
	r := genTestRecord()

	r.Title = ""
	err = RecordValidator.Eval(r)
	assert.NotNil(err, "Empty Title Error")

	r.Title = "../foo"
	err = RecordValidator.Eval(r)
	assert.NotNil(err, "Special Character Validation")

	r.Title = "NormalTitle"
	err = RecordValidator.Eval(r)
	assert.Nil(err, "Normal Character Validation")

	r.Title = "日本語はつかえる"
	err = RecordValidator.Eval(r)
	assert.Nil(err, "日本語 Validation")

	r.Title = "モーニング娘。"
	err = RecordValidator.Eval(r)
	assert.Nil(err, "日本語 特殊文字 Valiation")
}
开发者ID:speedland,项目名称:apps,代码行数:25,代码来源:record_test.go


示例4: TestRecorderStart

func TestRecorderStart(t *testing.T) {
	assert := wcg.NewAssert(t)
	receiver := make(chan []Record)
	recorder := NewRecorder((<-chan []Record)(receiver))

	interval := time.Duration(30) * time.Millisecond
	wait := 10
	go recorder.Start(interval)

	now := time.Now()
	r1 := NewDummyRecord("r1") // cancel before starting
	r1.startAt = now
	r1.endAt = now.Add(time.Duration(5 * time.Second))
	receiver <- []Record{r1}
	err := util.WaitFor(func() bool {
		return len(recorder.controls) == 1
	}, wait)
	assert.Nil(err, "check r1 in controls.")
	ctrl := recorder.controls[r1.Key()]

	err = util.WaitFor(func() bool {
		return r1.done == true
	}, wait)
	assert.Nil(err, "check r1 has been done.")
	assert.EqInt(int(RSSucceeded), int(ctrl.state), "Record state should be RSSucceeded")
	recorder.Stop()
}
开发者ID:speedland,项目名称:apps,代码行数:27,代码来源:record_test.go


示例5: TestPt1Record_Start

func TestPt1Record_Start(t *testing.T) {
	assert := wcg.NewAssert(t)
	now := time.Now()

	tvrecord := models.NewTvRecord(
		"Title",
		"Category",
		now,
		now.Add(time.Duration(5)*time.Second),
		"cid",
		"sid",
		"uid",
	)
	util.WithTempDir(func(dir string) {
		record := NewPt1Record(tvrecord, genPt1Config(dir))
		err := record.Start()
		assert.Nil(err, "Pt1Record started.")
		time.Sleep(1 * time.Second)
		assert.Ok(record.IsRunning(), "Pt1Record is running.")

		err = record.Stop()
		assert.Nil(err, "Stop record.")

		err = util.WaitFor(func() bool {
			return record.IsRunning() == false
		}, 10)
		assert.Nil(err, "Pt1Record has stopped.")

		content, _ := ioutil.ReadFile(record.filepath)
		lines := bytes.Split(content, []byte("\n"))
		assert.EqStr("OK", string(lines[len(lines)-1]), "Check the mock record content.")
	})
}
开发者ID:speedland,项目名称:agent,代码行数:33,代码来源:pt1_recorder_test.go


示例6: TestGetIEpgList

func TestGetIEpgList(t *testing.T) {
	assert := wcg.NewAssert(t)
	client := NewCrawler(http.DefaultClient)
	list, err := client.GetIEpgList("今井絵理子", FEED_SCOPE_ALL)
	assert.Nil(err, "GetIEpgList should not return an error.")
	assert.NotNil(list, "GetIEpgList should return list of ids")
}
开发者ID:speedland,项目名称:lib,代码行数:7,代码来源:iepg_test.go


示例7: TestChannel_AddAndDelCrawlerConfig

func TestChannel_AddAndDelCrawlerConfig(t *testing.T) {
	test.RunTestServer(func(ts *test.TestServer) {
		assert := wcg.NewAssert(t)

		// prepare
		d := NewCrawlerConfigDriver(TEST_APP_KEY, ts.Context, wcg.NewLogger(nil))
		d.Add(&tv.CrawlerConfig{
			Keyword:  "キーワード1",
			Category: "カテゴリー1",
			Scope:    1,
		})
		d.Add(&tv.CrawlerConfig{
			Keyword:  "キーワード2",
			Category: "カテゴリー2",
			Scope:    1,
		})

		err := util.WaitFor(func() bool {
			c, _ := d.NewQuery().Count()
			return c == 2
		}, util.DefaultWaitForTimeout)
		assert.Nil(err, "Confirm CrawlerConfig entities has been stored within a timeout window.")

		d.Delete("キーワード1")
		err = util.WaitFor(func() bool {
			c, _ := d.NewQuery().Count()
			return c == 1
		}, util.DefaultWaitForTimeout)
		assert.Nil(err, "Confirm CrawlerConfig entities has been deleted within a timeout window.")

		err = d.Delete("Not Exists")
		assert.Nil(err, "Delete should not return even trying to delete the unexising keyword.")
	})
}
开发者ID:speedland,项目名称:apps,代码行数:34,代码来源:crawler_config_driver_test.go


示例8: TestIOLogSinkFormat

func TestIOLogSinkFormat(t *testing.T) {
	assert := wcg.NewAssert(t)
	record := NewTestRecord()
	storage := NewTestLogStorage()
	s := NewIOLogSink("", storage)
	s.Write(record)
	assert.NotZero(len(storage.GetLines()), "sink.Write should write a log record")
	line := storage.GetLines()[0]
	expect := "1984/09/22 12:01:28 +0000 [TRACE] [1|user1|session1|request1] This is a test (sourec.go#1)"
	assert.EqStr(expect, line, "LogRecord format")

	// custom format
	storage = NewTestLogStorage()
	s = NewIOLogSink("$TIMESTAMP $INVALIDVAR $TEXT", storage)
	s.Write(record)
	assert.NotZero(len(storage.GetLines()), "sink.Write should write a log record")

	line = storage.GetLines()[0]
	expect = "1984/09/22 12:01:28 +0000  This is a test"
	assert.EqStr(expect, line, "LogRecord format")

	// Data record case.
	storage = NewTestLogStorage()
	s = NewIOLogSink("", storage)
	record.Data = wcg.DataBag{}
	s.Write(record)
	assert.Zero(len(storage.GetLines()), "sink.Write should not write anything if the record has DataBag")
}
开发者ID:speedland,项目名称:wcg,代码行数:28,代码来源:io_test.go


示例9: TestRecorderUpcomming

func TestRecorderUpcomming(t *testing.T) {
	assert := wcg.NewAssert(t)
	receiver := make(chan []Record)
	recorder := NewRecorder((<-chan []Record)(receiver))
	interval := time.Duration(30) * time.Millisecond
	wait := 10
	go recorder.Start(interval)

	r1 := NewDummyRecord("r1")
	r1.startAt = time.Now().Add(time.Duration(2 * time.Hour))
	r1.endAt = r1.startAt.Add(time.Duration(10 * time.Minute))
	r2 := NewDummyRecord("r2")
	r2.startAt = time.Now().Add(time.Duration(4 * time.Hour))
	r2.endAt = r2.startAt.Add(time.Duration(10 * time.Minute))
	r3 := NewDummyRecord("r3")
	r3.startAt = time.Now().Add(time.Duration(8 * time.Hour))
	r3.endAt = r3.startAt.Add(time.Duration(10 * time.Minute))

	receiver <- []Record{r1, r2, r3}
	err := util.WaitFor(func() bool {
		return len(recorder.controls) == 3
	}, wait)
	assert.Nil(err, "check all records in controls.")

	upcome := recorder.Upcomming()
	assert.Ok(r1.startAt.Equal(upcome), "Upcomming should be r2")
	recorder.Stop()
}
开发者ID:speedland,项目名称:apps,代码行数:28,代码来源:record_test.go


示例10: TestRecorderStart_CancelWhileRecording

func TestRecorderStart_CancelWhileRecording(t *testing.T) {
	assert := wcg.NewAssert(t)
	receiver := make(chan []Record)
	recorder := NewRecorder((<-chan []Record)(receiver))
	interval := time.Duration(30) * time.Millisecond
	wait := 5

	go recorder.Start(interval)

	now := time.Now()
	r1 := NewDummyRecord("r1") // cancel before starting
	r1.startAt = now
	r1.endAt = now.Add(time.Duration(30 * time.Minute))

	receiver <- []Record{r1}
	err := util.WaitFor(func() bool {
		return len(recorder.controls) == 1
	}, wait)
	assert.Nil(err, "check r1 in controls.")
	assert.EqStr(r1.Key(), recorder.controls[r1.Key()].record.Key(), "check r1 in controls.")

	err = util.WaitFor(func() bool {
		return recorder.controls[r1.Key()].state == RSRecording
	}, wait)
	assert.Nil(err, "check r1 in RSRecording state.")

	receiver <- []Record{}
	err = util.WaitFor(func() bool {
		return len(recorder.controls) == 0
	}, wait)
	assert.Nil(err, "check r1 removed from controls.")

	recorder.Stop()
}
开发者ID:speedland,项目名称:apps,代码行数:34,代码来源:record_test.go


示例11: Test_parseAuctionApiResult

func Test_parseAuctionApiResult(t *testing.T) {
	assert := wcg.NewAssert(t)

	file, _ := os.Open("./auction-sample.xml")
	defer file.Close()
	auction, err := parseAuctionApiResult(file)
	assert.Nil(err, "parseAuctionApiResult should not return an error")
	assert.EqStr("h206483716", auction.Id, "Id")
	assert.EqStr("9/20 モーニング娘。15 座間 秋ツアー 夜公演 一般席 即決特典付", auction.Title, "Title")
	assert.EqStr("http://page8.auctions.yahoo.co.jp/jp/auction/h206483716", auction.Url, "Url")
	assert.EqStr("", auction.ImageUrl, "ImageUrl")
	assert.EqStr("gaba9tmcy2gam0", auction.Seller, "Seller")
	assert.EqFloat32(9000.0, auction.InitPrice, "InitPrice")
	assert.EqFloat32(9500.0, auction.CurrentPrice, "CurrentPrice")
	assert.EqFloat32(13000.0, auction.BidOrBuy, "BidOrBuy")
	assert.EqFloat32(13000.0, auction.BidOrBuy, "BidOrBuy")
	assert.EqInt(1, auction.Quantity, "Quantity")
	assert.EqInt(3, auction.Bids, "Bids")
	assert.EqTime(
		wcg.Must(time.Parse(time.RFC3339, "2015-08-30T20:27:57+09:00")).(time.Time),
		auction.StartAt,
		"StartAt",
	)
	assert.EqTime(
		wcg.Must(time.Parse(time.RFC3339, "2015-08-31T23:27:57+09:00")).(time.Time),
		auction.EndAt,
		"EndAt",
	)
	assert.Ok(
		STATUS_CLOSED == auction.Status,
		"Closed",
	)
}
开发者ID:speedland,项目名称:apps,代码行数:33,代码来源:crawler_test.go


示例12: TestTwitterClient_Stream

func TestTwitterClient_Stream(t *testing.T) {
	assert := wcg.NewAssert(t)
	NUM_TWEETS_IN_STREAM := 5
	httptest.StartMockServer("./dummy", func(ms *httptest.MockServer) {
		ms.Routes().Get("/1.1/statuses/filter.json", func(res *wcg.Response, req *wcg.Request) {
			data, _ := json.Marshal(map[string]interface{}{
				"id_str":     "123",
				"text":       "test text",
				"created_at": "Thu Sep 24 13:26:59 +0000 2015",
			})
			for i := 0; i < NUM_TWEETS_IN_STREAM; i++ {
				res.WriteString(string(data) + "\r\n")
				res.WriteString("\r\n") // send empty (optional)
				res.Flush()
				time.Sleep(10 * time.Millisecond)
			}
			res.Close()
		})
		client := NewTwitterClient("", "", nil)
		client.StreamingEndpoint = ms.BaseUrl()
		client.Token = BearerToken("TestToken")
		ts, err := client.Stream(&StreamingParams{})
		assert.Nil(err, "Stream should not return an error")

		var tweet *Tweet
		ch := ts.GetStreamChannel()
		num_received := 0
		for tweet = range ch {
			num_received += 1
		}
		assert.EqInt(NUM_TWEETS_IN_STREAM+1, num_received, "The number of tweets is incorrect.")
		assert.Nil(tweet, "The end of stream should be nil")
	})

}
开发者ID:speedland,项目名称:apps,代码行数:35,代码来源:client_test.go


示例13: TestParseIEpg

func TestParseIEpg(t *testing.T) {
	assert := wcg.NewAssert(t)
	file, _ := os.Open("./iepg-sample.iepg")
	defer file.Close()
	iepg, err := ParseIEpg(file)
	assert.Nil(err, "ParseIEPG should not return an error")
	assert.EqStr("The Girls Live ▽道重さゆみ卒業ライブに密着▽LoVendoЯスタジオライブ", iepg.ProgramTitle, "ProgramTitle")
	assert.EqStr("テレビ東京", iepg.StationName, "StationName")
	assert.EqStr("DFS00430", iepg.StationId, "StationId")
	assert.EqInt(7852, iepg.ProgramId, "ProgramId")
	assert.EqInt(2014, iepg.StartAt.Year(), "StartAt.Year")
	assert.EqInt(12, int(iepg.StartAt.Month()), "StartAt.Date")
	assert.EqInt(5, iepg.StartAt.Day(), "StartAt.Date")
	assert.EqInt(1, iepg.StartAt.Hour(), "StartAt.Hour")
	assert.EqInt(0, iepg.StartAt.Minute(), "StartAt.Mininute")
	zone, _ := iepg.StartAt.Zone()
	assert.EqStr("JST", zone, "StartAt.Zone")

	assert.EqInt(2014, iepg.EndAt.Year(), "EndAt.Year")
	assert.EqInt(12, int(iepg.EndAt.Month()), "EndAt.Date")
	assert.EqInt(5, iepg.EndAt.Day(), "EndAt.Date")
	assert.EqInt(1, iepg.EndAt.Hour(), "EndAt.Hour")
	assert.EqInt(30, iepg.EndAt.Minute(), "EndAt.Mininute")
	zone, _ = iepg.EndAt.Zone()
	assert.EqStr("JST", zone, "EndAt.Zone")

}
开发者ID:speedland,项目名称:lib,代码行数:27,代码来源:iepg_test.go


示例14: TestMax

func TestMax(t *testing.T) {
	type TestObject struct {
		Str   string
		Int   int
		Float float32
		Array []string
	}
	assert := wcg.NewAssert(t)
	obj := &TestObject{}
	v := NewObjectValidator()
	v.Field("Str").Max(1)
	v.Field("Int").Max(1)
	v.Field("Float").Max(1)
	v.Field("Array").Max(1)

	obj.Str = "Foo"
	obj.Int = 5
	obj.Float = 5
	obj.Array = []string{"a", "b", "c", "d"}
	result := v.Eval(obj).(*ValidationError)
	assert.NotNil(result.Errors["Str"], "ValidationError should claims on 'Str'")
	assert.NotNil(result.Errors["Int"], "ValidationError should claims on 'Int'")
	assert.NotNil(result.Errors["Float"], "ValidationError should claims on 'Float'")
	assert.NotNil(result.Errors["Array"], "ValidationError should claims on 'Arrau'")
	assert.EqStr("must be less than or equal to 1", result.Errors["Str"][0].String(), "ValidationError Error message")
	assert.EqStr("must be less than or equal to 1", result.Errors["Int"][0].String(), "ValidationError Error message")
	assert.EqStr("must be less than or equal to 1", result.Errors["Float"][0].String(), "ValidationError Error message")
	assert.EqStr("must be less than or equal to 1", result.Errors["Array"][0].String(), "ValidationError Error message")

	obj.Str = "F"
	obj.Int = 1
	obj.Float = 1
	obj.Array = []string{"a"}
	assert.Nil(v.Eval(obj), "Eval(obj) should return nil when validation passed.")
}
开发者ID:speedland,项目名称:wcg,代码行数:35,代码来源:object_validator_test.go


示例15: TestMatch

func TestMatch(t *testing.T) {
	type TestObject struct {
		Str   string
		Bytes []byte
	}
	assert := wcg.NewAssert(t)
	obj := &TestObject{}
	v := NewObjectValidator()
	v.Field("Str").Match("a+")
	v.Field("Bytes").Match("a+")
	result := v.Eval(obj).(*ValidationError)
	assert.NotNil(result.Errors["Str"], "ValidationError should claims on 'Str'")
	assert.NotNil(result.Errors["Bytes"], "ValidationError should claims on 'Bytes'")
	assert.EqStr("not match with 'a+'", result.Errors["Str"][0].String(), "ValidationError Error message")
	assert.EqStr("not match with 'a+'", result.Errors["Bytes"][0].String(), "ValidationError Error message")

	obj.Str = "bbb"
	obj.Bytes = []byte(obj.Str)
	result = v.Eval(obj).(*ValidationError)
	assert.NotNil(result, "Eval(obj) should return ValidationError")
	assert.NotNil(result.Errors["Str"], "ValidationError should claims on 'Str'")
	assert.NotNil(result.Errors["Bytes"], "ValidationError should claims on 'Bytes'")
	assert.EqStr("not match with 'a+'", result.Errors["Str"][0].String(), "ValidationError Error message")
	assert.EqStr("not match with 'a+'", result.Errors["Bytes"][0].String(), "ValidationError Error message")

	obj.Str = "aaa"
	obj.Bytes = []byte(obj.Str)
	assert.Nil(v.Eval(obj), "Eval(obj) should return nil when validation passed.")
}
开发者ID:speedland,项目名称:wcg,代码行数:29,代码来源:object_validator_test.go


示例16: TestParseEntry

func TestParseEntry(t *testing.T) {
	assert := wcg.NewAssert(t)
	file, _ := os.Open("./entry-sample.html")
	defer file.Close()
	entry, err := ParseEntry(file)
	assert.Nil(err, "ParseEntryContent should not return an error")
	assert.EqStr("早くヴァンプになりた〜い!工藤 遥", entry.Title, "Title")
}
开发者ID:speedland,项目名称:lib,代码行数:8,代码来源:ameblo_test.go


示例17: TestGetOverlaps

func TestGetOverlaps(t *testing.T) {
	test.RunTestServer(func(ts *test.TestServer) {
		var found []*tv.TvRecord
		const timeForm = "2006/01/02 15:04:05"
		assert := wcg.NewAssert(t)
		d := NewTvRecordDriver(TEST_APP_KEY, ts.Context, wcg.NewLogger(nil))

		base := genTestRecord()
		base.StartAt, _ = time.Parse(timeForm, "2014/01/01 12:00:00")
		base.EndAt, _ = time.Parse(timeForm, "2014/01/01 13:00:00")
		d.Save(base)
		err := util.WaitFor(func() bool {
			c, _ := d.NewQuery().Count()
			return c == 1
		}, util.DefaultWaitForTimeout)
		assert.Nil(err, "Confirm TvRecord entities has been stored within a timeout window.")

		// case1: no overlaps
		r := genTestRecord()
		r.StartAt, _ = time.Parse(timeForm, "2014/01/01 10:50:00")
		r.EndAt, _ = time.Parse(timeForm, "2014/01/01 11:10:00")
		found, err = d.GetOverlaps(r)
		assert.Nil(err, "TvRecordDriver#GetOverlaps should not return an error (case1)")
		assert.EqInt(0, len(found), "TvRecordDriver#GetOverlaps should return empty array (case1)")

		// case 2: base.end < r.start
		r = genTestRecord()
		r.StartAt, _ = time.Parse(timeForm, "2014/01/01 13:50:00")
		r.EndAt, _ = time.Parse(timeForm, "2014/01/01 14:10:00")
		found, err = d.GetOverlaps(r)
		assert.Nil(err, "TvRecordDriver#GetOverlaps should not return an error (case2)")
		assert.EqInt(0, len(found), "TvRecordDriver#GetOverlaps should return empty array (case2)")

		// case 3: base.start < r.start < base.end
		r = genTestRecord()
		r.StartAt, _ = time.Parse(timeForm, "2014/01/01 11:50:00")
		r.EndAt, _ = time.Parse(timeForm, "2014/01/01 12:10:00")
		found, err = d.GetOverlaps(r)
		assert.Nil(err, "TvRecordDriver#GetOverlaps should not return an error (case3)")
		assert.EqInt(1, len(found), "TvRecordDriver#GetOverlaps should return an array with an entity (case3)")

		// case 4: r.start < base.end < r.end
		r = genTestRecord()
		r.StartAt, _ = time.Parse(timeForm, "2014/01/01 12:50:00")
		r.EndAt, _ = time.Parse(timeForm, "2014/01/01 13:10:00")
		found, err = d.GetOverlaps(r)
		assert.Nil(err, "TvRecordDriver#GetOverlaps should not return an error (case4)")
		assert.EqInt(1, len(found), "TvRecordDriver#GetOverlaps should return an array with an entity (case4)")

		// case 5: r.start < base.start < base.end < r.end
		r = genTestRecord()
		r.StartAt, _ = time.Parse(timeForm, "2014/01/01 12:10:00")
		r.EndAt, _ = time.Parse(timeForm, "2014/01/01 12:50:00")
		found, err = d.GetOverlaps(r)
		assert.Nil(err, "TvRecordDriver#GetOverlaps should not return an error (case4)")
		assert.EqInt(1, len(found), "TvRecordDriver#GetOverlaps should return an array with an entity (case4)")
	})
}
开发者ID:speedland,项目名称:apps,代码行数:58,代码来源:record_driver_test.go


示例18: TestCrawlEntry

func TestCrawlEntry(t *testing.T) {
	assert := wcg.NewAssert(t)
	c := &Crawler{
		http.DefaultClient,
	}
	entry, err := c.CrawlEntry("http://ameblo.jp/sayumimichishige-blog/entry-11874881676.html")
	assert.Nil(err, "CrawlEntryList should not return an error")
	assert.EqStr("春ツアー思い出", entry.Title, "An entry in EntryList should have title.")
}
开发者ID:speedland,项目名称:lib,代码行数:9,代码来源:ameblo_test.go


示例19: TestCrawlEntryList

func TestCrawlEntryList(t *testing.T) {
	assert := wcg.NewAssert(t)
	c := &Crawler{
		http.DefaultClient,
	}
	list, err := c.CrawlEntryList("http://ameblo.jp/sayumimichishige-blog/entrylist.html")
	assert.Nil(err, "CrawlEntryList should not return an error")
	assert.Ok(len(list) > 0, "CrawlEntryList should return some entries.")
	assert.Ok(list[0].Title != "", "An entry in EntryList should have title.")
}
开发者ID:speedland,项目名称:lib,代码行数:10,代码来源:ameblo_test.go


示例20: TestSign

func TestSign(t *testing.T) {
	assert := wcg.NewAssert(t)
	cmd := "sign foo"
	stdout := ExecToolEx(cmd)
	assert.EqStr(wcg.Sign("foo", "wcgsess")+"\n", stdout, cmd)

	cmd = "sign -k bar foo"
	stdout = ExecToolEx(cmd)
	assert.EqStr(wcg.Sign("foo", "bar")+"\n", stdout, cmd)
}
开发者ID:speedland,项目名称:wcg,代码行数:10,代码来源:sign_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang wcg.NewLogger函数代码示例发布时间:2022-05-28
下一篇:
Golang lib.AppContext类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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