mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-27 04:11:03 +00:00
05f26bab00
Actually wanted to add this to #3030 but @6543 was too fast…
31 lines
735 B
Go
31 lines
735 B
Go
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)
|
|
|
|
service = Parse([]string{"ENV:value", "ENV2:value2", "ENV3_WITHOUT_VALUE"})
|
|
env, err = service.EnvironList(nil)
|
|
assert.NoError(t, err)
|
|
assert.Len(t, env, 2)
|
|
}
|