2015-10-03 07:25:13 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2015-10-07 23:31:31 +00:00
|
|
|
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"},
|
|
|
|
}
|
|
|
|
|
2015-10-07 23:31:31 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2015-10-09 10:24:42 +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"})
|
|
|
|
}
|