(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestValidateTheme(t *testing.T) { |
| 14 | t.Parallel() |
| 15 | |
| 16 | t.Run("accepts built-in theme", func(t *testing.T) { |
| 17 | t.Parallel() |
| 18 | require.NoError(t, validateTheme("nord")) |
| 19 | }) |
| 20 | |
| 21 | t.Run("accepts default theme", func(t *testing.T) { |
| 22 | t.Parallel() |
| 23 | require.NoError(t, validateTheme(styles.DefaultThemeRef)) |
| 24 | }) |
| 25 | |
| 26 | t.Run("rejects unknown theme with helpful message", func(t *testing.T) { |
| 27 | t.Parallel() |
| 28 | err := validateTheme("does-not-exist") |
| 29 | require.Error(t, err) |
| 30 | assert.Contains(t, err.Error(), "does-not-exist") |
| 31 | assert.Contains(t, err.Error(), "available themes") |
| 32 | }) |
| 33 | |
| 34 | t.Run("rejects path traversal", func(t *testing.T) { |
| 35 | t.Parallel() |
| 36 | require.Error(t, validateTheme("../../etc/passwd")) |
| 37 | }) |
| 38 | } |
| 39 | |
| 40 | func TestApplyThemePrecedence(t *testing.T) { |
| 41 | // Not parallel: mutates the process-global applied theme via ApplyTheme. |
nothing calls this directly
no test coverage detected