~reesmichael1/chantpointer

ref: e8f306b2bbd69105afce04178a12356fcae8bc14 chantpointer/saved_test.go -rw-r--r-- 804 bytes View raw
e8f306b2Michael Rees Update URL of personal website 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main

import (
	"bytes"
	"testing"
)

var savedJSON = `{"chant":"line 1\nline 2\n\nab(c 1)23\nword | \"word\"","score":"/tmp/abc/chant.png","scoreName":"fake_name.png","subtitle":"Psalm Subtitle","title":"Psalm Title"}`

func TestSaveChant(t *testing.T) {
	buf := bytes.NewBuffer([]byte{})

	SaveInput(buf, "Psalm Title", "Psalm Subtitle", `line 1
line 2

ab(c 1)23
word | "word"`, "fake_name.png", "/tmp/abc/chant.png")

	equals(t, savedJSON, string(buf.Bytes()))
}

func TestLoadSavedChant(t *testing.T) {
	buf := bytes.NewBufferString(savedJSON)
	s := LoadSaved(buf)

	expected := Saved{
		Chant: `line 1
line 2

ab(c 1)23
word | "word"`,
		Title:     "Psalm Title",
		Subtitle:  "Psalm Subtitle",
		ScorePath: "/tmp/abc/chant.png",
		ScoreName: "fake_name.png",
	}

	equals(t, expected, s)
}