Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pacedotdev/oto
Browse files Browse the repository at this point in the history
  • Loading branch information
matryer committed Nov 13, 2020
2 parents 414ea93 + 1760a73 commit fde060b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
29 changes: 17 additions & 12 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestParse(t *testing.T) {
is.NoErr(err)

is.Equal(def.PackageName, "pleasantries")
is.Equal(len(def.Services), 2) // should be 2 services
is.Equal(len(def.Services), 3) // should be 3 services
is.Equal(def.Services[0].Name, "GreeterService")
is.Equal(def.Services[0].Metadata["strapline"], "A lovely greeter service") // custom metadata
is.Equal(def.Services[0].Comment, `GreeterService is a polite API.
Expand Down Expand Up @@ -102,17 +102,22 @@ You will love it.`)
is.Equal(greetOutputObject.Fields[1].Type.Multiple, false)
is.Equal(greetOutputObject.Fields[1].Type.Package, "")

is.Equal(def.Services[1].Name, "Welcomer")
is.Equal(len(def.Services[1].Methods), 1)
is.Equal(def.Services[1].Name, "StrangeTypesService")
strangeInputObj, err := def.Object(def.Services[1].Methods[0].InputObject.ObjectName)
is.NoErr(err)
is.Equal(strangeInputObj.Fields[0].Type.JSType, "any")

is.Equal(def.Services[2].Name, "Welcomer")
is.Equal(len(def.Services[2].Methods), 1)

is.Equal(def.Services[1].Methods[0].InputObject.TypeName, "WelcomeRequest")
is.Equal(def.Services[1].Methods[0].InputObject.Multiple, false)
is.Equal(def.Services[1].Methods[0].InputObject.Package, "")
is.Equal(def.Services[1].Methods[0].OutputObject.TypeName, "WelcomeResponse")
is.Equal(def.Services[1].Methods[0].OutputObject.Multiple, false)
is.Equal(def.Services[1].Methods[0].OutputObject.Package, "")
is.Equal(def.Services[2].Methods[0].InputObject.TypeName, "WelcomeRequest")
is.Equal(def.Services[2].Methods[0].InputObject.Multiple, false)
is.Equal(def.Services[2].Methods[0].InputObject.Package, "")
is.Equal(def.Services[2].Methods[0].OutputObject.TypeName, "WelcomeResponse")
is.Equal(def.Services[2].Methods[0].OutputObject.Multiple, false)
is.Equal(def.Services[2].Methods[0].OutputObject.Package, "")

welcomeInputObject, err := def.Object(def.Services[1].Methods[0].InputObject.TypeName)
welcomeInputObject, err := def.Object(def.Services[2].Methods[0].InputObject.TypeName)
is.NoErr(err)
is.Equal(welcomeInputObject.Name, "WelcomeRequest")
is.Equal(len(welcomeInputObject.Fields), 4)
Expand Down Expand Up @@ -146,7 +151,7 @@ You will love it.`)
is.Equal(welcomeInputObject.Fields[3].Type.JSType, "boolean")
is.Equal(welcomeInputObject.Fields[3].Type.SwiftType, "Bool")

welcomeOutputObject, err := def.Object(def.Services[1].Methods[0].OutputObject.TypeName)
welcomeOutputObject, err := def.Object(def.Services[2].Methods[0].OutputObject.TypeName)
is.NoErr(err)
is.Equal(welcomeOutputObject.Name, "WelcomeResponse")
is.Equal(len(welcomeOutputObject.Fields), 2)
Expand All @@ -167,7 +172,7 @@ You will love it.`)
is.Equal(welcomeOutputObject.Fields[1].Type.SwiftType, "String")
is.True(welcomeOutputObject.Metadata != nil)

is.Equal(len(def.Objects), 8)
is.Equal(len(def.Objects), 10)
for i := range def.Objects {
switch def.Objects[i].Name {
case "Greeting":
Expand Down
14 changes: 14 additions & 0 deletions parser/testdata/services/pleasantries/strange_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package pleasantries

type StrangeTypesService interface {
DoSomethingStrange(DoSomethingStrangeRequest) DoSomethingStrangeResponse
}

type DoSomethingStrangeRequest struct {
Anything interface{}
}

type DoSomethingStrangeResponse struct {
Value interface{}
Size int
}

0 comments on commit fde060b

Please sign in to comment.