From 404ea4168ea19fb62822667a12ce57766cb7dbed Mon Sep 17 00:00:00 2001 From: mactep Date: Fri, 29 Sep 2023 08:45:48 -0300 Subject: [PATCH] Make `StringifySnapshot` use cupaloy format --- pkg/grpc/snapshot.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/grpc/snapshot.go b/pkg/grpc/snapshot.go index 90faebe..2da5ada 100644 --- a/pkg/grpc/snapshot.go +++ b/pkg/grpc/snapshot.go @@ -1,6 +1,10 @@ package grpc -import "strings" +import ( + "fmt" + "reflect" + "strings" +) type ProtoMessage interface { String() string @@ -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) }