MCPcopy Index your code
hub / github.com/docker/docker-agent / TestValidateTheme

Function TestValidateTheme

cmd/root/run_theme_test.go:13–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func 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
40func TestApplyThemePrecedence(t *testing.T) {
41 // Not parallel: mutates the process-global applied theme via ApplyTheme.

Callers

nothing calls this directly

Calls 3

validateThemeFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected