mirror of
				https://github.com/go-kratos/kratos.git
				synced 2025-10-30 23:47:59 +02:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			599 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			599 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package grpc
 | |
| 
 | |
| import (
 | |
| 	"reflect"
 | |
| 	"testing"
 | |
| 
 | |
| 	"google.golang.org/protobuf/types/known/structpb"
 | |
| )
 | |
| 
 | |
| func TestCodec(t *testing.T) {
 | |
| 	in, err := structpb.NewStruct(map[string]any{"Golang": "Kratos"})
 | |
| 	if err != nil {
 | |
| 		t.Errorf("grpc codec create input data error:%v", err)
 | |
| 	}
 | |
| 	c := codec{}
 | |
| 	data, err := c.Marshal(in)
 | |
| 	if err != nil {
 | |
| 		t.Errorf("grpc codec marshal error:%v", err)
 | |
| 	}
 | |
| 	out := &structpb.Struct{}
 | |
| 	err = c.Unmarshal(data, out)
 | |
| 	if err != nil {
 | |
| 		t.Errorf("grpc codec unmarshal error:%v", err)
 | |
| 	}
 | |
| 	if !reflect.DeepEqual(in, out) {
 | |
| 		t.Errorf("grpc codec want %v, got %v", in, out)
 | |
| 	}
 | |
| }
 |