2019-12-05 22:25:03 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/afero"
|
|
|
|
"testing"
|
2020-02-29 18:36:59 -07:00
|
|
|
"io/ioutil"
|
2019-12-05 22:25:03 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestTheme(t *testing.T) {
|
|
|
|
fs := new(afero.MemMapFs)
|
2020-02-29 18:36:59 -07:00
|
|
|
index := "this is the index"
|
|
|
|
afero.WriteFile(fs, "/index.html", []byte(index), 0644)
|
2019-12-05 22:25:03 -07:00
|
|
|
|
|
|
|
s := NewTheme(fs)
|
|
|
|
|
2020-02-29 18:36:59 -07:00
|
|
|
if f, err := s.Open("/index.html"); err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
} else if buf, err := ioutil.ReadAll(f); err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
} else if string(buf) != index {
|
|
|
|
t.Error("Read wrong value from index")
|
2019-12-05 22:25:03 -07:00
|
|
|
}
|
|
|
|
}
|