Skip to content

Commit

Permalink
use protocompile (#644)
Browse files Browse the repository at this point in the history
* pass unit test

* unit test and CLI E2E tests passed

* REPL E2E tests are passed

* fix tests

* delete unnecessary files

* add a test for fully-qualified service name

* add a test for fully-qualified message name

* tweak code/comments
  • Loading branch information
ktr0731 committed Mar 4, 2023
1 parent 5de4a96 commit 117e47a
Show file tree
Hide file tree
Showing 57 changed files with 1,075 additions and 1,194 deletions.
8 changes: 8 additions & 0 deletions e2e/repl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ func TestE2E_REPL(t *testing.T) {
commonFlags: "--proto testdata/test.proto",
input: []interface{}{"service Example", "call Unary", "kaguya"},
},
"call Unary by selecting only fully-qualified service": {
commonFlags: "--proto testdata/test.proto",
input: []interface{}{"service api.Example", "call Unary", "kaguya"},
},
"call Unary by selecting only service (empty package)": {
registerEmptyPackageService: true,
commonFlags: "--proto testdata/empty_package.proto",
Expand Down Expand Up @@ -308,6 +312,10 @@ func TestE2E_REPL(t *testing.T) {
commonFlags: "--proto testdata/test.proto",
input: []interface{}{"desc SimpleRequest"},
},
"desc a fully-qualified message": {
commonFlags: "--proto testdata/test.proto",
input: []interface{}{"desc api.SimpleRequest"},
},
"desc simple message in empty package": {
commonFlags: "--proto testdata/empty_package.proto",
input: []interface{}{"desc SimpleRequest"},
Expand Down
11 changes: 5 additions & 6 deletions e2e/testdata/fixtures/teste2e_oldrepl-desc_a_map.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
+-------+--------------------------------+----------+
| FIELD | TYPE | REPEATED |
+-------+--------------------------------+----------+
| kvs | map<TYPE_STRING, TYPE_MESSAGE | false |
| | (Name)> | |
+-------+--------------------------------+----------+
+-------+-----------------------------+----------+
| FIELD | TYPE | REPEATED |
+-------+-----------------------------+----------+
| kvs | map<string, message (Name)> | false |
+-------+-----------------------------+----------+

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+-------+---------------------+----------+
| FIELD | TYPE | REPEATED |
+-------+---------------------+----------+
| name | TYPE_MESSAGE (Name) | true |
+-------+---------------------+----------+
+-------+----------------+----------+
| FIELD | TYPE | REPEATED |
+-------+----------------+----------+
| name | message (Name) | true |
+-------+----------------+----------+

10 changes: 5 additions & 5 deletions e2e/testdata/fixtures/teste2e_oldrepl-desc_simple_message.golden
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+-------+-------------+----------+
| FIELD | TYPE | REPEATED |
+-------+-------------+----------+
| name | TYPE_STRING | false |
+-------+-------------+----------+
+-------+--------+----------+
| FIELD | TYPE | REPEATED |
+-------+--------+----------+
| name | string | false |
+-------+--------+----------+

28 changes: 5 additions & 23 deletions e2e/testdata/fixtures/teste2e_oldrepl-show_service.golden
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
+---------+---------------------------+-----------------------------+----------------+
| SERVICE | RPC | REQUEST TYPE | RESPONSE TYPE |
+---------+---------------------------+-----------------------------+----------------+
| Example | Unary | SimpleRequest | SimpleResponse |
| Example | UnaryMessage | UnaryMessageRequest | SimpleResponse |
| Example | UnaryRepeated | UnaryRepeatedRequest | SimpleResponse |
| Example | UnaryRepeatedMessage | UnaryRepeatedMessageRequest | SimpleResponse |
| Example | UnaryRepeatedEnum | UnaryRepeatedEnumRequest | SimpleResponse |
| Example | UnarySelf | UnarySelfRequest | SimpleResponse |
| Example | UnaryMap | UnaryMapRequest | SimpleResponse |
| Example | UnaryMapMessage | UnaryMapMessageRequest | SimpleResponse |
| Example | UnaryOneof | UnaryOneofRequest | SimpleResponse |
| Example | UnaryEnum | UnaryEnumRequest | SimpleResponse |
| Example | UnaryBytes | UnaryBytesRequest | SimpleResponse |
| Example | UnaryHeader | UnaryHeaderRequest | SimpleResponse |
| Example | UnaryHeaderTrailer | SimpleRequest | SimpleResponse |
| Example | UnaryHeaderTrailerFailure | SimpleRequest | SimpleResponse |
| Example | UnaryWithMapResponse | SimpleRequest | MapResponse |
| Example | UnaryEcho | UnaryMessageRequest | SimpleResponse |
| Example | ClientStreaming | SimpleRequest | SimpleResponse |
| Example | ServerStreaming | SimpleRequest | SimpleResponse |
| Example | BidiStreaming | SimpleRequest | SimpleResponse |
+---------+---------------------------+-----------------------------+----------------+
+-------------+
| NAME |
+-------------+
| api.Example |
+-------------+

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

{
"message": "kaguya"
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
+-------+--------+----------+
| FIELD | TYPE | REPEATED |
+-------+--------+----------+
| name | string | false |
+-------+--------+----------+

11 changes: 5 additions & 6 deletions e2e/testdata/fixtures/teste2e_repl-desc_a_map.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
+-------+--------------------------------+----------+
| FIELD | TYPE | REPEATED |
+-------+--------------------------------+----------+
| kvs | map<TYPE_STRING, TYPE_MESSAGE | false |
| | (Name)> | |
+-------+--------------------------------+----------+
+-------+-----------------------------+----------+
| FIELD | TYPE | REPEATED |
+-------+-----------------------------+----------+
| kvs | map<string, message (Name)> | false |
+-------+-----------------------------+----------+

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+-------+---------------------+----------+
| FIELD | TYPE | REPEATED |
+-------+---------------------+----------+
| name | TYPE_MESSAGE (Name) | true |
+-------+---------------------+----------+
+-------+----------------+----------+
| FIELD | TYPE | REPEATED |
+-------+----------------+----------+
| name | message (Name) | true |
+-------+----------------+----------+

10 changes: 5 additions & 5 deletions e2e/testdata/fixtures/teste2e_repl-desc_simple_message.golden
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+-------+-------------+----------+
| FIELD | TYPE | REPEATED |
+-------+-------------+----------+
| name | TYPE_STRING | false |
+-------+-------------+----------+
+-------+--------+----------+
| FIELD | TYPE | REPEATED |
+-------+--------+----------+
| name | string | false |
+-------+--------+----------+

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+-------+-------------+----------+
| FIELD | TYPE | REPEATED |
+-------+-------------+----------+
| name | TYPE_STRING | false |
+-------+-------------+----------+
+-------+--------+----------+
| FIELD | TYPE | REPEATED |
+-------+--------+----------+
| name | string | false |
+-------+--------+----------+

28 changes: 5 additions & 23 deletions e2e/testdata/fixtures/teste2e_repl-show_service.golden
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
+---------+---------------------------+-----------------------------+----------------+
| SERVICE | RPC | REQUEST TYPE | RESPONSE TYPE |
+---------+---------------------------+-----------------------------+----------------+
| Example | Unary | SimpleRequest | SimpleResponse |
| Example | UnaryMessage | UnaryMessageRequest | SimpleResponse |
| Example | UnaryRepeated | UnaryRepeatedRequest | SimpleResponse |
| Example | UnaryRepeatedMessage | UnaryRepeatedMessageRequest | SimpleResponse |
| Example | UnaryRepeatedEnum | UnaryRepeatedEnumRequest | SimpleResponse |
| Example | UnarySelf | UnarySelfRequest | SimpleResponse |
| Example | UnaryMap | UnaryMapRequest | SimpleResponse |
| Example | UnaryMapMessage | UnaryMapMessageRequest | SimpleResponse |
| Example | UnaryOneof | UnaryOneofRequest | SimpleResponse |
| Example | UnaryEnum | UnaryEnumRequest | SimpleResponse |
| Example | UnaryBytes | UnaryBytesRequest | SimpleResponse |
| Example | UnaryHeader | UnaryHeaderRequest | SimpleResponse |
| Example | UnaryHeaderTrailer | SimpleRequest | SimpleResponse |
| Example | UnaryHeaderTrailerFailure | SimpleRequest | SimpleResponse |
| Example | UnaryWithMapResponse | SimpleRequest | MapResponse |
| Example | UnaryEcho | UnaryMessageRequest | SimpleResponse |
| Example | ClientStreaming | SimpleRequest | SimpleResponse |
| Example | ServerStreaming | SimpleRequest | SimpleResponse |
| Example | BidiStreaming | SimpleRequest | SimpleResponse |
+---------+---------------------------+-----------------------------+----------------+
+-------------+
| NAME |
+-------------+
| api.Example |
+-------------+

10 changes: 7 additions & 3 deletions fill/filler.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// Package fill provides fillers that fills each field with a value.
package fill

import "errors"
import (
"errors"

"google.golang.org/protobuf/types/dynamicpb"
)

var (
ErrCodecMismatch = errors.New("unsupported codec (could be invalid JSON format)")
Expand All @@ -15,7 +19,7 @@ type Filler interface {
// - io.EOF: At the end of input.
// - ErrCodecMismatch: If v isn't a supported type.
//
Fill(v interface{}) error
Fill(v *dynamicpb.Message) error
}

// InteractiveFillerOpts represents options for InteractiveFiller.
Expand All @@ -41,5 +45,5 @@ type InteractiveFiller interface {
// - io.EOF: At the end of input.
// - ErrCodecMismatch: If v isn't a supported type.
//
Fill(v interface{}, opts InteractiveFillerOpts) error
Fill(v *dynamicpb.Message, opts InteractiveFillerOpts) error
}
107 changes: 0 additions & 107 deletions fill/proto/convert.go

This file was deleted.

0 comments on commit 117e47a

Please sign in to comment.