HOPE
06/20/2022, 8:32 AMmutation func()
in go. after executing the mutation it will write a (resource, subject, permission)
tuple to authzed.
I'd like to test after i executed func(), does subject
have permission
to resource
.
I am aware of the serve-testing. But I'm wondering how I can put it into my go unittest code.
I'm trying this example https://github.com/authzed/spicedb/blob/main/cmd/spicedb/servetesting_integration_test.go
But it requires building a docker image. And when I removed first two lines
//go:build docker
// +build docker
and run go test
, it pops up error saying
go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:17:47: undefined: v0.RelationTupleTreeNode
vroldanbet
06/20/2022, 9:38 AMgo get ./...
to resolve all module dependencies?
Then you can run the test with
go test --tags=docker ./cmd/spicedb/servetesting_integration_test.go
ok command-line-arguments 0.638s
You'd need to remove the tags: ci
part of the test, as this is part of our CI pipeline, where each branch commit is pushed to a container with tag ci
and the integration test is run against it.HOPE
06/20/2022, 9:39 AMHOPE
06/20/2022, 9:42 AM➜ api git:(@peter/test) go test --tags=docker internal/authz/authz_test.go
# github.com/authzed/spicedb/pkg/proto/core/v1
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:17:47: undefined: v0.RelationTupleTreeNode
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:50:43: undefined: v0.RelationTupleUpdate
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:74:30: undefined: v0.Zookie
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:101:40: undefined: v0.NamespaceDefinition
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:113:44: undefined: v0.NamespaceDefinition
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:122:69: undefined: v0.RelationTupleTreeNode
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:167:60: undefined: v0.NamespaceDefinition
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:179:66: undefined: v0.NamespaceDefinition
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:188:63: undefined: v0.RelationTupleUpdate
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:200:69: undefined: v0.RelationTupleUpdate
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:200:69: too many errors
FAIL command-line-arguments [build failed]
FAIL
HOPE
06/20/2022, 9:42 AMvroldanbet
06/20/2022, 9:42 AMHOPE
06/20/2022, 9:43 AMvroldanbet
06/20/2022, 9:45 AMvroldanbet
06/20/2022, 9:45 AMvroldanbet
06/20/2022, 9:46 AMvroldanbet
06/20/2022, 9:46 AMHOPE
06/20/2022, 9:47 AMvroldanbet
06/20/2022, 9:50 AM`
# github.com/authzed/spicedb/pkg/proto/core/v1
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:17:47: undefined: v0.RelationTupleTreeNode
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:50:43: undefined: v0.RelationTupleUpdate
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:74:30: undefined: v0.Zookie
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:101:40: undefined: v0.NamespaceDefinition
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:113:44: undefined: v0.NamespaceDefinition
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:122:69: undefined: v0.RelationTupleTreeNode
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:167:60: undefined: v0.NamespaceDefinition
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:179:66: undefined: v0.NamespaceDefinition
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:188:63: undefined: v0.RelationTupleUpdate
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:200:69: undefined: v0.RelationTupleUpdate
../../go/pkg/mod/github.com/authzed/spicedb@v1.8.0/pkg/proto/core/v1/util.go:200:69: too many errors
Compilation finished with exit code 2
HOPE
06/20/2022, 9:52 AMvroldanbet
06/20/2022, 9:52 AMHOPE
06/20/2022, 9:53 AMvroldanbet
06/20/2022, 9:54 AMvroldanbet
06/20/2022, 9:54 AM1.8.1
. Do this:
go get github.com/authzed/spicedb@5fbb49830d60325a7fbea47b8155e0d2a9242c2b
vroldanbet
06/20/2022, 9:54 AMgo mod tidy
vroldanbet
06/20/2022, 9:55 AMHOPE
06/20/2022, 9:55 AMvroldanbet
06/20/2022, 2:47 PMauthzed-go
, so you shouldn't need to use an unreleased version of spicedbJoey
06/20/2022, 2:50 PMJoey
06/20/2022, 2:51 PMvroldanbet
06/20/2022, 2:52 PMvroldanbet
06/20/2022, 2:53 PMauthzed-go
client library and the docker containerJoey
06/20/2022, 2:56 PMHOPE
06/21/2022, 2:36 AMHOPE
06/21/2022, 2:38 AMJoey
06/21/2022, 2:45 AMJoey
06/21/2022, 2:46 AMJoey
06/21/2022, 2:46 AMJoey
06/21/2022, 2:47 AMJoey
06/21/2022, 2:47 AMHOPE
06/21/2022, 3:50 AM