Add inline templates to the CLI and library #4

Merged
lilleman merged 23 commits from cli-inline-template into main 2026-09-03 21:20:26 +02:00
2 changed files with 22 additions and 0 deletions
Showing only changes of commit 4d58c93757 - Show all commits
+14
View File
@@ -333,6 +333,20 @@ func TestRunInlineTemplate(t *testing.T) {
} }
} }
func TestRunTemplateMisuse(t *testing.T) {
for _, arg := range []string{
"{bad", // unterminated brace
"[red,green]", // a near-miss JSON array (unquoted strings)
`{"format":"x"}`, // an object holding only a format
"{/no.such.path}", // a reference into nothing
} {
code, out, errb := runOut("--seed", "1", arg)
if code != 2 || out != "" || !strings.Contains(errb, "try 'fejkdata --help'") {
t.Errorf("run(%q) = %d, %q, %q; want misuse naming --help", arg, code, out, errb)
}
}
}
func TestRunNoShippedData(t *testing.T) { func TestRunNoShippedData(t *testing.T) {
code, list, errb := runOut("--no-shipped-data", "-d", svSE, "--list") code, list, errb := runOut("--no-shipped-data", "-d", svSE, "--list")
if code != 0 { if code != 0 {
+8
View File
@@ -76,6 +76,14 @@ func TestFakeTemplateDeterministic(t *testing.T) {
} }
} }
func TestBareStringReferenceHint(t *testing.T) {
f := shipped(t)
_, err := f.FakeTemplate(`{sv_SE.person.last}`)
if err == nil || !strings.Contains(err.Error(), "write {/sv_SE.person.last}") {
t.Fatalf("FakeTemplate(bare token) = %v, want a hint naming {/sv_SE.person.last}", err)
}
}
func TestFakeTemplateErrors(t *testing.T) { func TestFakeTemplateErrors(t *testing.T) {
f := shipped(t) f := shipped(t)
for _, c := range []struct { for _, c := range []struct {