當前位置: 首頁>>代碼示例>>Golang>>正文


Golang assert.Equal函數代碼示例

本文整理匯總了Golang中github.com/nowk/assert.Equal函數的典型用法代碼示例。如果您正苦於以下問題:Golang Equal函數的具體用法?Golang Equal怎麽用?Golang Equal使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Equal函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestEntryCreatedIfReadCloserIsNotNilOnError

func TestEntryCreatedIfReadCloserIsNotNilOnError(t *testing.T) {
	c := ioutil.NopCloser(bytes.NewReader([]byte("uh-oh")))
	sourceFn := tSourceFunc(c)

	out := new(bytes.Buffer)
	zip := NewZip(sourceFn)
	zip.Add("good", "error", "andgoodagain")

	_, err := zip.WriteTo(out)
	if err := zip.Close(); err != nil {
		t.Fatal(err)
	}

	assert.NotNil(t, err)
	assert.Equal(t, fmt.Sprintf("1 error(s):\n\n%s", "* uh-oh"), err.Error())

	ze := err.(Error)
	assert.Equal(t, 1, len(err.(Error)))
	assert.Equal(t, "uh-oh", ze[0].Error())
	gozipst.VerifyZip(t, out.Bytes(), []gozipst.Entries{
		{"good", "Good!"},
		{"error", "uh-oh"},
		{"andgoodagain", "Good!"},
	})
}
開發者ID:gozips,項目名稱:zips,代碼行數:25,代碼來源:zips_test.go

示例2: TestZipFromHTTPSources

func TestZipFromHTTPSources(t *testing.T) {
	ts := tServer()
	defer ts.Close()

	url1 := fmt.Sprintf("%s/index.html", ts.URL)
	url2 := fmt.Sprintf("%s/posts", ts.URL)
	url3 := fmt.Sprintf("%s/api/data.json", ts.URL)

	out := new(bytes.Buffer)
	zip := NewZip(sources.HTTP)
	zip.Add(url1)
	zip.Add(url2, url3)
	n, err := zip.WriteTo(out)
	if err := zip.Close(); err != nil {
		t.Fatal(err)
	}

	assert.Nil(t, err)
	assert.Equal(t, int64(38), n)
	assert.Equal(t, int64(38), zip.N)
	assert.Equal(t, int64(38), zip.UncompressedSize)
	assert.Equal(t, int64(56), zip.CompressedSize)
	gozipst.VerifyZip(t, out.Bytes(), []gozipst.Entries{
		{"index.html", "Hello World!"},
		{"posts", "Post Body"},
		{"data.json", `{"data": ["one"]}`},
	})
}
開發者ID:gozips,項目名稱:zips,代碼行數:28,代碼來源:zips_test.go

示例3: TestRateLimitError

func TestRateLimitError(t *testing.T) {
	api, mock := tNewInstagram(t)

	reg := regmc(`v1\/users\/self\/feed\?access_token=\w+$`)
	mock.Expect("GET", reg).Respond(429, `{"meta": {"code": 429}}`)

	data, err := api.Users.SelfFeed()

	assert.Equal(t, data.Meta.Code, 429)
	assert.Equal(t, err.Error(), "The maximum number of requests per hour has been exceeded.")
	assert.TypeOf(t, "instagram.RateLimitError", err)
}
開發者ID:nowk,項目名稱:go-instagram,代碼行數:12,代碼來源:rate_limit_test.go

示例4: TestRateLimit

func TestRateLimit(t *testing.T) {
	api, mock := tNewInstagram(t)

	reg := regmc(`v1\/users\/self\/feed\?access_token=\w+$`)
	resp, _ := mock.Expect("GET", reg).Respond(200, `{"meta": {"code": 200}}`)
	resp.Header.Add("X-Ratelimit-Remaining", "3000")
	resp.Header.Add("X-Ratelimit-Limit", "5000")

	api.Users.SelfFeed()

	assert.Equal(t, api.RateLimit.Remaining, int64(3000))
	assert.Equal(t, api.RateLimit.Limit, int64(5000))
}
開發者ID:nowk,項目名稱:go-instagram,代碼行數:13,代碼來源:rate_limit_test.go

示例5: TestRealTimeUnsubscribe

func TestRealTimeUnsubscribe(t *testing.T) {
	api, mock := tNewRealTime(t, "my-clientid", "a-secret")

	reg := regmc(`v1\/subscriptions\?client_id=[a-z-]+&client_secret=[a-z-]+&id=\d+$`)
	mock.Expect("DELETE", reg).Respond(200, `{"meta": {"code": 201}}`)

	data, _ := api.Unsubscribe("id", "1234")

	assert.Equal(t, data.Meta.Code, 201)
}
開發者ID:nowk,項目名稱:go-instagram,代碼行數:10,代碼來源:real_time_test.go

示例6: TestTagsName

func TestTagsName(t *testing.T) {
	api, mock := tNewInstagram(t)

	reg := regmc(`v1\/tags\/\w+\?access_token=\w+$`)
	mock.Expect("GET", reg).Respond(200, `{"meta": {"code": 200}}`)

	data, _ := api.Tags.Name("Foo")

	assert.Equal(t, data.Meta.Code, 200)
	assert.TypeOf(t, "*jsons.Tag", data)
	assert.TypeOf(t, "jsons.TagData", data.Data)
}
開發者ID:nowk,項目名稱:go-instagram,代碼行數:12,代碼來源:tags_test.go

示例7: TestRealTimeSubscriptions

func TestRealTimeSubscriptions(t *testing.T) {
	api, mock := tNewRealTime(t, "my-clientid", "a-secret")

	reg := regmc(`v1\/subscriptions\?client_id=[a-z-]+&client_secret=[a-z-]+$`)
	mock.Expect("GET", reg).Respond(200, `{"meta": {"code": 202}}`)

	data, _ := api.Subscriptions()

	assert.Equal(t, data.Meta.Code, 202)
	assert.TypeOf(t, "*jsons.Subscriptions", data)
	assert.TypeOf(t, "[]jsons.SubscriptionData", data.Data)
}
開發者ID:nowk,項目名稱:go-instagram,代碼行數:12,代碼來源:real_time_test.go

示例8: TestCommentsComments

func TestCommentsComments(t *testing.T) {
	api, mock := tNewInstagram(t)

	reg := regmc(`v1\/media\/\d+\/comments\?access_token=\w+$`)
	mock.Expect("GET", reg).Respond(200, `{"meta": {"code": 200}}`)

	data, _ := api.Comments.Comments(12345)

	assert.Equal(t, data.Meta.Code, 200)
	assert.TypeOf(t, "*jsons.Comments", data)
	assert.TypeOf(t, "[]jsons.CommentData", data.Data)
}
開發者ID:nowk,項目名稱:go-instagram,代碼行數:12,代碼來源:comments_test.go

示例9: TestUsersUser

func TestUsersUser(t *testing.T) {
	api, mock := tNewInstagram(t)

	reg := regmc(`v1\/users\/\d+\?access_token=`)
	mock.Expect("GET", reg).Respond(200, `{"meta": {"code": 201}}`)

	data, _ := api.Users.User(1234)

	assert.Equal(t, data.Meta.Code, 201)
	assert.TypeOf(t, "*jsons.User", data)
	assert.TypeOf(t, "jsons.UserData", data.Data)
}
開發者ID:nowk,項目名稱:go-instagram,代碼行數:12,代碼來源:users_test.go

示例10: TestRelationshipsFollows

func TestRelationshipsFollows(t *testing.T) {
	api, mock := tNewInstagram(t)

	reg := regmc(`v1\/users\/\d+\/follows\?access_token=\w+$`)
	mock.Expect("GET", reg).Respond(200, `{"meta": {"code": 200}}`)

	data, _ := api.Relationships.Follows(123)

	assert.Equal(t, data.Meta.Code, 200)
	assert.TypeOf(t, "*jsons.Users", data)
	assert.TypeOf(t, "[]jsons.UserData", data.Data)
}
開發者ID:nowk,項目名稱:go-instagram,代碼行數:12,代碼來源:relationships_test.go

示例11: TestRelationshipsRelationship

func TestRelationshipsRelationship(t *testing.T) {
	api, mock := tNewInstagram(t)

	reg := regmc(`v1\/users\/\d+\/relationship\?access_token=\w+$`)
	mock.Expect("GET", reg).Respond(200, `{"meta": {"code": 203}}`)

	data, _ := api.Relationships.Relationship(12345)

	assert.Equal(t, data.Meta.Code, 203)
	assert.TypeOf(t, "*jsons.Relationship", data)
	assert.TypeOf(t, "jsons.RelationshipData", data.Data)
}
開發者ID:nowk,項目名稱:go-instagram,代碼行數:12,代碼來源:relationships_test.go

示例12: TestRelationshipsSelfRequestedBy

func TestRelationshipsSelfRequestedBy(t *testing.T) {
	api, mock := tNewInstagram(t)

	reg := regmc(`v1\/users\/self\/requested-by\?access_token=\w+$`)
	mock.Expect("GET", reg).Respond(200, `{"meta": {"code": 202}}`)

	data, _ := api.Relationships.SelfRequestedBy()

	assert.Equal(t, data.Meta.Code, 202)
	assert.TypeOf(t, "*jsons.Users", data)
	assert.TypeOf(t, "[]jsons.UserData", data.Data)
}
開發者ID:nowk,項目名稱:go-instagram,代碼行數:12,代碼來源:relationships_test.go

示例13: TestLikesPost

func TestLikesPost(t *testing.T) {
	api, mock := tNewInstagram(t)

	reg := regmc(`v1\/media\/\d+\/likes\?access_token=\w+$`)
	mock.Expect("POST", reg).Respond(200, `{"meta": {"code": 201}}`)

	data, _ := api.Likes.Post(12345)

	assert.Equal(t, data.Meta.Code, 201)
	assert.TypeOf(t, "*jsons.Like", data)
	assert.TypeOf(t, "jsons.LikeData", data.Data)
}
開發者ID:nowk,項目名稱:go-instagram,代碼行數:12,代碼來源:likes_test.go

示例14: TestCommentsDelete

func TestCommentsDelete(t *testing.T) {
	api, mock := tNewInstagram(t)

	reg := regmc(`v1\/media\/\d+\/comments\/\d+\?access_token=\w+$`)
	mock.Expect("DELETE", reg).Respond(200, `{"meta": {"code": 202}}`)

	data, _ := api.Comments.Delete(12345, 67890)

	assert.Equal(t, data.Meta.Code, 202)
	assert.TypeOf(t, "*jsons.Comment", data)
	assert.TypeOf(t, "jsons.CommentData", data.Data)
}
開發者ID:nowk,項目名稱:go-instagram,代碼行數:12,代碼來源:comments_test.go

示例15: TestLocationsLocation

func TestLocationsLocation(t *testing.T) {
	api, mock := tNewInstagram(t)

	reg := regmc(`v1\/locations\/\d+\?access_token=\w+$`)
	mock.Expect("GET", reg).Respond(200, `{"meta": {"code": 200}}`)

	data, _ := api.Locations.Location(12345)

	assert.Equal(t, data.Meta.Code, 200)
	assert.TypeOf(t, "*jsons.Location", data)
	assert.TypeOf(t, "jsons.LocationData", data.Data)
}
開發者ID:nowk,項目名稱:go-instagram,代碼行數:12,代碼來源:locations_test.go


注:本文中的github.com/nowk/assert.Equal函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。