mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-01 06:34:36 -04:00
chore: teach lint-locale about locale_next (#6800)
- Ref: forgejo/forgejo#6203 & forgejo/forgejo#5703 - Moved code around to be reusable, otherwise an straightforward implementation. - Added unit test. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6800 Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
parent
6cdc78ed4f
commit
742e0c6a72
2 changed files with 99 additions and 10 deletions
|
@ -63,3 +63,32 @@ func TestLocalizationPolicy(t *testing.T) {
|
|||
assert.EqualValues(t, []string{"key: و\x1b[31m \x1b[0m\x1b[32m\u00a0\x1b[0m"}, checkLocaleContent([]byte(`key = و `)))
|
||||
})
|
||||
}
|
||||
|
||||
func TestNextLocalizationPolicy(t *testing.T) {
|
||||
initBlueMondayPolicy()
|
||||
initRemoveTags()
|
||||
|
||||
t.Run("Nested locales", func(t *testing.T) {
|
||||
assert.Empty(t, checkLocaleNextContent(map[string]any{
|
||||
"settings": map[string]any{
|
||||
"hidden_comment_types_description": `Comment types checked here will not be shown inside issue pages. Checking "Label" for example removes all "<user> added/removed <label>" comments.`,
|
||||
},
|
||||
}))
|
||||
|
||||
assert.EqualValues(t, []string{"settings.hidden_comment_types_description: \"\x1b[31m<not-an-allowed-key>\x1b[0m REPLACED-TAG\""}, checkLocaleNextContent(map[string]any{
|
||||
"settings": map[string]any{
|
||||
"hidden_comment_types_description": `"<not-an-allowed-key> <label>"`,
|
||||
},
|
||||
}))
|
||||
})
|
||||
|
||||
t.Run("Flat locales", func(t *testing.T) {
|
||||
assert.Empty(t, checkLocaleNextContent(map[string]any{
|
||||
"settings.hidden_comment_types_description": `Comment types checked here will not be shown inside issue pages. Checking "Label" for example removes all "<user> added/removed <label>" comments.`,
|
||||
}))
|
||||
|
||||
assert.EqualValues(t, []string{"settings.hidden_comment_types_description: \"\x1b[31m<not-an-allowed-key>\x1b[0m REPLACED-TAG\""}, checkLocaleNextContent(map[string]any{
|
||||
"settings.hidden_comment_types_description": `"<not-an-allowed-key> <label>"`,
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue