From d9299f5e59e948edcaff25035d405c5a75c17e80 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Thu, 14 Oct 2021 19:17:38 -0600 Subject: [PATCH] Fix test failure --- CHANGELOG.md | 4 ++++ cmd/mothd/mothballs_test.go | 29 +++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db46649..685cba1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) - 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 ### Added - `debug.notes` front matter field diff --git a/cmd/mothd/mothballs_test.go b/cmd/mothd/mothballs_test.go index 81e82e2..61bcd82 100644 --- a/cmd/mothd/mothballs_test.go +++ b/cmd/mothd/mothballs_test.go @@ -9,9 +9,11 @@ import ( "github.com/spf13/afero" ) -var testFiles = []struct { +type testFileContents struct { Name, Body string -}{ +} + +var testFiles = []testFileContents{ {"puzzles.txt", "1\n3\n2\n"}, {"answers.txt", "1 answer123\n1 answer456\n2 wat\n"}, {"1/puzzle.json", `{"name": "moo"}`}, @@ -21,7 +23,7 @@ var testFiles = []struct { {"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)) defer f.Close() @@ -32,13 +34,19 @@ func (m *Mothballs) createMothballWithMoo1(cat string, moo1 string) { of, _ := w.Create(file.Name) of.Write([]byte(file.Body)) } - - of, _ := w.Create("1/moo.txt") - of.Write([]byte(moo1)) + for _, file := range contents { + of, _ := w.Create(file.Name) + of.Write([]byte(file.Body)) + } } func (m *Mothballs) createMothball(cat string) { - m.createMothballWithMoo1(cat, "moo") + m.createMothballWithFiles( + cat, + []testFileContents{ + {"1/moo.txt", "moo"}, + }, + ) } func NewTestMothballs() *Mothballs { @@ -105,7 +113,12 @@ func TestMothballs(t *testing.T) { 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 - m.createMothballWithMoo1("pategory", goofyText) + m.createMothballWithFiles( + "pategory", + []testFileContents{ + {"1/moo.txt", goofyText}, + }, + ) m.refresh() if f, _, err := m.Open("pategory", 1, "moo.txt"); err != nil { t.Error("pategory/1/moo.txt", err)