refactor: move files to hrp

This commit is contained in:
debugtalk
2022-03-23 10:36:24 +08:00
parent 452a1a7536
commit 5888c51386
122 changed files with 23288 additions and 23 deletions
+62
View File
@@ -0,0 +1,62 @@
package hrp
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestLocateFile(t *testing.T) {
// specify target file path
_, err := locateFile("../examples/hrp/plugin/debugtalk.go", "debugtalk.go")
if !assert.Nil(t, err) {
t.Fail()
}
// specify path with the same dir
_, err = locateFile("../examples/hrp/plugin/hashicorp.go", "debugtalk.go")
if !assert.Nil(t, err) {
t.Fail()
}
// specify target file path dir
_, err = locateFile("../examples/hrp/plugin/", "debugtalk.go")
if !assert.Nil(t, err) {
t.Fail()
}
// specify wrong path
_, err = locateFile("../examples/hrp", "debugtalk.go")
if !assert.Error(t, err) {
t.Fail()
}
_, err = locateFile("../examples/hrp/demo.json", "debugtalk.go")
if !assert.Error(t, err) {
t.Fail()
}
_, err = locateFile(".", "debugtalk.go")
if !assert.Error(t, err) {
t.Fail()
}
_, err = locateFile("/abc", "debugtalk.go")
if !assert.Error(t, err) {
t.Fail()
}
}
func TestLocatePythonPlugin(t *testing.T) {
_, err := locatePlugin("../examples/hrp/debugtalk.py")
if !assert.Nil(t, err) {
t.Fail()
}
}
func TestLocateGoPlugin(t *testing.T) {
buildHashicorpPlugin()
defer removeHashicorpPlugin()
_, err := locatePlugin("../examples/hrp/debugtalk.bin")
if !assert.Nil(t, err) {
t.Fail()
}
}