test: extend banner guard coverage
This commit is contained in:
parent
df19b8c708
commit
73a1dbc8a6
2 changed files with 24 additions and 4 deletions
|
|
@ -54,7 +54,6 @@ func NewPicoclawCommand() *cobra.Command {
|
|||
const (
|
||||
colorBlue = "\033[1;38;2;62;93;185m"
|
||||
colorRed = "\033[1;38;2;213;70;70m"
|
||||
noBannerEnv = "PICOCLAW_NO_BANNER"
|
||||
banner = "\r\n" +
|
||||
colorBlue + "██████╗ ██╗ ██████╗ ██████╗ " + colorRed + " ██████╗██╗ █████╗ ██╗ ██╗\n" +
|
||||
colorBlue + "██╔══██╗██║██╔════╝██╔═══██╗" + colorRed + "██╔════╝██║ ██╔══██╗██║ ██║\n" +
|
||||
|
|
@ -65,6 +64,8 @@ const (
|
|||
"\033[0m\r\n"
|
||||
)
|
||||
|
||||
const noBannerEnv = "PICOCLAW_NO_BANNER"
|
||||
|
||||
func bannerDisabledByEnv() bool {
|
||||
value := strings.TrimSpace(strings.ToLower(os.Getenv(noBannerEnv)))
|
||||
switch value {
|
||||
|
|
|
|||
|
|
@ -79,4 +79,23 @@ func TestShouldPrintBanner(t *testing.T) {
|
|||
t.Setenv(noBannerEnv, "1")
|
||||
assert.False(t, shouldPrintBanner([]string{"picoclaw", "agent"}, true))
|
||||
})
|
||||
|
||||
t.Run("common truthy env values disable banner", func(t *testing.T) {
|
||||
for _, value := range []string{"true", "yes", "on"} {
|
||||
t.Run(value, func(t *testing.T) {
|
||||
t.Setenv(noBannerEnv, value)
|
||||
assert.False(t, shouldPrintBanner([]string{"picoclaw", "agent"}, true))
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("root command still prints banner in terminal", func(t *testing.T) {
|
||||
t.Setenv(noBannerEnv, "")
|
||||
assert.True(t, shouldPrintBanner([]string{"picoclaw"}, true))
|
||||
})
|
||||
|
||||
t.Run("unknown subcommand still prints banner in terminal", func(t *testing.T) {
|
||||
t.Setenv(noBannerEnv, "")
|
||||
assert.True(t, shouldPrintBanner([]string{"picoclaw", "unknown"}, true))
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue