mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Added test for err fix
This commit is contained in:
parent
91b3fb2af3
commit
688fe55bb9
@ -15,11 +15,16 @@ func TestGetLogger(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type parseSnippetScenario struct {
|
type parseSnippetScenario struct {
|
||||||
snippet string
|
snippet string
|
||||||
expected *yaml.Node
|
expected *yaml.Node
|
||||||
|
expectedError string
|
||||||
}
|
}
|
||||||
|
|
||||||
var parseSnippetScenarios = []parseSnippetScenario{
|
var parseSnippetScenarios = []parseSnippetScenario{
|
||||||
|
{
|
||||||
|
snippet: ":",
|
||||||
|
expectedError: "yaml: did not find expected key",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
snippet: "",
|
snippet: "",
|
||||||
expected: &yaml.Node{
|
expected: &yaml.Node{
|
||||||
@ -82,6 +87,14 @@ var parseSnippetScenarios = []parseSnippetScenario{
|
|||||||
func TestParseSnippet(t *testing.T) {
|
func TestParseSnippet(t *testing.T) {
|
||||||
for _, tt := range parseSnippetScenarios {
|
for _, tt := range parseSnippetScenarios {
|
||||||
actual, err := parseSnippet(tt.snippet)
|
actual, err := parseSnippet(tt.snippet)
|
||||||
|
if tt.expectedError != "" {
|
||||||
|
if err == nil {
|
||||||
|
t.Errorf("Expected error '%v' but it worked!", tt.expectedError)
|
||||||
|
} else {
|
||||||
|
test.AssertResultComplexWithContext(t, tt.expectedError, err.Error(), tt.snippet)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(tt.snippet)
|
t.Error(tt.snippet)
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user