-
Notifications
You must be signed in to change notification settings - Fork 8
refactor: parse protos #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,37 +38,3 @@ func TestNewFiles(t *testing.T) { | |
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestParseProtos(t *testing.T) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please improve it, but not deprecate it. |
||
| type args struct { | ||
| protoPaths []string | ||
| protoFiles []string | ||
| } | ||
| tests := []struct { | ||
| name string | ||
| args args | ||
| }{ | ||
| // TODO: Add test cases. | ||
| { | ||
| name: "test1", | ||
| args: args{ | ||
| protoPaths: []string{ | ||
| "../../../../proto", // tableau | ||
| }, | ||
| protoFiles: []string{ | ||
| "tableau/protobuf/unittest/unittest.proto", | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| files, err := ParseProtos(tt.args.protoPaths, tt.args.protoFiles...) | ||
| if err != nil { | ||
| t.Errorf("parseProtos() error = %v", err) | ||
| } | ||
| t.Logf("parsed proto files: %+v", files) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,6 +114,9 @@ type ProtoInputOption struct { | |
| // The enums and messages in ProtoFiles can be used in Excel/CSV/XML/YAML | ||
| // as common types. | ||
| // | ||
| // NOTE: Glob patterns are supported, which can specify sets | ||
| // of filenames with wildcard characters. | ||
| // | ||
| // Default: nil. | ||
| ProtoFiles []string `yaml:"protoFiles"` | ||
|
|
||
|
|
@@ -123,7 +126,7 @@ type ProtoInputOption struct { | |
| // | ||
| // Default: nil. | ||
| Formats []format.Format `yaml:"formats"` | ||
|
|
||
| // Specify only these subdirs (relative to input dir) to be processed. | ||
| // | ||
| // Default: nil. | ||
|
|
@@ -222,10 +225,8 @@ type ConfInputOption struct { | |
|
|
||
| // The files to be parsed to generate configurations. | ||
| // | ||
| // NOTE: | ||
| // - Recognize "*.proto" pattern if not set (value is nil). | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, the default behavior is ok, and should not be removed. It's useful for simple |
||
| // - Glob patterns are supported, which can specify sets | ||
| // of filenames with wildcard characters. | ||
| // NOTE: Glob patterns are supported, which can specify sets | ||
| // of filenames with wildcard characters. | ||
| // | ||
| // Default: nil. | ||
| ProtoFiles []string `yaml:"protoFiles"` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,9 +54,9 @@ func genProto(logLevel, logMode string) error { | |
| Input: &options.ProtoInputOption{ | ||
| ProtoPaths: []string{defaultOutdir}, | ||
| ProtoFiles: []string{ | ||
| "common/base.proto", | ||
| "common/common.proto", | ||
| "common/union.proto", | ||
| filepath.Join(defaultOutdir, "common/base.proto"), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a breaking change, we should describe it in the PR title and description. |
||
| filepath.Join(defaultOutdir, "common/common.proto"), | ||
| filepath.Join(defaultOutdir, "common/union.proto"), | ||
| }, | ||
| Formats: []format.Format{ | ||
| // format.Excel, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The excludedProtoFiles should be tested in unittest.