package codescan import ( "errors" "testing" "gitbay.org/gitbay/internal/store" ) func TestUnquotedLines(t *testing.T) { for _, tc := range []struct { name, src string want bool }{ {"quotes inside a quoted value", `x`, false}, {"quoted literal in a quoted value", ``, false}, {"single quotes", ``, false}, {"action adding a name", ``, false}, {"handlebars block", ``, false}, {"comment", `

`, false}, {"jinja statement", `

{{ title }}

`, false}, {"script body", "", false}, {"html comment", ``, false}, {"unquoted value", `
`, true}, {"unquoted after text", ``, true}, {"standing in for attributes", `
`, true}, {"output inside an action", ``, true}, } { lines, ok := unquotedLines([]byte(tc.src)) if !ok { t.Errorf("%s: not read", tc.name) continue } if lines[1] != tc.want { t.Errorf("%s: unquoted = %v, want %v", tc.name, lines[1], tc.want) } } } func TestUnquotedLinesAcrossLines(t *testing.T) { src := "\n" lines, ok := unquotedLines([]byte(src)) if !ok || !lines[4] || lines[5] || len(lines) != 1 { t.Errorf("lines = %v ok %v", lines, ok) } for _, src := range []string{`\nx\n", "unquoted.html": "\n", "broken.html": "