mirror of https://github.com/dirtbags/moth.git
Fix test failure
This commit is contained in:
parent
41a0e6dffc
commit
d9299f5e59
|
@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Writing a new mothball with the same name is now detected and the new mothball loaded (#172)
|
- Writing a new mothball with the same name is now detected and the new mothball loaded (#172)
|
||||||
- Regression test for issue where URL path leading directories were ignored (#144)
|
- Regression test for issue where URL path leading directories were ignored (#144)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Many error messages were changed to start with a lower-case letter,
|
||||||
|
in order to satisfy a new linter check.
|
||||||
|
|
||||||
## [v4.2.2] - 2021-09-30
|
## [v4.2.2] - 2021-09-30
|
||||||
### Added
|
### Added
|
||||||
- `debug.notes` front matter field
|
- `debug.notes` front matter field
|
||||||
|
|
|
@ -9,9 +9,11 @@ import (
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testFiles = []struct {
|
type testFileContents struct {
|
||||||
Name, Body string
|
Name, Body string
|
||||||
}{
|
}
|
||||||
|
|
||||||
|
var testFiles = []testFileContents{
|
||||||
{"puzzles.txt", "1\n3\n2\n"},
|
{"puzzles.txt", "1\n3\n2\n"},
|
||||||
{"answers.txt", "1 answer123\n1 answer456\n2 wat\n"},
|
{"answers.txt", "1 answer123\n1 answer456\n2 wat\n"},
|
||||||
{"1/puzzle.json", `{"name": "moo"}`},
|
{"1/puzzle.json", `{"name": "moo"}`},
|
||||||
|
@ -21,7 +23,7 @@ var testFiles = []struct {
|
||||||
{"3/moo.txt", `moo`},
|
{"3/moo.txt", `moo`},
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mothballs) createMothballWithMoo1(cat string, moo1 string) {
|
func (m *Mothballs) createMothballWithFiles(cat string, contents []testFileContents) {
|
||||||
f, _ := m.Create(fmt.Sprintf("%s.mb", cat))
|
f, _ := m.Create(fmt.Sprintf("%s.mb", cat))
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
|
@ -32,13 +34,19 @@ func (m *Mothballs) createMothballWithMoo1(cat string, moo1 string) {
|
||||||
of, _ := w.Create(file.Name)
|
of, _ := w.Create(file.Name)
|
||||||
of.Write([]byte(file.Body))
|
of.Write([]byte(file.Body))
|
||||||
}
|
}
|
||||||
|
for _, file := range contents {
|
||||||
of, _ := w.Create("1/moo.txt")
|
of, _ := w.Create(file.Name)
|
||||||
of.Write([]byte(moo1))
|
of.Write([]byte(file.Body))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mothballs) createMothball(cat string) {
|
func (m *Mothballs) createMothball(cat string) {
|
||||||
m.createMothballWithMoo1(cat, "moo")
|
m.createMothballWithFiles(
|
||||||
|
cat,
|
||||||
|
[]testFileContents{
|
||||||
|
{"1/moo.txt", "moo"},
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTestMothballs() *Mothballs {
|
func NewTestMothballs() *Mothballs {
|
||||||
|
@ -105,7 +113,12 @@ func TestMothballs(t *testing.T) {
|
||||||
|
|
||||||
goofyText := "bozonics"
|
goofyText := "bozonics"
|
||||||
//time.Sleep(1 * time.Second) // I don't love this, but we need the mtime to increase, and it's only accurate to 1s
|
//time.Sleep(1 * time.Second) // I don't love this, but we need the mtime to increase, and it's only accurate to 1s
|
||||||
m.createMothballWithMoo1("pategory", goofyText)
|
m.createMothballWithFiles(
|
||||||
|
"pategory",
|
||||||
|
[]testFileContents{
|
||||||
|
{"1/moo.txt", goofyText},
|
||||||
|
},
|
||||||
|
)
|
||||||
m.refresh()
|
m.refresh()
|
||||||
if f, _, err := m.Open("pategory", 1, "moo.txt"); err != nil {
|
if f, _, err := m.Open("pategory", 1, "moo.txt"); err != nil {
|
||||||
t.Error("pategory/1/moo.txt", err)
|
t.Error("pategory/1/moo.txt", err)
|
||||||
|
|
Loading…
Reference in New Issue