30 lines
540 B
Go
30 lines
540 B
Go
package file_test
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"testing"
|
|
|
|
"apigo.cc/gojs"
|
|
_ "apigo.cc/gojs/file"
|
|
"github.com/ssgo/u"
|
|
)
|
|
|
|
func TestHash(t *testing.T) {
|
|
defer os.Remove("test.txt")
|
|
defer os.Remove("test2.txt")
|
|
r, err := gojs.Run(`
|
|
import file from 'apigo.cc/gojs/file'
|
|
file.write('test.txt', 'hello world')
|
|
file.rename('test.txt', 'test2.txt')
|
|
return file.read('test2.txt')
|
|
`, "")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
} else if r != "hello world" {
|
|
t.Fatal("read file error", r)
|
|
} else {
|
|
fmt.Println(u.BGreen("test succeess"))
|
|
}
|
|
}
|