Skip to content

Commit

Permalink
Make StringifySnapshot use cupaloy format
Browse files Browse the repository at this point in the history
  • Loading branch information
mactep committed Sep 29, 2023
1 parent 729c57c commit 404ea41
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/grpc/snapshot.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package grpc

import "strings"
import (
"fmt"
"reflect"
"strings"
)

type ProtoMessage interface {
String() string
Expand All @@ -9,8 +13,9 @@ type ProtoMessage interface {
// StringifySnapshot converts a protobuf response to a string and removes all double spaces.
// This is needed because of a pseudo-random effect https://github.com/golang/protobuf/issues/1121
func StringifySnapshot(resp ProtoMessage) string {
respType := reflect.TypeOf(resp).String()
respStr := resp.String()
respStr = strings.ReplaceAll(respStr, " ", " ")

return respStr
return fmt.Sprintf("(%s)(%s)", respType, respStr)
}

0 comments on commit 404ea41

Please sign in to comment.