Skip to content

Commit

Permalink
fixup! fix build and test errors due to proto v2 implementation - int…
Browse files Browse the repository at this point in the history
…roduce test_utils.Separator to deal with random whitespaces in string representations - use proto.Equal for comparison of proto Messages, often wrapped in custom functions to suit the particular purpose - use pointers to avoid copying or use proto.Clone where necessary to copy messages

Signed-off-by: Alexander zur Bonsen <alexander.zur.bonsen@tngtech.com>
  • Loading branch information
alexzurbonsen committed Apr 26, 2022
1 parent b21947e commit 9b69b94
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions orc8r/lib/go/protos/marshaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,18 @@ func TestMconfigMarshal(t *testing.T) {
assert.NotNil(t, pdAny)
pdJson, err := protos.MarshalMconfigToString(pdAny)
assert.NoError(t, err)
pipelinedExpectedVal = strings.ReplaceAll(pipelinedExpectedVal, " ", "")
pipelinedExpectedVal = strings.ReplaceAll(pipelinedExpectedVal, "\n", "")
pdJson = strings.ReplaceAll(pdJson, " ", "")
pdJson = strings.ReplaceAll(pdJson, "\n", "")
pipelinedExpectedVal = stripWhitespaceAndLinebreaks(pipelinedExpectedVal)
pdJson = stripWhitespaceAndLinebreaks(pdJson)
assert.Equal(t, pipelinedExpectedVal, pdJson)

marshaledRes, err := protos.MarshalMconfigToString(cfg)
assert.NoError(t, err)
marshaledSrc = strings.ReplaceAll(marshaledSrc, " ", "")
marshaledSrc = strings.ReplaceAll(marshaledSrc, "\n", "")
marshaledRes = strings.ReplaceAll(marshaledRes, " ", "")
marshaledRes = strings.ReplaceAll(marshaledRes, "\n", "")
marshaledSrc = stripWhitespaceAndLinebreaks(marshaledSrc)
marshaledRes = stripWhitespaceAndLinebreaks(marshaledRes)
assert.Equal(t, marshaledSrc, marshaledRes)
}

func stripWhitespaceAndLinebreaks(input string) string {
input = strings.ReplaceAll(input, " ", "")
return strings.ReplaceAll(input, "\n", "")
}

0 comments on commit 9b69b94

Please sign in to comment.