Skip to content

Commit

Permalink
add test for query.
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrofolium committed Nov 2, 2023
1 parent a9a6560 commit 8567137
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion cardinal/query_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package cardinal_test

import (
"pkg.world.dev/world-engine/cardinal/testutils"
"errors"
"testing"

"pkg.world.dev/world-engine/cardinal/testutils"

"gotest.tools/v3/assert"

"pkg.world.dev/world-engine/cardinal"
)

Expand Down Expand Up @@ -40,6 +43,24 @@ func handleQueryHealth(worldCtx cardinal.WorldContext, request *QueryHealthReque
return resp, nil
}

func TestNewQueryTypeWithEVMSupport(_ *testing.T) {
// This test just makes sure that NeQueryTypeWithEVMSupport maintains api compatibility.
// it is mainly here to check for compiler errors.
type FooReq struct {
X uint64
}
type FooReply struct {
Y uint64
}
cardinal.NewQueryTypeWithEVMSupport[FooReq, FooReply](
"query_health",
func(
_ cardinal.WorldContext,
_ FooReq) (FooReply, error) {
return FooReply{}, errors.New("this function should never get called")
})
}

var queryHealth = cardinal.NewQueryType[*QueryHealthRequest, *QueryHealthResponse]("query_health", handleQueryHealth)

func TestQueryExample(t *testing.T) {
Expand Down

0 comments on commit 8567137

Please sign in to comment.