mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-23 10:21:00 +00:00
971cb52032
this adjust the packages that parse the yaml-config-file to match [Terminology](https://woodpecker-ci.org/docs/next/usage/terminology)
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package compiler
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
yaml_types "github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types"
|
|
yaml_base_types "github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types/base"
|
|
)
|
|
|
|
func TestSecretAvailable(t *testing.T) {
|
|
secret := Secret{
|
|
Match: []string{"golang"},
|
|
PluginOnly: false,
|
|
}
|
|
assert.True(t, secret.Available(&yaml_types.Container{
|
|
Image: "golang",
|
|
Commands: yaml_base_types.StringOrSlice{"echo 'this is not a plugin'"},
|
|
}))
|
|
assert.False(t, secret.Available(&yaml_types.Container{
|
|
Image: "not-golang",
|
|
Commands: yaml_base_types.StringOrSlice{"echo 'this is not a plugin'"},
|
|
}))
|
|
// secret only available for "golang" plugin
|
|
secret = Secret{
|
|
Match: []string{"golang"},
|
|
PluginOnly: true,
|
|
}
|
|
assert.True(t, secret.Available(&yaml_types.Container{
|
|
Image: "golang",
|
|
Commands: yaml_base_types.StringOrSlice{},
|
|
}))
|
|
assert.False(t, secret.Available(&yaml_types.Container{
|
|
Image: "not-golang",
|
|
Commands: yaml_base_types.StringOrSlice{},
|
|
}))
|
|
assert.False(t, secret.Available(&yaml_types.Container{
|
|
Image: "not-golang",
|
|
Commands: yaml_base_types.StringOrSlice{"echo 'this is not a plugin'"},
|
|
}))
|
|
}
|