2017-08-12 17:48:06 +00:00
|
|
|
package settings
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSettings_Stream(t *testing.T) {
|
|
|
|
s := Settings{}
|
2017-08-27 11:45:46 +00:00
|
|
|
filename := Rand(4)
|
2017-08-12 17:48:06 +00:00
|
|
|
if _, err := s.Stream(filename); err == nil {
|
|
|
|
t.Fatal("Error expected, none found", filename, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
filename = "io.go"
|
|
|
|
if _, err := s.Stream(filename); err != nil {
|
|
|
|
t.Fatal("Error unexpected", filename, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSettings_Write(t *testing.T) {
|
|
|
|
s := Settings{}
|
|
|
|
data := "abcdefgh"
|
|
|
|
d, err := ioutil.TempFile("", "io_test")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if err := s.Write(d.Name(), []byte(data)); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSettings_Create(t *testing.T) {
|
|
|
|
s := Settings{}
|
|
|
|
p, err := os.Getwd()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
f := s.Create(p, "io_test")
|
|
|
|
os.Remove(f.Name())
|
2017-08-14 23:13:30 +00:00
|
|
|
}
|