40 lines
957 B
Go
40 lines
957 B
Go
package executor
|
||
|
||
import (
|
||
"github.com/magiconair/properties/assert"
|
||
"testing"
|
||
)
|
||
|
||
var emptyFilePath = "/home/wdd/IdeaProjects/ProjectOctopus/agent-go/executor/script/123"
|
||
var noExistFilePath = "/home/wdd/IdeaProjects/ProjectOctopus/agent-go/executor/script/456"
|
||
|
||
func TestBasicFileExistAndNotNull(t *testing.T) {
|
||
|
||
resultOK := BasicFileExistAndNotNull(emptyFilePath)
|
||
|
||
assert.Equal(t, resultOK, false, "判定为空文件返回false!")
|
||
|
||
}
|
||
|
||
func TestBasicReplaceFileNotExists(t *testing.T) {
|
||
|
||
replace := BasicReplace(noExistFilePath, "123", "123")
|
||
|
||
t.Logf("replace no exists file result are => %#v", replace)
|
||
|
||
}
|
||
|
||
func TestBasicFileExists(t *testing.T) {
|
||
|
||
exists := BasicFileExists(emptyFilePath)
|
||
|
||
assert.Equal(t, exists, true, "文件存在,但是为空,应该返回true!")
|
||
}
|
||
|
||
func TestBasicFileExistFalse(t *testing.T) {
|
||
|
||
exists := BasicFileExists(noExistFilePath)
|
||
|
||
assert.Equal(t, exists, false, "文件不存在,应该返回false!")
|
||
}
|