mirror of
https://github.com/thegeeklab/drone-yaml.git
synced 2024-11-17 23:50:40 +00:00
44 lines
831 B
Go
44 lines
831 B
Go
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
|
// Use of this source code is governed by the Drone Non-Commercial License
|
|
// that can be found in the LICENSE file.
|
|
|
|
package yaml
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
func TestParam(t *testing.T) {
|
|
tests := []struct {
|
|
yaml string
|
|
value interface{}
|
|
from string
|
|
}{
|
|
{
|
|
yaml: "bar",
|
|
value: "bar",
|
|
},
|
|
{
|
|
yaml: "from_secret: username",
|
|
from: "username",
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
in := []byte(test.yaml)
|
|
out := new(Parameter)
|
|
err := yaml.Unmarshal(in, out)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
if got, want := out.Value, test.value; got != want {
|
|
t.Errorf("Want value %q, got %q", want, got)
|
|
}
|
|
if got, want := out.Secret, test.from; got != want {
|
|
t.Errorf("Want from_secret %q, got %q", want, got)
|
|
}
|
|
}
|
|
}
|