-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(genaip): invalid code generation for top-level singletons
The `fmt` and `strings` packages are imported but not used, resulting in compile errors. Closes #310
- Loading branch information
Showing
4 changed files
with
104 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
cmd/protoc-gen-go-aip/internal/genaip/testdata/test/toplevelsingleton/pattern_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package toplevelsingleton | ||
|
||
import ( | ||
"testing" | ||
|
||
"gotest.tools/v3/assert" | ||
) | ||
|
||
func TestConfigResourceName(t *testing.T) { | ||
t.Run("good", func(t *testing.T) { | ||
const pattern = "config" | ||
var name ConfigResourceName | ||
err := name.UnmarshalString(pattern) | ||
assert.NilError(t, err) | ||
|
||
marshalled, err := name.MarshalString() | ||
assert.NilError(t, err) | ||
assert.Equal(t, marshalled, pattern) | ||
}) | ||
|
||
t.Run("invalid", func(t *testing.T) { | ||
var name ConfigResourceName | ||
err := name.UnmarshalString("other") | ||
t.Log(err) | ||
assert.Error(t, err, "parse resource name 'other' with pattern 'config': segment config: got other") | ||
}) | ||
} |
17 changes: 17 additions & 0 deletions
17
cmd/protoc-gen-go-aip/internal/genaip/testdata/test/toplevelsingleton/testdata.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
syntax = "proto3"; | ||
|
||
package test.toplevelsingleton; | ||
|
||
import "google/api/resource.proto"; | ||
|
||
message Config { | ||
option (google.api.resource) = { | ||
type: "test1.testdata/Config" | ||
singular: "config" | ||
plural: "configs" | ||
pattern: "config" | ||
}; | ||
|
||
// The resource name of the config. | ||
string name = 1; | ||
} |
47 changes: 47 additions & 0 deletions
47
cmd/protoc-gen-go-aip/internal/genaip/testdata/test/toplevelsingleton/testdata_aip.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.