diff options
author | obscuren <geffobscura@gmail.com> | 2014-11-19 02:48:35 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-11-19 02:48:35 +0800 |
commit | 675ba4d7eb7ab96fa74b803085f042a25f8d8d42 (patch) | |
tree | cc8ee5c2cd3f80e943a336d9820539ea2ebce4d2 /ethutil/path_test.go | |
parent | f8d0cd9906a1ec4a4a1e95868a279312363f8b49 (diff) | |
parent | 5c958ec5f658709b648647449ce5349aa98b3d5d (diff) | |
download | dexon-675ba4d7eb7ab96fa74b803085f042a25f8d8d42.tar dexon-675ba4d7eb7ab96fa74b803085f042a25f8d8d42.tar.gz dexon-675ba4d7eb7ab96fa74b803085f042a25f8d8d42.tar.bz2 dexon-675ba4d7eb7ab96fa74b803085f042a25f8d8d42.tar.lz dexon-675ba4d7eb7ab96fa74b803085f042a25f8d8d42.tar.xz dexon-675ba4d7eb7ab96fa74b803085f042a25f8d8d42.tar.zst dexon-675ba4d7eb7ab96fa74b803085f042a25f8d8d42.zip |
Merge branch 'tests' into poc8
Diffstat (limited to 'ethutil/path_test.go')
-rw-r--r-- | ethutil/path_test.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/ethutil/path_test.go b/ethutil/path_test.go new file mode 100644 index 000000000..908c94ee7 --- /dev/null +++ b/ethutil/path_test.go @@ -0,0 +1,51 @@ +package ethutil + +import ( + // "os" + "testing" +) + +func TestGoodFile(t *testing.T) { + goodpath := "~/goethereumtest.pass" + path := ExpandHomePath(goodpath) + contentstring := "3.14159265358979323846" + + err := WriteFile(path, []byte(contentstring)) + if err != nil { + t.Error("Could not write file") + } + + if !FileExist(path) { + t.Error("File not found at", path) + } + + v, err := ReadAllFile(path) + if err != nil { + t.Error("Could not read file", path) + } + if v != contentstring { + t.Error("Expected", contentstring, "Got", v) + } + +} + +func TestBadFile(t *testing.T) { + badpath := "/this/path/should/not/exist/goethereumtest.fail" + path := ExpandHomePath(badpath) + contentstring := "3.14159265358979323846" + + err := WriteFile(path, []byte(contentstring)) + if err == nil { + t.Error("Wrote file, but should not be able to", path) + } + + if FileExist(path) { + t.Error("Found file, but should not be able to", path) + } + + v, err := ReadAllFile(path) + if err == nil { + t.Error("Read file, but should not be able to", v) + } + +} |