drone-yaml/yaml/push_test.go

49 lines
856 B
Go
Raw Normal View History

2019-02-10 19:00:16 +00:00
// 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.
2019-02-10 19:00:16 +00:00
2019-01-22 23:44:17 +00:00
package yaml
import (
"testing"
2019-05-30 01:21:23 +00:00
"github.com/buildkite/yaml"
2019-01-22 23:44:17 +00:00
)
func TestPush(t *testing.T) {
tests := []struct {
yaml string
image string
}{
{
yaml: "foo",
image: "foo",
},
{
yaml: "{ image: foo }",
image: "foo",
},
}
for _, test := range tests {
in := []byte(test.yaml)
out := new(Push)
err := yaml.Unmarshal(in, out)
if err != nil {
t.Error(err)
return
}
if got, want := out.Image, test.image; got != want {
t.Errorf("Want Image %q, got %q", want, got)
}
}
}
func TestPushError(t *testing.T) {
in := []byte("[]")
out := new(Push)
err := yaml.Unmarshal(in, out)
if err == nil {
t.Errorf("Expect unmarshal error")
}
}