twosigma / envoy-viz

Apache License 2.0
11 stars 1 forks source link

Add tests to exercise FromFile and {Read,Parse}EnvoyConfig #7

Open blevz opened 3 years ago

skelterjohn commented 3 years ago

Oh, if that's the package you're using then I think you can give it the message objects directly without translating them to maps.

On Thu, Apr 1, 2021, 9:42 AM Ben Levy @.***> wrote:

@.**** commented on this pull request.

In configreader/reader_test.go https://github.com/twosigma/envoy-viz/pull/7#discussion_r605668097:

  • var expectedMap map[string]interface{}
  • if err := json.Unmarshal(expectedBytes, &expectedMap); err != nil {
  • t.Error(err)
  • return
  • }
  • actualBytes, err := protojson.Marshal(actual)
  • if err != nil {
  • t.Error(err)
  • return
  • }
  • var actualMap map[string]interface{}
  • if err := json.Unmarshal(actualBytes, &actualMap); err != nil {
  • t.Error(err)
  • return
  • }
  • if diff := cmp.Diff(expectedMap, actualMap); diff != "" {

Isn't that what I'm using here? Should I be using it differently?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/twosigma/envoy-viz/pull/7#discussion_r605668097, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACRTVVE2QPQGGK7ET6TTOLTGRZ5ZANCNFSM42BGPSBQ .

blevz commented 3 years ago

I couldn't get it to work originally but I think I need to use this: https://pkg.go.dev/google.golang.org/protobuf/testing/protocmp

Will try it and update if it works

Oh, if that's the package you're using then I think you can give it the message objects directly without translating them to maps. On Thu, Apr 1, 2021, 9:42 AM Ben Levy @.> wrote: @*.** commented on this pull request. ------------------------------ In configreader/reader_test.go <#7 (comment)>: > + var expectedMap map[string]interface{} + if err := json.Unmarshal(expectedBytes, &expectedMap); err != nil { + t.Error(err) + return + } + actualBytes, err := protojson.Marshal(actual) + if err != nil { + t.Error(err) + return + } + var actualMap map[string]interface{} + if err := json.Unmarshal(actualBytes, &actualMap); err != nil { + t.Error(err) + return + } + if diff := cmp.Diff(expectedMap, actualMap); diff != "" { Isn't that what I'm using here? Should I be using it differently? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#7 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACRTVVE2QPQGGK7ET6TTOLTGRZ5ZANCNFSM42BGPSBQ .