Skip to content

Commit

Permalink
fix to replace incorrect tag names retrieved from api meta model (#194)
Browse files Browse the repository at this point in the history
fix to replace incorrect tag names retrieved from api meta model

Made changes to match how the problem was solved using the referenced bug fix in the ovirt-engine-api-metamodel library
  • Loading branch information
mathianasj committed Jan 30, 2020
1 parent 193e35c commit 2be58af
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,14 @@ else if (memberType instanceof StructType || memberType instanceof EnumType) {
else if (memberType instanceof ListType) {
ListType listType = (ListType) memberType;
Type elementType = listType.getElementType();
String elementSingularTag = goNames.getTagStyleName(elementType.getName());
if (elementType instanceof StructType || elementType instanceof EnumType) {
String elementSingularTag;
if(elementType instanceof StructType) {
elementSingularTag = goNames.getTagStyleName(elementType.getName());
} else {
elementSingularTag = goNames.getTagStyleName(names.getSingular(member.getName()));
}

buffer.addLine("%1$s(writer, r, \"%2$s\", \"%3$s\")",
goTypes.getXmlWriteManyFuncName(elementType).getSimpleName(),
tag,
Expand Down
26 changes: 26 additions & 0 deletions sdk/ovirtsdk/writers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,29 @@ func TestCpuWriteOne(t *testing.T) {
string(b.Bytes()))

}

func TestBootDevice(t *testing.T) {
assert := assert.New(t)
var b bytes.Buffer
writer := NewXMLWriter(&b)
boot, err := NewBootBuilder().DevicesOfAny("network").Build()
assert.Nil(err)
err = XMLBootWriteOne(writer, boot, "")
assert.Nil(err)
writer.Flush()
assert.Equal("<boot><devices><device>network</device></devices></boot>",
string(b.Bytes()))
}

func TestBootDevices(t *testing.T) {
assert := assert.New(t)
var b bytes.Buffer
writer := NewXMLWriter(&b)
boot, err := NewBootBuilder().DevicesOfAny("network", "hd").Build()
assert.Nil(err)
err = XMLBootWriteOne(writer, boot, "")
assert.Nil(err)
writer.Flush()
assert.Equal("<boot><devices><device>network</device><device>hd</device></devices></boot>",
string(b.Bytes()))
}

0 comments on commit 2be58af

Please sign in to comment.