mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-06 08:16:19 +02:00
include test
This commit is contained in:
parent
1c9cfcd376
commit
c7c2c13f2c
47
remote/github/github_test.go
Normal file
47
remote/github/github_test.go
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/franela/goblin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestHook(t *testing.T) {
|
||||||
|
var (
|
||||||
|
github Github
|
||||||
|
r *http.Request
|
||||||
|
body *bytes.Buffer
|
||||||
|
)
|
||||||
|
|
||||||
|
g := goblin.Goblin(t)
|
||||||
|
|
||||||
|
g.Describe("Hook", func() {
|
||||||
|
g.BeforeEach(func() {
|
||||||
|
github = Github{}
|
||||||
|
body = bytes.NewBuffer([]byte{})
|
||||||
|
r, _ = http.NewRequest("POST", "https://drone.com/hook", body)
|
||||||
|
})
|
||||||
|
|
||||||
|
g.Describe("For a Pull Request", func() {
|
||||||
|
g.BeforeEach(func() {
|
||||||
|
r.Header.Set("X-Github-Event", "pull_request")
|
||||||
|
})
|
||||||
|
|
||||||
|
g.It("Should set build author to the pull request author", func() {
|
||||||
|
hookJson, err := ioutil.ReadFile("fixtures/pull_request.json")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
body.Write(hookJson)
|
||||||
|
|
||||||
|
_, build, err := github.Hook(r)
|
||||||
|
g.Assert(err).Equal(nil)
|
||||||
|
g.Assert(build.Author).Equal("author")
|
||||||
|
g.Assert(build.Avatar).Equal("https://avatars.githubusercontent.com/u/55555?v=3")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user