mirror of
https://github.com/sbrow/ps.git
synced 2025-12-29 18:47:38 -05:00
improved robustness
more tests added.
This commit is contained in:
45
ps_test.go
45
ps_test.go
@@ -2,7 +2,6 @@ package ps
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
_ "io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
_ "strings"
|
||||
@@ -20,24 +19,24 @@ func TestOpen(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("Skipping \"TestOpen\"")
|
||||
}
|
||||
Open("F:\\GitLab\\dreamkeepers-psd\\Template009.1.psd")
|
||||
}
|
||||
|
||||
// TODO: Comparison borked
|
||||
/*func TestRun(t *testing.T) {
|
||||
out := []byte("Testing...\n")
|
||||
msg, err := run("test")
|
||||
_, err := Open("F:\\GitLab\\dreamkeepers-psd\\Template009.1.psd")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if string(msg) == string(out) {
|
||||
fail := fmt.Sprintf("run(test)\ngot:\t\"%s\"\nwant:\t\"%s\"\n", msg, out)
|
||||
}
|
||||
|
||||
func TestRun(t *testing.T) {
|
||||
out := []byte("hello,\r\nworld!\r\n")
|
||||
msg, err := run("test", "hello,", "world!")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if string(msg) != string(out) {
|
||||
fail := fmt.Sprintf("TestRun faild.\ngot:\n\"%s\"\nwant:\n\"%s\"\n", msg, out)
|
||||
t.Fatal(fail)
|
||||
} else {
|
||||
os.Remove(path.Join(pkgpath, "scripts", "test.txt"))
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
func TestQuit(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("Skipping \"TestQuit\"")
|
||||
@@ -50,21 +49,15 @@ func TestWait(t *testing.T) {
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// TODO: Comparison borked
|
||||
/*func TestJS(t *testing.T) {
|
||||
out := "Testing...\n"
|
||||
_, err := Js(path.Join(Folder, "test.jsx"), Folder)
|
||||
func TestJS(t *testing.T) {
|
||||
out := []byte("F:\\TEMP\\js_out.txt\r\narg\r\nargs\r\n")
|
||||
script := "test.jsx"
|
||||
ret, err := Js(script, "arg", "args")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f, err := ioutil.ReadFile(path.Join(Folder, "test.txt"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if strings.Compare(string(f), string(out)) != 0 {
|
||||
fmt.Println(f)
|
||||
fmt.Println([]byte(out))
|
||||
fail := fmt.Sprintf("TestJS failed.\ngot:\t\"%s\"\nwant:\t\"%s\"", f, out)
|
||||
if string(ret) != string(out) {
|
||||
fail := fmt.Sprintf("TestJS failed.\ngot:\t\"%s\"\nwant:\t\"%s\"", ret, out)
|
||||
t.Fatal(fail)
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user