mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-12 08:23:48 +02:00
6568751320
Allow to change the status message via template option Closes https://github.com/woodpecker-ci/woodpecker/issues/855
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package common
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/woodpecker-ci/woodpecker/server"
|
|
"github.com/woodpecker-ci/woodpecker/server/model"
|
|
)
|
|
|
|
func TestGetBuildStatusContext(t *testing.T) {
|
|
origFormat := server.Config.Server.StatusContextFormat
|
|
origCtx := server.Config.Server.StatusContext
|
|
defer func() {
|
|
server.Config.Server.StatusContextFormat = origFormat
|
|
server.Config.Server.StatusContext = origCtx
|
|
}()
|
|
|
|
repo := &model.Repo{Owner: "user1", Name: "repo1"}
|
|
build := &model.Build{Event: model.EventPull}
|
|
proc := &model.Proc{Name: "lint"}
|
|
|
|
assert.EqualValues(t, "", GetBuildStatusContext(repo, build, proc))
|
|
|
|
server.Config.Server.StatusContext = "ci/woodpecker"
|
|
server.Config.Server.StatusContextFormat = "{{ .context }}/{{ .event }}/{{ .pipeline }}"
|
|
assert.EqualValues(t, "ci/woodpecker/pr/lint", GetBuildStatusContext(repo, build, proc))
|
|
build.Event = model.EventPush
|
|
assert.EqualValues(t, "ci/woodpecker/push/lint", GetBuildStatusContext(repo, build, proc))
|
|
|
|
server.Config.Server.StatusContext = "ci"
|
|
server.Config.Server.StatusContextFormat = "{{ .context }}:{{ .owner }}/{{ .repo }}:{{ .event }}:{{ .pipeline }}"
|
|
assert.EqualValues(t, "ci:user1/repo1:push:lint", GetBuildStatusContext(repo, build, proc))
|
|
}
|