aboutsummaryrefslogtreecommitdiff
path: root/internal/cli/liturgy_test.go
blob: c3ab0b41ab3ae1a1e519e1ca282fdbb70d6debaa (plain) (blame)
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
package cli

import (
	"bytes"
	"path/filepath"
	"strings"
	"testing"

	"github.com/lukaszkasprzak/lectio/internal/config"
)

func TestRunLiturgy(t *testing.T) {
	dir := t.TempDir()
	t.Setenv("LECTIO_CONFIG", filepath.Join(dir, "config.ini"))
	cfg, err := config.Load()
	if err != nil {
		t.Fatal(err)
	}
	var buf bytes.Buffer
	if code := runLiturgy(cfg, "2025-08-15", &buf, &buf); code != 0 {
		t.Fatalf("exit code %d", code)
	}
	out := buf.String()
	if !strings.Contains(out, "2025-08-15") {
		t.Errorf("missing date:\n%s", out)
	}
	if !strings.Contains(strings.ToLower(out), "solemnity") || !strings.Contains(out, "Assumption") {
		t.Errorf("2025-08-15 should be the Assumption solemnity:\n%s", out)
	}
	if !strings.Contains(out, "gospel:") {
		t.Errorf("proper reading not shown:\n%s", out)
	}
}