fix
This commit is contained in:
1 parent
7537a41955
commit
ff6c2df618
14 files changed
+767
-349
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package aiprompts
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAllBundledLanguageRules(t *testing.T) {
|
||||
want := []string{"en", "fr", "de", "es", "it", "nl", "pt", "pl", "cs", "sk", "hu", "ro", "bg", "hr", "sl", "sv", "da", "fi", "el", "et", "lv", "lt", "mt", "ga", "ja"}
|
||||
if len(OfflinePromptLanguages()) != len(want) {
|
||||
t.Fatalf("need 25 locales, have %d", len(OfflinePromptLanguages()))
|
||||
}
|
||||
for _, lang := range want {
|
||||
prompt, err := OfflineDefaultPrompt(lang)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, tag := range []string{"--- Title ---", "--- End Title ---", "--- Description ---", "--- End Description ---", "--- Meta ---", "--- End Meta ---"} {
|
||||
if !strings.Contains(prompt, tag) {
|
||||
t.Fatalf("missing %q in %s", tag, lang)
|
||||
}
|
||||
}
|
||||
if len(prompt) > 8000 {
|
||||
t.Fatalf("too long %s", lang)
|
||||
}
|
||||
if strings.Contains(prompt, "{{attrs}}") {
|
||||
t.Fatalf("unexpected placeholder in prelocalized instruction %s", lang)
|
||||
}
|
||||
}
|
||||
if _, err := OfflineDefaultPrompt("invalid"); err == nil {
|
||||
t.Fatal("unknown language silently fell back")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user