()
| 15 | var opts = conv.Options{} |
| 16 | |
| 17 | func ExampleBinaryConv_Do() { |
| 18 | // get descriptor and data |
| 19 | includeDirs := util_test.MustGitPath("testdata/idl/") // includeDirs is used to find the include files. |
| 20 | desc := proto.FnRequest(proto.GetFnDescFromFile(exampleIDLPath, "ExampleMethod", proto.Options{}, includeDirs)) |
| 21 | |
| 22 | // make BinaryConv |
| 23 | cv := NewBinaryConv(conv.Options{}) |
| 24 | in := readExampleReqProtoBufData() |
| 25 | |
| 26 | // do conversion |
| 27 | out, err := cv.Do(context.Background(), desc, in) |
| 28 | if err != nil { |
| 29 | panic(err) |
| 30 | } |
| 31 | exp := example2.ExampleReq{} |
| 32 | |
| 33 | // use proto.Unmarshal to check proto data validity |
| 34 | err = goproto.Unmarshal(readExampleReqProtoBufData(), &exp) |
| 35 | if err != nil { |
| 36 | panic(err) |
| 37 | } |
| 38 | |
| 39 | // validate result |
| 40 | var act example2.ExampleReq |
| 41 | err = json.Unmarshal([]byte(out), &act) |
| 42 | if err != nil { |
| 43 | panic(err) |
| 44 | } |
| 45 | if !reflect.DeepEqual(exp, act) { |
| 46 | panic("not equal") |
| 47 | } |
| 48 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…