2015-10-10 08:18:54 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
2017-09-20 23:40:33 +00:00
|
|
|
"reflect"
|
2015-10-10 08:18:54 +00:00
|
|
|
"testing"
|
2017-09-20 23:40:33 +00:00
|
|
|
|
|
|
|
yaml "gopkg.in/yaml.v2"
|
2015-10-10 08:18:54 +00:00
|
|
|
)
|
|
|
|
|
2017-02-26 22:01:52 +00:00
|
|
|
func parseData(rawData string) yaml.MapSlice {
|
|
|
|
var parsedData yaml.MapSlice
|
2015-10-10 08:18:54 +00:00
|
|
|
err := yaml.Unmarshal([]byte(rawData), &parsedData)
|
|
|
|
if err != nil {
|
2017-09-20 23:40:33 +00:00
|
|
|
fmt.Printf("Error parsing yaml: %v\n", err)
|
2015-10-10 08:18:54 +00:00
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
return parsedData
|
|
|
|
}
|
|
|
|
|
|
|
|
func assertResult(t *testing.T, expectedValue interface{}, actualValue interface{}) {
|
|
|
|
if expectedValue != actualValue {
|
|
|
|
t.Error("Expected <", expectedValue, "> but got <", actualValue, ">", fmt.Sprintf("%T", actualValue))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-20 23:40:33 +00:00
|
|
|
func assertResultComplex(t *testing.T, expectedValue interface{}, actualValue interface{}) {
|
|
|
|
if !reflect.DeepEqual(expectedValue, actualValue) {
|
|
|
|
t.Error("Expected <", expectedValue, "> but got <", actualValue, ">", fmt.Sprintf("%T", actualValue))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-10 08:18:54 +00:00
|
|
|
func assertResultWithContext(t *testing.T, expectedValue interface{}, actualValue interface{}, context interface{}) {
|
|
|
|
|
|
|
|
if expectedValue != actualValue {
|
|
|
|
t.Error(context)
|
|
|
|
t.Error(": expected <", expectedValue, "> but got <", actualValue, ">")
|
|
|
|
}
|
|
|
|
}
|