yq/yaml_test.go

37 lines
788 B
Go
Raw Normal View History

2015-10-03 07:25:13 +00:00
package main
import (
"testing"
)
var parseValueTests = []struct {
2015-10-03 07:25:13 +00:00
argument string
expectedResult interface{}
testDescription string
}{
{"true", true, "boolean"},
{"\"true\"", "true", "boolean as string"},
{"3.4", 3.4, "number"},
{"\"3.4\"", "3.4", "number as string"},
}
func TestParseValue(t *testing.T) {
for _, tt := range parseValueTests {
assertResultWithContext(t, tt.expectedResult, parseValue(tt.argument), tt.testDescription)
2015-10-03 07:25:13 +00:00
}
}
func TestRead(t *testing.T) {
result := read([]string{"sample.yaml", "b.c"})
assertResult(t, 2, result)
}
func TestUpdateYaml(t *testing.T) {
updateYaml([]string{"sample.yaml", "b.c", "3"})
}
func TestUpdateYaml_WithScript(t *testing.T) {
writeScript = "instruction_sample.yaml"
updateYaml([]string{"sample.yaml"})
}