From 041e9e14a23a5eb72ab564372458c49240f6d21d Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 23 Apr 2020 21:15:19 +0200 Subject: [PATCH] Add tests for api depending on ffi Signed-off-by: Jakub Sztandera --- api/api_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 api/api_test.go diff --git a/api/api_test.go b/api/api_test.go new file mode 100644 index 000000000..1b438258a --- /dev/null +++ b/api/api_test.go @@ -0,0 +1,34 @@ +package api + +import ( + "os" + "os/exec" + "path/filepath" + "runtime" + "strings" + "testing" +) + +func goCmd() string { + var exeSuffix string + if runtime.GOOS == "windows" { + exeSuffix = ".exe" + } + path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix) + if _, err := os.Stat(path); err == nil { + return path + } + return "go" +} + +func TestDoesntDependOnFFI(t *testing.T) { + deps, err := exec.Command(goCmd(), "list", "-deps", "github.com/filecoin-project/lotus/api").Output() + if err != nil { + t.Fatal(err) + } + for _, pkg := range strings.Fields(string(deps)) { + if pkg == "github.com/filecoin-project/filecoin-ffi" { + t.Fatal("api depends on filecoin-ffi") + } + } +}