本文整理汇总了Golang中github.com/GlenKelley/battleref/testing.T.ErrorNow方法的典型用法代码示例。如果您正苦于以下问题:Golang T.ErrorNow方法的具体用法?Golang T.ErrorNow怎么用?Golang T.ErrorNow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/GlenKelley/battleref/testing.T
的用法示例。
在下文中一共展示了T.ErrorNow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestCreateUser
func TestCreateUser(t *testing.T) {
TournamentTest(t, func(t *testutil.T, tm *Tournament) {
if isUser, err := tm.UserExists("NameFoo"); err != nil {
t.ErrorNow(err)
} else if isUser {
t.FailNow()
}
if users, err := tm.ListUsers(); err != nil {
t.ErrorNow(err)
} else if len(users) != 0 {
t.FailNow()
}
if _, err := tm.CreateUser("NameFoo", "PublicKey", CategoryTest); err != nil {
t.ErrorNow(err)
}
if isUser, err := tm.UserExists("NameFoo"); err != nil {
t.ErrorNow(err)
} else if !isUser {
t.FailNow()
} else if users, err := tm.ListUsers(); err != nil {
t.ErrorNow(err)
} else if len(users) != 1 {
t.FailNow()
} else if users[0] != "NameFoo" {
t.FailNow()
}
})
}
示例2: TestUnescaptedParsingFails
func TestUnescaptedParsingFails(t *testing.T) {
ServerTest(t, func(t *testutil.T, server *ServerState) {
if r := sendPostExpectStatus(t, server, http.StatusInternalServerError, "/register", strings.NewReader("name=NameFoo&category="+string(tournament.CategoryTest)+"&public_key="+UnescapedSamplePublicKey)); Json(t, r).Key("error").Key("message").String() != "Invalid Public Key" {
t.ErrorNow("expected 'Invalid Public Key'")
}
})
}
示例3: TestSubmitPlayerNameError
func TestSubmitPlayerNameError(t *testing.T) {
ServerTest(t, func(t *testutil.T, server *ServerState) {
if r := sendJSONPostExpectStatus(t, server, http.StatusInternalServerError, "/submit", map[string]string{"name": "NameFoo", "category": string(tournament.CategoryTest), "commit_hash": SampleCommitHash}); Json(t, r).Key("error").Key("message").String() != "Unknown player" {
t.ErrorNow(r, "expected 'Unknown player'")
}
})
}
示例4: TestCategories
func TestCategories(t *testing.T) {
ServerTest(t, func(t *testutil.T, server *ServerState) {
if r := sendGet(t, server, "/categories"); !compareStringsUnordered(Json(t, r).Key("data").Key("categories").Array(), []string{string(tournament.CategoryBattlecode2014), string(tournament.CategoryBattlecode2015), string(tournament.CategoryBattlecode2016)}) {
t.ErrorNow("expected 3 categories", r)
}
})
}
示例5: TestInitGitoliteRepo
func TestInitGitoliteRepo(t *testing.T) {
GitoliteHostTest(t, func(t *testutil.T, host *GitoliteHost) {
if privateKey, publicKey, err := testutil.CreateKeyPair(); err != nil {
t.ErrorNow(err)
} else if file, err := ioutil.TempFile(os.TempDir(), "battlecode_private_key"); err != nil {
t.ErrorNow(err)
} else if _, err := file.WriteString(privateKey); err != nil {
t.ErrorNow(err)
} else {
file.Close()
defer os.Remove(file.Name())
if err := host.InitRepository("foo", map[string]int64{"foo": 1}, map[int64]string{1: publicKey}); err != nil {
t.ErrorNow(err)
}
defer host.DeleteRepository("foo")
repoURL := host.RepositoryURL("foo")
if repo, err := (TempRemote{}).CheckoutRepositoryWithKeyFile(repoURL, file.Name()); err != nil {
t.ErrorNow(err)
} else {
defer repo.Delete()
CheckDirectoryContent(t, repo.Dir(), []string{".git"})
}
}
})
}
示例6: TestCreateExistingMapError
func TestCreateExistingMapError(t *testing.T) {
TournamentTest(t, func(t *testutil.T, tm *Tournament) {
t.CheckError(tm.CreateMap("NameFoo", "SourceFoo", CategoryTest))
if err := tm.CreateMap("NameFoo", "SourceFoo", CategoryTest); err == nil {
t.ErrorNow("expected error")
}
})
}
示例7: TestSubmitCommitHashError
func TestSubmitCommitHashError(t *testing.T) {
ServerTest(t, func(t *testutil.T, server *ServerState) {
sendJSONPost(t, server, "/register", map[string]string{"name": "NameFoo", "public_key": SamplePublicKey, "category": string(tournament.CategoryTest)})
if r := sendJSONPostExpectStatus(t, server, http.StatusInternalServerError, "/submit", map[string]string{"name": "NameFoo", "category": string(tournament.CategoryTest), "commit_hash": "InvalidCommitHash"}); Json(t, r).Key("error").Key("message").String() != "Invalid commit hash" {
t.ErrorNow(r, "expected 'Unknown player'")
}
})
}
示例8: TestRunLatestMatches
func TestRunLatestMatches(t *testing.T) {
TournamentTest(t, func(t *testutil.T, tm *Tournament) {
runLatestMatches(t, tm)
if matches, err := tm.ListMatches(CategoryTest); err != nil {
t.ErrorNow(err)
} else if len(matches) != 18 {
t.ErrorNow("Expected 1 got", len(matches))
}
})
}
示例9: TestCreateExistingKey
func TestCreateExistingKey(t *testing.T) {
TournamentTest(t, func(t *testutil.T, tm *Tournament) {
if _, err := tm.CreateUser("NameFoo", "PublicKeyFoo", CategoryTest); err != nil {
t.ErrorNow(err)
}
if _, err := tm.CreateUser("NameBar", "PublicKeyFoo", CategoryTest); err != nil {
t.ErrorNow(err)
}
})
}
示例10: TestCreateDuplicateUserError
func TestCreateDuplicateUserError(t *testing.T) {
TournamentTest(t, func(t *testutil.T, tm *Tournament) {
if _, err := tm.CreateUser("NameFoo", "PublicKeyFoo", CategoryTest); err != nil {
t.ErrorNow(err)
}
if _, err := tm.CreateUser("NameFoo", "PublicKeyFoo", CategoryTest); err == nil {
t.ErrorNow("expected error")
}
})
}
示例11: TestDeleteLocalRepo
func TestDeleteLocalRepo(t *testing.T) {
LocalDirHostTest(t, func(t *testutil.T, local *LocalDirHost) {
t.CheckError(local.InitRepository("foo", nil, nil))
t.CheckError(local.DeleteRepository("foo"))
repoURL := local.RepositoryURL("foo")
if _, err := os.Stat(repoURL); err == nil {
t.FailNow()
} else if !os.IsNotExist(err) {
t.ErrorNow(err)
}
})
}
示例12: TestCheckoutRepository
func TestCheckoutRepository(t *testing.T) {
LocalDirHostTest(t, func(t *testutil.T, host *LocalDirHost) {
t.CheckError(host.InitRepository("foo", nil, nil))
repoURL := host.RepositoryURL("foo")
if repo, err := (TempRemote{}).CheckoutRepository(repoURL); err != nil {
t.ErrorNow(err)
} else {
defer repo.Delete()
CheckDirectoryContent(t, repo.Dir(), []string{".git"})
}
})
}
示例13: TestInitLocalRepo
func TestInitLocalRepo(t *testing.T) {
LocalDirHostTest(t, func(t *testutil.T, local *LocalDirHost) {
t.CheckError(local.InitRepository("foo", nil, nil))
repoURL := local.RepositoryURL("foo")
if stat, err := os.Stat(repoURL); err != nil {
t.ErrorNow(err)
} else if !stat.IsDir() {
t.ErrorNowf("%s is not a directory", repoURL)
} else {
CheckDirectoryContent(t, repoURL, []string{"HEAD", "branches", "config", "description", "hooks", "info", "objects", "refs"})
}
})
}
示例14: TestCreateMatch
func TestCreateMatch(t *testing.T) {
TournamentTest(t, func(t *testutil.T, tm *Tournament) {
p1 := Submission{"p1", "c1"}
p2 := Submission{"p2", "c2"}
if id, err := tm.CreateMatch(CategoryTest, "MapFoo", p1, p2, time.Now()); err != nil {
t.FailNow()
} else if result, err := tm.GetMatchResult(id); err != nil {
t.ErrorNow(err)
} else if result != MatchResultInProgress {
t.FailNow()
}
})
}
示例15: TestPush
func TestPush(t *testing.T) {
LocalDirHostTest(t, func(t *testutil.T, host *LocalDirHost) {
t.CheckError(host.InitRepository("foo", nil, nil))
repoURL := host.RepositoryURL("foo")
var head string
if repo, err := (TempRemote{}).CheckoutRepository(repoURL); err != nil {
t.ErrorNow(err)
} else {
defer repo.Delete()
t.CheckError(ioutil.WriteFile(filepath.Join(repo.Dir(), "foo.txt"), []byte("hello"), os.ModePerm))
t.CheckError(repo.AddFiles([]string{"foo.txt"}))
t.CheckError(repo.CommitFiles([]string{"foo.txt"}, "commit message"))
t.CheckError(repo.Push())
if h, err := repo.Head(); err != nil {
t.ErrorNow(err)
} else {
head = h
}
}
if repo, err := (TempRemote{}).CheckoutRepository(repoURL); err != nil {
t.ErrorNow(err)
} else {
defer repo.Delete()
if head2, err := repo.Head(); err != nil {
t.ErrorNow(err)
} else if head != head2 {
t.ErrorNowf("Expected <%v> != Actual <%v>", head, head2)
}
}
})
}