mirror of
https://github.com/thegeeklab/drone-yaml.git
synced 2024-11-14 06:20:39 +00:00
61 lines
1.0 KiB
Go
61 lines
1.0 KiB
Go
package yaml
|
|
|
|
import (
|
|
"bytes"
|
|
"io/ioutil"
|
|
"testing"
|
|
)
|
|
|
|
func TestConvert(t *testing.T) {
|
|
tests := []struct {
|
|
before, after string
|
|
}{
|
|
{
|
|
before: "testdata/simple.yml",
|
|
after: "testdata/simple.yml.golden",
|
|
},
|
|
{
|
|
before: "testdata/vault_1.yml",
|
|
after: "testdata/vault_1.yml.golden",
|
|
},
|
|
{
|
|
before: "testdata/vault_2.yml",
|
|
after: "testdata/vault_2.yml.golden",
|
|
},
|
|
{
|
|
before: "testdata/vault_3.yml",
|
|
after: "testdata/vault_3.yml.golden",
|
|
},
|
|
{
|
|
before: "testdata/matrix_1.yml",
|
|
after: "testdata/matrix_1.yml.golden",
|
|
},
|
|
{
|
|
before: "testdata/matrix_2.yml",
|
|
after: "testdata/matrix_2.yml.golden",
|
|
},
|
|
}
|
|
|
|
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(a)
|
|
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))
|
|
}
|
|
}
|
|
}
|