carvalhorr / protoc-gen-mock

47 stars 11 forks source link

issue with repeated #17

Closed jfgosselin closed 4 years ago

jfgosselin commented 4 years ago

Hi ,

I've tried your mock with a repeated field:

    syntax = "proto3";

    package carvalhorr.greeter;

    option go_package = ".;greeter_service";

    service Greeter {
        rpc Hello(Request) returns (Response) {}
    }

    message Request {
        string name = 1;

        repeated ABC abc = 2;
        message ABC {
        string key = 1;
        }

    }

    message Response {
        string greeting = 1;
    }

But I get the following error:

    panic: runtime error: comparing uncomparable type []interface {}

    goroutine 68 [running]:
    github.com/carvalhorr/protoc-gen-mock/stub.jsonStringMatches(0xc000255020, 0xc000255080, 0x1, 0x459ad00)
        /Users/jfgosse/golang/src/github.com/carvalhorr/protoc-gen-mock/stub/model.go:123 +0x287
    github.com/carvalhorr/protoc-gen-mock/stub.(*JsonString).Equals(0xc000207930, 0xc00002e1b0, 0x28, 0xc000207700)
        /Users/jfgosse/golang/src/github.com/carvalhorr/protoc-gen-mock/stub/model.go:103 +0x12c
    github.com/carvalhorr/protoc-gen-mock/stub.(*stubsMatcher).Match(0xc0001906b0, 0x4780840, 0xc000254f00, 0x46b3597, 0x21, 0xc00002e1b0, 0x28, 0x0)
        /Users/jfgosse/golang/src/github.com/carvalhorr/protoc-gen-mock/stub/matcher.go:35 +0x1c1
    github.com/carvalhorr/protoc-gen-mock/grpchandler.glob..func1(0x4780840, 0xc000254f00, 0x47708c0, 0xc0001906b0, 0x46b3597, 0x21, 0x463aac0, 0xc00026ebe0, 0x4627680, 0xc00007c580, ...)
        /Users/jfgosse/golang/src/github.com/carvalhorr/protoc-gen-mock/grpchandler/handler.go:19 +0xcc
    greeter-service._Greeter_Hello_MockHandler(0x46458c0, 0xc0000b5200, 0x4780840, 0xc000254f00, 0xc0000324e0, 0x0, 0x4780840, 0xc000254f00, 0xc00002a490, 0x10)
        /Users/jfgosse/golang/src/greeter-service/greeter.mock.pb.go:102 +0x10e
    google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001fc1c0, 0x4787e40, 0xc000272900, 0xc0002a2100, 0xc0001613e0, 0x4b742e0, 0x0, 0x0, 0x0)
        /Users/jfgosse/golang/src/google.golang.org/grpc/server.go:1171 +0x4fd
    google.golang.org/grpc.(*Server).handleStream(0xc0001fc1c0, 0x4787e40, 0xc000272900, 0xc0002a2100, 0x0)
        /Users/jfgosse/golang/src/google.golang.org/grpc/server.go:1494 +0xd25
    google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc00002a384, 0xc0001fc1c0, 0x4787e40, 0xc000272900, 0xc0002a2100)
        /Users/jfgosse/golang/src/google.golang.org/grpc/server.go:834 +0xbb
    created by google.golang.org/grpc.(*Server).serveStreams.func1
        /Users/jfgosse/golang/src/google.golang.org/grpc/server.go:832 +0x204
carvalhorr commented 4 years ago

Good catch. I will work on it in the next few days