mirror of
https://github.com/thegeeklab/drone-yaml.git
synced 2024-11-29 13:20:36 +00:00
47 lines
819 B
Go
47 lines
819 B
Go
|
package bitbucket
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"io/ioutil"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestConvert(t *testing.T) {
|
||
|
tests := []struct {
|
||
|
before, after, ref string
|
||
|
}{
|
||
|
{
|
||
|
before: "testdata/sample1.yaml",
|
||
|
after: "testdata/sample1.yaml.golden",
|
||
|
ref: "refs/heads/master",
|
||
|
},
|
||
|
{
|
||
|
before: "testdata/sample2.yaml",
|
||
|
after: "testdata/sample2.yaml.golden",
|
||
|
ref: "refs/heads/feature/foo",
|
||
|
},
|
||
|
}
|
||
|
|
||
|
for _, test := range tests {
|
||
|
a, err := ioutil.ReadFile(test.before)
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
return
|
||
|
}
|
||
|
b, err := ioutil.ReadFile(test.after)
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
return
|
||
|
}
|
||
|
c, err := Convert([]byte(a), test.ref)
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
return
|
||
|
}
|
||
|
if bytes.Equal(b, c) == false {
|
||
|
t.Errorf("Unexpected yaml conversion of %s", test.before)
|
||
|
t.Log(string(c))
|
||
|
}
|
||
|
}
|
||
|
}
|