MCPcopy
hub / github.com/docker/docker-agent / TestApplyThemePrecedence

Function TestApplyThemePrecedence

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

Source from the content-addressed store, hash-verified

38}
39
40func TestApplyThemePrecedence(t *testing.T) {
41 // Not parallel: mutates the process-global applied theme via ApplyTheme.
42 // Isolate config/data dirs so a developer's real user config (which may
43 // pin a theme) cannot influence the precedence assertions.
44 dir := t.TempDir()
45 paths.SetConfigDir(dir)
46 paths.SetDataDir(dir)
47 t.Cleanup(func() {
48 paths.SetConfigDir("")
49 paths.SetDataDir("")
50 })
51
52 t.Run("override takes precedence and is applied", func(t *testing.T) {
53 applyTheme("nord")
54 assert.Equal(t, "nord", styles.CurrentTheme().Ref)
55 })
56
57 t.Run("invalid override falls back to default theme", func(t *testing.T) {
58 // applyTheme tolerates an invalid ref (validateTheme guards the CLI
59 // entry point); it must never panic and should apply the default.
60 applyTheme("does-not-exist")
61 assert.Equal(t, styles.DefaultThemeRef, styles.CurrentTheme().Ref)
62 })
63
64 t.Run("empty override applies default when no user config theme", func(t *testing.T) {
65 applyTheme("")
66 assert.Equal(t, styles.DefaultThemeRef, styles.CurrentTheme().Ref)
67 })
68}

Callers

nothing calls this directly

Calls 6

SetConfigDirFunction · 0.92
SetDataDirFunction · 0.92
CurrentThemeFunction · 0.92
applyThemeFunction · 0.85
CleanupMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected