Fix chapter test.

This test content may be moved to a different function.
This commit is contained in:
Benjamin A. Shelton 2026-10-13 13:17:44 -06:00
commit e6e4974ad0
Signed by: zancarius
GPG key ID: 8BD42DBD6C337E01

View file

@ -1,6 +1,7 @@
package bible_test package bible_test
import ( import (
"bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"os" "os"
@ -10,6 +11,11 @@ import (
"go.destrealm.net/vfs" "go.destrealm.net/vfs"
) )
const (
Jude5 string = `Although you are fully aware of this, I want to remind you that after Jesus had delivered His people out of the land of Egypt, He destroyed those who did not believe.`
Jude6 string = `And the angels who did not stay within their own domain but abandoned their proper dwelling—these He has kept in eternal chains under darkness, bound for judgment on that great day.`
)
func loadScripture(s string) (*bible.Chapter, error) { func loadScripture(s string) (*bible.Chapter, error) {
st, err := os.Stat(s) st, err := os.Stat(s)
if err != nil { if err != nil {
@ -37,45 +43,23 @@ func loadScripture(s string) (*bible.Chapter, error) {
} }
func Test_ChapterJSON(t *testing.T) { func Test_ChapterJSON(t *testing.T) {
ch, err := loadScripture("../../data/translations/bsb/GEN/1/chapter.json") testJSON := &bytes.Buffer{}
if err != nil { testJSON.WriteString(`{"numberOfVerses": 25, "chapter": {"number": 1, "content": [{"type": "verse", "number": 5, "content": ["Although you are fully aware of this, I want to remind you that after Jesus", {"noteId": 0}, "had delivered His people out of the land of Egypt, He destroyed those who did not believe."]}, {"type": "verse", "number": 6, "content": ["And the angels who did not stay within their own domain but abandoned their proper dwelling\u2014these He has kept in eternal chains under darkness, bound for judgment on that great day."]}]}}`)
c := &bible.Chapter{}
if err := json.Unmarshal(testJSON.Bytes(), c); err != nil {
t.Fatal(err) t.Fatal(err)
} }
/*fmt.Println(ch) vv := c.FilterVerses(5, 5)
fmt.Println(ch.ChapterDecl) if vv.String() != Jude5 {
fmt.Println("length:", len(ch.ChapterDecl.Content)) t.Error("Jude 5 did not match as expected:", vv.String())
fmt.Println(ch.NumVerses, ch.ChapterDecl.Number)*/
if ch.NumVerses != 31 {
t.Errorf("expected 31 verses in Genesis 1, got %d", ch.NumVerses)
}
if ch.ChapterDecl.Number != 1 {
t.Errorf("metadata should report chapter '1'; received: %d", ch.ChapterDecl.Number)
} }
/*for _, c := range ch.ChapterDecl.Content { vv = c.FilterVerses(6, 6)
if c.IsVerse { if vv.String() != Jude6 {
fmt.Print(c.Number, " ") t.Error("Jude 6 did not match as expected:", vv.String())
if len(c.Content) > 0 { }
for _, c1 := range c.Content {
if len(c1.Text) > 0 {
fmt.Print(c1.Text, " ")
}
if c1.IsLineBreak {
t.Fatal("line break")
fmt.Print("\n")
}
}
}
}
if c.IsLineBreak {
fmt.Print("\n")
}
}*/
t.Error(".")
} }
func Test_VerseFilter(t *testing.T) { func Test_VerseFilter(t *testing.T) {