Skip to content

Commit

Permalink
Add error test case, get coverager to 100
Browse files Browse the repository at this point in the history
  • Loading branch information
stevededalus committed Aug 2, 2017
1 parent e4164ab commit aeaa667
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions codegen/type_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,12 @@ func addSpecToMap(
)
}
}
if overrideMap[k].Field == nil {
return overrideMap, errors.Errorf(
"Failed to find field ( %s ) for transform.",
v.QualifiedName,
)
}
}
return overrideMap, nil
}
35 changes: 35 additions & 0 deletions codegen/type_converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1574,3 +1574,38 @@ func TestConverterMapMapTypeIncompatabile(t *testing.T) {
err.Error(),
)
}

func TestConverterInvalidMapping(t *testing.T) {
fieldMap := make(map[string]codegen.FieldMapperEntry)
fieldMap["Two"] = codegen.FieldMapperEntry{
QualifiedName: "Garbage",
Override: true,
}

lines, err := convertTypes(
"Foo", "Bar",
`
struct Inner {
1: optional string field
}
struct Foo {
1: optional map<string, Inner> one
2: optional map<string, string> two
}
struct Bar {
1: optional map<string, Inner> one
2: optional map<string, Inner> two
}`,
nil,
fieldMap,
)

assert.Error(t, err)
assert.Equal(t, "", lines)
assert.Equal(t,
"Failed to find field ( Garbage ) for transform.",
err.Error(),
)
}

0 comments on commit aeaa667

Please sign in to comment.