无法在 membersrvc/ca 中 运行 golang 单元测试
Not able to run golang unit tests inside membersrvc/ca
我已经分叉了 hyperledger/fabric 项目,在我的回购协议中,我尝试 运行 使用以下命令对 ECA 进行单元测试:
但是我收到以下错误:
vagrant@hyperledger-devenv:v0.0.10-37b6688:/opt/gopath/src/github.com/hyperledger/fabric/membersrvc/ca$
go test eca_test.go
command-line-arguments
eca_test.go:30:2:
cannot find package "command-/vendor/github.com/golang/protobuf/proto"
in any of:
/opt/go/src/command-/vendor/github.com/golang/protobuf/proto (from $GOROOT)
/opt/gopath/src/command-/vendor/github.com/golang/protobuf/proto (from
$GOPATH)
FAIL command-line-arguments [setup failed]
同样,当我尝试 运行 CA 单元测试时出现以下错误:
vagrant@hyperledger-devenv:v0.0.10-37b6688:/opt/gopath/src/github.com/hyperledger/fabric/membersrvc/ca$ go test ca_test.go
command-line-arguments
ca_test.go:28:2: cannot find
package "command-/vendor/github.com/spf13/viper" in any of:
/opt/go/src/command-/vendor/github.com/spf13/viper (from $GOROOT)
/opt/gopath/src/command-/vendor/github.com/spf13/viper (from >$GOPATH)
FAIL command-line-arguments [setup failed]
几天前,这些曾经为我工作,但是在我使用 hyperledger/project 的最新更改更新我的叉子后,我无法 运行 测试
这是我的 GOPATH 值:
vagrant@hyperledger-devenv:v0.0.10-37b6688:/opt/gopath/src/github.com/hyperledger/fabric$ echo $GOPATH /opt/gopath
我不确定为什么 golang 构建系统在查找导入包时将 "command-/vendor" 附加到路径。有人可以帮我解决这个问题吗?
根据文档 go test
需要包名称作为参数。
如果您 运行 go test .
并为此包执行所有测试,那么测试应该没有问题。
可以 运行 go test eca_test.go
但在这种情况下,您必须指定构建“eca_test”所需的所有其他文件。有关详细信息,请参阅“How to run test cases in a specified file?”。
如果您想 运行 最好使用此包中的一项测试 go test . -run TestNewECA
“TestNewECA”是eca_test.go中的测试函数名,不是文件名。
我已经分叉了 hyperledger/fabric 项目,在我的回购协议中,我尝试 运行 使用以下命令对 ECA 进行单元测试: 但是我收到以下错误:
vagrant@hyperledger-devenv:v0.0.10-37b6688:/opt/gopath/src/github.com/hyperledger/fabric/membersrvc/ca$ go test eca_test.go
command-line-arguments
eca_test.go:30:2: cannot find package "command-/vendor/github.com/golang/protobuf/proto" in any of:
/opt/go/src/command-/vendor/github.com/golang/protobuf/proto (from $GOROOT)
/opt/gopath/src/command-/vendor/github.com/golang/protobuf/proto (from $GOPATH)
FAIL command-line-arguments [setup failed]
同样,当我尝试 运行 CA 单元测试时出现以下错误:
vagrant@hyperledger-devenv:v0.0.10-37b6688:/opt/gopath/src/github.com/hyperledger/fabric/membersrvc/ca$ go test ca_test.go
command-line-arguments
ca_test.go:28:2: cannot find package "command-/vendor/github.com/spf13/viper" in any of: /opt/go/src/command-/vendor/github.com/spf13/viper (from $GOROOT)
/opt/gopath/src/command-/vendor/github.com/spf13/viper (from >$GOPATH)
FAIL command-line-arguments [setup failed]
几天前,这些曾经为我工作,但是在我使用 hyperledger/project 的最新更改更新我的叉子后,我无法 运行 测试
这是我的 GOPATH 值:
vagrant@hyperledger-devenv:v0.0.10-37b6688:/opt/gopath/src/github.com/hyperledger/fabric$ echo $GOPATH /opt/gopath
我不确定为什么 golang 构建系统在查找导入包时将 "command-/vendor" 附加到路径。有人可以帮我解决这个问题吗?
根据文档 go test
需要包名称作为参数。
如果您 运行 go test .
并为此包执行所有测试,那么测试应该没有问题。
可以 运行 go test eca_test.go
但在这种情况下,您必须指定构建“eca_test”所需的所有其他文件。有关详细信息,请参阅“How to run test cases in a specified file?”。
如果您想 运行 最好使用此包中的一项测试 go test . -run TestNewECA
“TestNewECA”是eca_test.go中的测试函数名,不是文件名。