1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-06-24 22:06:51 +02:00

Add some tests (#3030)

This commit is contained in:
qwerty287
2023-12-27 10:36:49 +01:00
committed by GitHub
parent 5cb0ae053a
commit e575ffe72d
9 changed files with 117 additions and 2 deletions

View File

@ -26,7 +26,7 @@ type builtin struct {
globals []*model.Environ
}
// Parse returns a EnvironService based on a string slice where key and value are separated by a ":" delimiter.
// Parse returns a model.EnvironService based on a string slice where key and value are separated by a ":" delimiter.
func Parse(params []string) model.EnvironService {
var globals []*model.Environ

View File

@ -0,0 +1,26 @@
package environments
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParse(t *testing.T) {
service := Parse([]string{})
env, err := service.EnvironList(nil)
assert.NoError(t, err)
assert.Empty(t, env)
service = Parse([]string{"ENV:value"})
env, err = service.EnvironList(nil)
assert.NoError(t, err)
assert.Len(t, env, 1)
assert.Equal(t, env[0].Name, "ENV")
assert.Equal(t, env[0].Value, "value")
service = Parse([]string{"ENV:value", "ENV2:value2"})
env, err = service.EnvironList(nil)
assert.NoError(t, err)
assert.Len(t, env, 2)
}