mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-17 22:16:30 +00:00
Merge pull request #1757 from appleboy/patch-4
Testing author label length limitation for Bitbucket server. [CI SKIP]
This commit is contained in:
commit
fe750c751a
3 changed files with 59 additions and 65 deletions
|
@ -67,11 +67,10 @@ func convertPushHook(hook *internal.PostHook, baseURL string) *model.Build {
|
||||||
name := refParts[2]
|
name := refParts[2]
|
||||||
commitType := refParts[1]
|
commitType := refParts[1]
|
||||||
|
|
||||||
|
|
||||||
//Ensuring the author label is not longer then 40 for the label of the commit author (default size in the db)
|
//Ensuring the author label is not longer then 40 for the label of the commit author (default size in the db)
|
||||||
authorLabel := hook.Changesets.Values[0].ToCommit.Author.Name
|
authorLabel := hook.Changesets.Values[0].ToCommit.Author.Name
|
||||||
if (len(authorLabel) > 40) {
|
if len(authorLabel) > 40 {
|
||||||
authorLabel = authorLabel[0:40]
|
authorLabel = authorLabel[0:37] + "..."
|
||||||
}
|
}
|
||||||
|
|
||||||
build := &model.Build{
|
build := &model.Build{
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package bitbucketserver
|
package bitbucketserver
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
"github.com/drone/drone/model"
|
"github.com/drone/drone/model"
|
||||||
"github.com/drone/drone/remote/bitbucketserver/internal"
|
"github.com/drone/drone/remote/bitbucketserver/internal"
|
||||||
"github.com/franela/goblin"
|
"github.com/franela/goblin"
|
||||||
"github.com/mrjones/oauth"
|
"github.com/mrjones/oauth"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_helper(t *testing.T) {
|
func Test_helper(t *testing.T) {
|
||||||
|
@ -14,7 +13,6 @@ func Test_helper(t *testing.T) {
|
||||||
g := goblin.Goblin(t)
|
g := goblin.Goblin(t)
|
||||||
g.Describe("Bitbucket Server converter", func() {
|
g.Describe("Bitbucket Server converter", func() {
|
||||||
|
|
||||||
|
|
||||||
g.It("should convert repository lite", func() {
|
g.It("should convert repository lite", func() {
|
||||||
from := &internal.Repo{}
|
from := &internal.Repo{}
|
||||||
from.Project.Key = "octocat"
|
from.Project.Key = "octocat"
|
||||||
|
@ -26,7 +24,6 @@ func Test_helper(t *testing.T) {
|
||||||
g.Assert(to.Name).Equal("hello-world")
|
g.Assert(to.Name).Equal("hello-world")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
g.It("should convert repository", func() {
|
g.It("should convert repository", func() {
|
||||||
from := &internal.Repo{
|
from := &internal.Repo{
|
||||||
Slug: "hello-world",
|
Slug: "hello-world",
|
||||||
|
@ -72,8 +69,6 @@ func Test_helper(t *testing.T) {
|
||||||
g.Assert(result.Token).Equal("foo")
|
g.Assert(result.Token).Equal("foo")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
g.It("should convert push hook to build", func() {
|
g.It("should convert push hook to build", func() {
|
||||||
change := internal.PostHook{}
|
change := internal.PostHook{}
|
||||||
|
|
||||||
|
@ -83,7 +78,7 @@ func Test_helper(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
value := internal.Value{}
|
value := internal.Value{}
|
||||||
value.ToCommit.Author.Name = "John Doe"
|
value.ToCommit.Author.Name = "John Doe, Appleboy, Mary, Janet E. Dawson and Ann S. Palmer"
|
||||||
value.ToCommit.Author.EmailAddress = "huh@huh.com"
|
value.ToCommit.Author.EmailAddress = "huh@huh.com"
|
||||||
value.ToCommit.Message = "message"
|
value.ToCommit.Message = "message"
|
||||||
|
|
||||||
|
@ -94,7 +89,8 @@ func Test_helper(t *testing.T) {
|
||||||
|
|
||||||
build := convertPushHook(&change, "http://base.com")
|
build := convertPushHook(&change, "http://base.com")
|
||||||
g.Assert(build.Event).Equal(model.EventPush)
|
g.Assert(build.Event).Equal(model.EventPush)
|
||||||
g.Assert(build.Author).Equal("John Doe")
|
// Ensuring the author label is not longer then 40
|
||||||
|
g.Assert(build.Author).Equal("John Doe, Appleboy, Mary, Janet E. Da...")
|
||||||
g.Assert(build.Avatar).Equal(avatarLink("huh@huh.com"))
|
g.Assert(build.Avatar).Equal(avatarLink("huh@huh.com"))
|
||||||
g.Assert(build.Commit).Equal("73f9c44d")
|
g.Assert(build.Commit).Equal("73f9c44d")
|
||||||
g.Assert(build.Branch).Equal("master")
|
g.Assert(build.Branch).Equal("master")
|
||||||
|
|
|
@ -125,7 +125,6 @@ type Value struct {
|
||||||
} `json:"toCommit"`
|
} `json:"toCommit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type PostHook struct {
|
type PostHook struct {
|
||||||
Changesets struct {
|
Changesets struct {
|
||||||
Filter interface{} `json:"filter"`
|
Filter interface{} `json:"filter"`
|
||||||
|
|
Loading…
Reference in a new issue