moth/cmd/mothd/theme_test.go

24 lines
457 B
Go
Raw Normal View History

2019-12-05 22:25:03 -07:00
package main
import (
"github.com/spf13/afero"
2020-02-29 18:36:59 -07:00
"io/ioutil"
2020-02-29 22:37:22 -07:00
"testing"
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
}
}