forked from gnolang/gno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from berty/chore/again-cherry-pick-Amino-snake_…
…case-and-comments Chore: Again cherry pick amino snake case and comments
- Loading branch information
Showing
5 changed files
with
474 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package genproto | ||
|
||
import ( | ||
"path" | ||
"testing" | ||
|
||
"github.com/gnolang/gno/tm2/pkg/amino" | ||
"github.com/jaekwon/testify/assert" | ||
) | ||
|
||
// message comment | ||
type TestMessageName struct { | ||
// field comment 1 | ||
FieldName1 string | ||
// field comment 2 | ||
FieldName2 []uint64 | ||
} | ||
|
||
// message comment 2 | ||
type TestMessageName2 struct { | ||
// another field comment | ||
FieldName string | ||
} | ||
|
||
func TestComments(t *testing.T) { | ||
pkg := amino.RegisterPackage( | ||
amino.NewPackage( | ||
"github.com/gnolang/gno/tm2/pkg/amino/genproto", | ||
"amino_test", | ||
amino.GetCallersDirname(), | ||
).WithTypes( | ||
&TestMessageName{}, | ||
&TestMessageName2{}, | ||
// Add comments from this same source file. | ||
).WithComments(path.Join(amino.GetCallersDirname(), "comments_test.go"))) | ||
|
||
p3c := NewP3Context() | ||
p3c.RegisterPackage(pkg) | ||
p3c.ValidateBasic() | ||
p3doc := p3c.GenerateProto3SchemaForTypes(pkg, pkg.ReflectTypes()...) | ||
proto3Schema := p3doc.Print() | ||
assert.Equal(t, proto3Schema, `syntax = "proto3"; | ||
package amino_test; | ||
option go_package = "github.com/gnolang/gno/tm2/pkg/amino/genproto/pb"; | ||
// messages | ||
// message comment | ||
message TestMessageName { | ||
// field comment 1 | ||
string field_name1 = 1; | ||
// field comment 2 | ||
repeated uint64 field_name2 = 2; | ||
} | ||
// message comment 2 | ||
message TestMessageName2 { | ||
// another field comment | ||
string field_name = 1; | ||
}`) | ||
} |
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
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
Oops, something went wrong.