mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-04-15 01:41:56 +00:00
Use Goblin Assert as intended (#501)
this allow for better debugging if an error occur
This commit is contained in:
@@ -68,7 +68,7 @@ func Test_github(t *testing.T) {
|
||||
})
|
||||
g.It("Should handle malformed url", func() {
|
||||
_, err := New(Opts{URL: "%gh&%ij"})
|
||||
g.Assert(err != nil).IsTrue()
|
||||
g.Assert(err).IsNotNil()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -98,7 +98,7 @@ func Test_github(t *testing.T) {
|
||||
g.Describe("Requesting a repository", func() {
|
||||
g.It("Should return the repository details", func() {
|
||||
repo, err := c.Repo(ctx, fakeUser, fakeRepo.Owner, fakeRepo.Name)
|
||||
g.Assert(err == nil).IsTrue()
|
||||
g.Assert(err).IsNil()
|
||||
g.Assert(repo.Owner).Equal(fakeRepo.Owner)
|
||||
g.Assert(repo.Name).Equal(fakeRepo.Name)
|
||||
g.Assert(repo.FullName).Equal(fakeRepo.FullName)
|
||||
@@ -108,21 +108,21 @@ func Test_github(t *testing.T) {
|
||||
})
|
||||
g.It("Should handle a not found error", func() {
|
||||
_, err := c.Repo(ctx, fakeUser, fakeRepoNotFound.Owner, fakeRepoNotFound.Name)
|
||||
g.Assert(err != nil).IsTrue()
|
||||
g.Assert(err).IsNotNil()
|
||||
})
|
||||
})
|
||||
|
||||
g.Describe("Requesting repository permissions", func() {
|
||||
g.It("Should return the permission details", func() {
|
||||
perm, err := c.Perm(ctx, fakeUser, fakeRepo.Owner, fakeRepo.Name)
|
||||
g.Assert(err == nil).IsTrue()
|
||||
g.Assert(err).IsNil()
|
||||
g.Assert(perm.Admin).IsTrue()
|
||||
g.Assert(perm.Push).IsTrue()
|
||||
g.Assert(perm.Pull).IsTrue()
|
||||
})
|
||||
g.It("Should handle a not found error", func() {
|
||||
_, err := c.Perm(ctx, fakeUser, fakeRepoNotFound.Owner, fakeRepoNotFound.Name)
|
||||
g.Assert(err != nil).IsTrue()
|
||||
g.Assert(err).IsNotNil()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -37,18 +37,18 @@ func Test_parser(t *testing.T) {
|
||||
req.Header.Set(hookEvent, "issues")
|
||||
|
||||
r, b, err := parseHook(req, false)
|
||||
g.Assert(r == nil).IsTrue()
|
||||
g.Assert(b == nil).IsTrue()
|
||||
g.Assert(err == nil).IsTrue()
|
||||
g.Assert(r).IsNil()
|
||||
g.Assert(b).IsNil()
|
||||
g.Assert(err).IsNil()
|
||||
})
|
||||
|
||||
g.Describe("given a push hook", func() {
|
||||
g.It("should skip when action is deleted", func() {
|
||||
raw := []byte(fixtures.HookPushDeleted)
|
||||
r, b, err := parsePushHook(raw)
|
||||
g.Assert(r == nil).IsTrue()
|
||||
g.Assert(b == nil).IsTrue()
|
||||
g.Assert(err == nil).IsTrue()
|
||||
g.Assert(r).IsNil()
|
||||
g.Assert(b).IsNil()
|
||||
g.Assert(err).IsNil()
|
||||
})
|
||||
g.It("should extract repository and build details", func() {
|
||||
buf := bytes.NewBufferString(fixtures.HookPush)
|
||||
@@ -57,9 +57,9 @@ func Test_parser(t *testing.T) {
|
||||
req.Header.Set(hookEvent, hookPush)
|
||||
|
||||
r, b, err := parseHook(req, false)
|
||||
g.Assert(err == nil).IsTrue()
|
||||
g.Assert(r != nil).IsTrue()
|
||||
g.Assert(b != nil).IsTrue()
|
||||
g.Assert(err).IsNil()
|
||||
g.Assert(r).IsNotNil()
|
||||
g.Assert(b).IsNotNil()
|
||||
g.Assert(b.Event).Equal(model.EventPush)
|
||||
expectedFiles := []string{"CHANGELOG.md", "app/controller/application.rb"}
|
||||
g.Assert(b.ChangedFiles).Equal(expectedFiles)
|
||||
@@ -70,16 +70,16 @@ func Test_parser(t *testing.T) {
|
||||
g.It("should skip when action is not open or sync", func() {
|
||||
raw := []byte(fixtures.HookPullRequestInvalidAction)
|
||||
r, b, err := parsePullHook(raw, false)
|
||||
g.Assert(r == nil).IsTrue()
|
||||
g.Assert(b == nil).IsTrue()
|
||||
g.Assert(err == nil).IsTrue()
|
||||
g.Assert(r).IsNil()
|
||||
g.Assert(b).IsNil()
|
||||
g.Assert(err).IsNil()
|
||||
})
|
||||
g.It("should skip when state is not open", func() {
|
||||
raw := []byte(fixtures.HookPullRequestInvalidState)
|
||||
r, b, err := parsePullHook(raw, false)
|
||||
g.Assert(r == nil).IsTrue()
|
||||
g.Assert(b == nil).IsTrue()
|
||||
g.Assert(err == nil).IsTrue()
|
||||
g.Assert(r).IsNil()
|
||||
g.Assert(b).IsNil()
|
||||
g.Assert(err).IsNil()
|
||||
})
|
||||
g.It("should extract repository and build details", func() {
|
||||
buf := bytes.NewBufferString(fixtures.HookPullRequest)
|
||||
@@ -88,9 +88,9 @@ func Test_parser(t *testing.T) {
|
||||
req.Header.Set(hookEvent, hookPull)
|
||||
|
||||
r, b, err := parseHook(req, false)
|
||||
g.Assert(err == nil).IsTrue()
|
||||
g.Assert(r != nil).IsTrue()
|
||||
g.Assert(b != nil).IsTrue()
|
||||
g.Assert(err).IsNil()
|
||||
g.Assert(r).IsNotNil()
|
||||
g.Assert(b).IsNotNil()
|
||||
g.Assert(b.Event).Equal(model.EventPull)
|
||||
})
|
||||
})
|
||||
@@ -103,9 +103,9 @@ func Test_parser(t *testing.T) {
|
||||
req.Header.Set(hookEvent, hookDeploy)
|
||||
|
||||
r, b, err := parseHook(req, false)
|
||||
g.Assert(err == nil).IsTrue()
|
||||
g.Assert(r != nil).IsTrue()
|
||||
g.Assert(b != nil).IsTrue()
|
||||
g.Assert(err).IsNil()
|
||||
g.Assert(r).IsNotNil()
|
||||
g.Assert(b).IsNotNil()
|
||||
g.Assert(b.Event).Equal(model.EventDeploy)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user