本文整理汇总了Golang中github.com/remind101/deploy/Godeps/_workspace/src/github.com/bmizerany/assert.Equal函数的典型用法代码示例。如果您正苦于以下问题:Golang Equal函数的具体用法?Golang Equal怎么用?Golang Equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestSearchBrowserLauncher
func TestSearchBrowserLauncher(t *testing.T) {
browser := searchBrowserLauncher("darwin")
assert.Equal(t, "open", browser)
browser = searchBrowserLauncher("windows")
assert.Equal(t, "cmd /c start", browser)
}
开发者ID:ZBNA,项目名称:deploy,代码行数:7,代码来源:utils_test.go
示例2: TestResolveRequestQuery
func TestResolveRequestQuery(t *testing.T) {
setup := Setup(t)
defer setup.Teardown()
setup.Mux.HandleFunc("/q", func(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
assert.Equal(t, "1", q.Get("a"))
assert.Equal(t, "4", q.Get("b"))
assert.Equal(t, "3", q.Get("c"))
assert.Equal(t, "2", q.Get("d"))
assert.Equal(t, "1", q.Get("e"))
w.WriteHeader(123)
w.Write([]byte("ok"))
})
assert.Equal(t, "1", setup.Client.Query.Get("a"))
assert.Equal(t, "1", setup.Client.Query.Get("b"))
setup.Client.Query.Set("b", "2")
setup.Client.Query.Set("c", "3")
req, err := setup.Client.NewRequest("/q?d=4")
assert.Equal(t, nil, err)
req.Query.Set("b", "4")
req.Query.Set("c", "3")
req.Query.Set("d", "2")
req.Query.Set("e", "1")
res := req.Get()
assert.Equal(t, nil, err)
assert.Equal(t, 123, res.StatusCode)
}
开发者ID:ZBNA,项目名称:deploy,代码行数:33,代码来源:request_test.go
示例3: TestUploadsService_UploadAsset
func TestUploadsService_UploadAsset(t *testing.T) {
setup()
defer tearDown()
file, err := ioutil.TempFile("", "octokit-test-upload-")
assert.Equal(t, nil, err)
file.WriteString("this is a test")
fi, err := file.Stat()
assert.Equal(t, nil, err)
file.Close()
mux.HandleFunc("/repos/octokit/Hello-World/releases/123/assets", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
testHeader(t, r, "Content-Type", "text/plain")
assert.Equal(t, fi.Size(), r.ContentLength)
respondWithStatus(w, 201)
})
link := Hyperlink("/repos/octokit/Hello-World/releases/123/assets{?name}")
url, err := link.Expand(M{"name": fi.Name()})
assert.Equal(t, nil, err)
open, _ := os.Open(file.Name())
result := client.Uploads(url).UploadAsset(open, "text/plain", fi.Size())
fmt.Println(result)
assert.T(t, !result.HasError())
assert.Equal(t, 201, result.Response.StatusCode)
}
开发者ID:ZBNA,项目名称:deploy,代码行数:30,代码来源:uploads_test.go
示例4: TestSuccessfulGetWithoutOutput
func TestSuccessfulGetWithoutOutput(t *testing.T) {
setup := Setup(t)
defer setup.Teardown()
setup.Mux.HandleFunc("/user", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, "GET", r.Method)
head := w.Header()
head.Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"id": 1, "login": "sawyer"}`))
})
client := setup.Client
user := &TestUser{}
req, err := client.NewRequest("user")
assert.Equal(t, nil, err)
res := req.Get()
assert.Equal(t, false, res.IsError())
assert.Equal(t, false, res.IsApiError())
assert.Tf(t, !res.IsError(), "Response shouldn't have error")
assert.Equal(t, 200, res.StatusCode)
assert.Equal(t, false, res.BodyClosed)
assert.Equal(t, 0, user.Id)
assert.Equal(t, "", user.Login)
dec := json.NewDecoder(res.Body)
dec.Decode(user)
assert.Equal(t, 1, user.Id)
assert.Equal(t, "sawyer", user.Login)
}
开发者ID:ZBNA,项目名称:deploy,代码行数:33,代码来源:request_test.go
示例5: TestGitTreesService_One_Recursive
func TestGitTreesService_One_Recursive(t *testing.T) {
setup()
defer tearDown()
mux.HandleFunc("/repos/pengwynn/flint/git/trees/master", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
respondWithJSON(w, loadFixture("tree_recursive.json"))
})
url, err := GitTreesURL.Expand(M{
"owner": "pengwynn",
"repo": "flint",
"sha": "master",
"recursive": "1",
})
assert.Equal(t, nil, err)
tree, result := client.GitTrees(url).One()
assert.T(t, !result.HasError())
assert.Equal(t, "9c1337e761bbd517f3cc1b5acb9373b17f4810e8", tree.Sha)
assert.Equal(t, "https://api.github.com/repos/pengwynn/flint/git/trees/9c1337e761bbd517f3cc1b5acb9373b17f4810e8", tree.URL)
entries := tree.Tree
assert.Equal(t, 15, len(entries))
}
开发者ID:ZBNA,项目名称:deploy,代码行数:25,代码来源:git_trees_test.go
示例6: TestSuccessfulGet
func TestSuccessfulGet(t *testing.T) {
setup := Setup(t)
defer setup.Teardown()
setup.Mux.HandleFunc("/user", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, "GET", r.Method)
head := w.Header()
head.Set("Content-Type", "application/json")
link := `<https://api.github.com/user/repos?page=3&per_page=100>; rel="next", <https://api.github.com/user/repos?page=50&per_page=100>; rel="last"`
head.Set("Link", link)
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"id": 1, "login": "sawyer"}`))
})
client := setup.Client
user := &TestUser{}
req, err := client.NewRequest("user")
assert.Equal(t, nil, err)
res := req.Get()
assert.Equal(t, false, res.IsError())
assert.Equal(t, false, res.IsApiError())
assert.Equal(t, nil, res.Decode(user))
assert.Equal(t, 200, res.StatusCode)
assert.Equal(t, 1, user.Id)
assert.Equal(t, "sawyer", user.Login)
mheader := res.MediaHeader
assert.Equal(t, "https://api.github.com/user/repos?page=3&per_page=100", string(mheader.Relations["next"]))
assert.Equal(t, "https://api.github.com/user/repos?page=50&per_page=100", string(mheader.Relations["last"]))
}
开发者ID:ZBNA,项目名称:deploy,代码行数:33,代码来源:request_test.go
示例7: TestUsersService_All
func TestUsersService_All(t *testing.T) {
setup()
defer tearDown()
mux.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
rr := regexp.MustCompile(`users\?since=\d+`)
assert.Tf(t, rr.MatchString(r.URL.String()), "Regexp should match users?since=\\d+")
header := w.Header()
link := fmt.Sprintf(`<%s>; rel="next", <%s>; rel="first"`, testURLOf("users?since=135"), testURLOf("users{?since}"))
header.Set("Link", link)
respondWithJSON(w, loadFixture("users.json"))
})
url, err := UserURL.Expand(M{"since": 1})
assert.Equal(t, nil, err)
q := url.Query()
q.Set("since", "1")
url.RawQuery = q.Encode()
allUsers, result := client.Users(url).All()
assert.T(t, !result.HasError())
assert.Equal(t, 1, len(allUsers))
assert.Equal(t, testURLStringOf("users?since=135"), string(*result.NextPage))
nextPageURL, err := result.NextPage.Expand(nil)
assert.Equal(t, nil, err)
allUsers, result = client.Users(nextPageURL).All()
assert.T(t, !result.HasError())
assert.Equal(t, 1, len(allUsers))
}
开发者ID:ZBNA,项目名称:deploy,代码行数:35,代码来源:users_test.go
示例8: TestRepositoresService_One
func TestRepositoresService_One(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"))
})
url, err := RepositoryURL.Expand(M{"owner": "jingweno", "repo": "octokat"})
assert.Equal(t, nil, err)
repo, result := client.Repositories(url).One()
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)
assert.T(t, !repo.Permissions.Admin)
assert.T(t, !repo.Permissions.Push)
assert.T(t, repo.Permissions.Pull)
}
开发者ID:ZBNA,项目名称:deploy,代码行数:30,代码来源:repositories_test.go
示例9: TestAuthorizationsService_Create
func TestAuthorizationsService_Create(t *testing.T) {
setup()
defer tearDown()
params := AuthorizationParams{Scopes: []string{"public_repo"}}
mux.HandleFunc("/authorizations", func(w http.ResponseWriter, r *http.Request) {
var authParams AuthorizationParams
json.NewDecoder(r.Body).Decode(&authParams)
assert.T(t, reflect.DeepEqual(authParams, params))
testMethod(t, r, "POST")
respondWithJSON(w, loadFixture("create_authorization.json"))
})
url, err := AuthorizationsURL.Expand(nil)
assert.Equal(t, nil, err)
auth, _ := client.Authorizations(url).Create(params)
assert.Equal(t, 3844190, auth.ID)
assert.Equal(t, "https://api.github.com/authorizations/3844190", auth.URL)
assert.Equal(t, "123", auth.Token)
assert.Equal(t, "", auth.Note)
assert.Equal(t, "", auth.NoteURL)
assert.Equal(t, "2013-09-28 18:44:39 +0000 UTC", auth.CreatedAt.String())
assert.Equal(t, "2013-09-28 18:44:39 +0000 UTC", auth.UpdatedAt.String())
app := App{ClientID: "00000000000000000000", URL: "http://developer.github.com/v3/oauth/#oauth-authorizations-api", Name: "GitHub API"}
assert.Equal(t, app, auth.App)
assert.Equal(t, 1, len(auth.Scopes))
scopes := []string{"public_repo"}
assert.T(t, reflect.DeepEqual(auth.Scopes, scopes))
}
开发者ID:ZBNA,项目名称:deploy,代码行数:35,代码来源:authorizations_test.go
示例10: 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:ZBNA,项目名称:deploy,代码行数:31,代码来源:authorizations_test.go
示例11: TestDecode
func TestDecode(t *testing.T) {
input := `
{ "Login": "bob"
, "Url": "/foo/bar{/arg}"
, "_links":
{ "self": { "href": "/foo/bar{/arg}" }
}
}`
user := &HypermediaUser{}
decode(t, input, user)
assert.Equal(t, "bob", user.Login)
assert.Equal(t, 1, len(user.Links))
hl := user.Url
url, err := hl.Expand(M{"arg": "baz"})
if err != nil {
t.Errorf("Errors parsing %s: %s", hl, err)
}
assert.Equal(t, "/foo/bar/baz", url.String())
hl = user.Links["self"].Href
url, err = hl.Expand(M{"arg": "baz"})
if err != nil {
t.Errorf("Errors parsing %s: %s", hl, err)
}
assert.Equal(t, "/foo/bar/baz", url.String())
}
开发者ID:ZBNA,项目名称:deploy,代码行数:30,代码来源:hypermedia_test.go
示例12: TestEditor_openAndEdit_deleteFileWhenOpeningEditorFails
func TestEditor_openAndEdit_deleteFileWhenOpeningEditorFails(t *testing.T) {
tempFile, _ := ioutil.TempFile("", "editor-test")
tempFile.Close()
ioutil.WriteFile(tempFile.Name(), []byte("hello"), 0644)
editor := Editor{
Program: "memory",
File: tempFile.Name(),
Topic: "test",
openEditor: func(program string, file string) error {
assert.Equal(t, "memory", program)
assert.Equal(t, tempFile.Name(), file)
return fmt.Errorf("error")
},
}
_, err := os.Stat(tempFile.Name())
assert.Equal(t, nil, err)
_, err = editor.openAndEdit()
assert.Equal(t, "error using text editor for test message", fmt.Sprintf("%s", err))
// file is removed if there's error
_, err = os.Stat(tempFile.Name())
assert.T(t, os.IsNotExist(err))
}
开发者ID:ZBNA,项目名称:deploy,代码行数:26,代码来源:editor_test.go
示例13: TestEditor_EditTitleAndBody
func TestEditor_EditTitleAndBody(t *testing.T) {
tempFile, _ := ioutil.TempFile("", "PULLREQ")
tempFile.Close()
editor := Editor{
Program: "memory",
File: tempFile.Name(),
CS: "#",
openEditor: func(program string, file string) error {
assert.Equal(t, "memory", program)
assert.Equal(t, tempFile.Name(), file)
message := `A title
A title continues
A body
A body continues
# comment
`
return ioutil.WriteFile(file, []byte(message), 0644)
},
}
title, body, err := editor.EditTitleAndBody()
assert.Equal(t, nil, err)
assert.Equal(t, "A title A title continues", title)
assert.Equal(t, "A body\nA body continues", body)
}
开发者ID:ZBNA,项目名称:deploy,代码行数:28,代码来源:editor_test.go
示例14: TestSuccessfulGet_BasicAuth
func TestSuccessfulGet_BasicAuth(t *testing.T) {
setup()
defer tearDown()
mux.HandleFunc("/foo", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", defaultMediaType)
testHeader(t, r, "User-Agent", userAgent)
testHeader(t, r, "Authorization", "Basic amluZ3dlbm86cGFzc3dvcmQ=")
testHeader(t, r, "X-GitHub-OTP", "OTP")
respondWithJSON(w, `{"login": "octokit"}`)
})
client = NewClientWith(
server.URL,
userAgent,
BasicAuth{
Login: "jingweno",
Password: "password",
OneTimePassword: "OTP",
},
nil)
req, err := client.NewRequest("foo")
assert.Equal(t, nil, err)
var output map[string]interface{}
_, err = req.Get(&output)
assert.Equal(t, nil, err)
assert.Equal(t, "octokit", output["login"])
}
开发者ID:ZBNA,项目名称:deploy,代码行数:30,代码来源:client_test.go
示例15: TestGitShow
func TestGitShow(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
output, err := Show("9b5a719a3d76ac9dc2fa635d9b1f34fd73994c06")
assert.Equal(t, nil, err)
assert.Equal(t, "First comment\n\nMore comment", output)
}
开发者ID:ZBNA,项目名称:deploy,代码行数:8,代码来源:git_test.go
示例16: TestGitEditor
func TestGitEditor(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
SetGlobalConfig("core.editor", "foo")
gitEditor, err := Editor()
assert.Equal(t, nil, err)
assert.Equal(t, "foo", gitEditor)
}
开发者ID:ZBNA,项目名称:deploy,代码行数:9,代码来源:git_test.go
示例17: TestBranch_RemoteName
func TestBranch_RemoteName(t *testing.T) {
lp, _ := LocalRepo()
b := Branch{lp, "refs/remotes/origin/master"}
assert.Equal(t, "origin", b.RemoteName())
b = Branch{lp, "refs/head/master"}
assert.Equal(t, "", b.RemoteName())
}
开发者ID:ZBNA,项目名称:deploy,代码行数:9,代码来源:branch_test.go
示例18: TestGitRef
func TestGitRef(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
ref := "08f4b7b6513dffc6245857e497cfd6101dc47818"
gitRef, err := Ref(ref)
assert.Equal(t, nil, err)
assert.Equal(t, ref, gitRef)
}
开发者ID:ZBNA,项目名称:deploy,代码行数:9,代码来源:git_test.go
示例19: TestDecoder_Decode
func TestDecoder_Decode(t *testing.T) {
link := `<https://api.github.com/user/repos?page=3&per_page=100>; rel="next", <https://api.github.com/user/repos?page=50&per_page=100>; rel="last"`
header := http.Header{}
header.Add("Link", link)
decoder := Decoder{}
mediaHeader := decoder.Decode(header)
assert.Equal(t, "https://api.github.com/user/repos?page=3&per_page=100", string(mediaHeader.Relations["next"]))
assert.Equal(t, "https://api.github.com/user/repos?page=50&per_page=100", string(mediaHeader.Relations["last"]))
}
开发者ID:ZBNA,项目名称:deploy,代码行数:10,代码来源:decoder_test.go
示例20: TestGitRefList
func TestGitRefList(t *testing.T) {
repo := fixtures.SetupTestRepo()
defer repo.TearDown()
refList, err := RefList("08f4b7b6513dffc6245857e497cfd6101dc47818", "9b5a719a3d76ac9dc2fa635d9b1f34fd73994c06")
assert.Equal(t, nil, err)
assert.Equal(t, 1, len(refList))
assert.Equal(t, "9b5a719a3d76ac9dc2fa635d9b1f34fd73994c06", refList[0])
}
开发者ID:ZBNA,项目名称:deploy,代码行数:10,代码来源:git_test.go
注:本文中的github.com/remind101/deploy/Godeps/_workspace/src/github.com/bmizerany/assert.Equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论