File tree Expand file tree Collapse file tree 2 files changed +55
-1
lines changed
Expand file tree Collapse file tree 2 files changed +55
-1
lines changed Original file line number Diff line number Diff line change 55 "strconv"
66)
77
8- // Enabled returns whether cli hints are enabled or not
8+ // Enabled returns whether cli hints are enabled or not. Hints are enabled by
9+ // default, but can be disabled through the "DOCKER_CLI_HINTS" environment
10+ // variable.
911func Enabled () bool {
1012 if v := os .Getenv ("DOCKER_CLI_HINTS" ); v != "" {
1113 enabled , err := strconv .ParseBool (v )
Original file line number Diff line number Diff line change 1+ package hints
2+
3+ import (
4+ "testing"
5+
6+ "gotest.tools/v3/assert"
7+ )
8+
9+ func TestEnabled (t * testing.T ) {
10+ tests := []struct {
11+ doc string
12+ env string
13+ expected bool
14+ }{
15+ {
16+ doc : "default" ,
17+ expected : true ,
18+ },
19+ {
20+ doc : "DOCKER_CLI_HINTS=1" ,
21+ env : "1" ,
22+ expected : true ,
23+ },
24+ {
25+ doc : "DOCKER_CLI_HINTS=true" ,
26+ env : "true" ,
27+ expected : true ,
28+ },
29+ {
30+ doc : "DOCKER_CLI_HINTS=0" ,
31+ env : "0" ,
32+ expected : false ,
33+ },
34+ {
35+ doc : "DOCKER_CLI_HINTS=false" ,
36+ env : "false" ,
37+ expected : false ,
38+ },
39+ {
40+ doc : "DOCKER_CLI_HINTS=not-a-bool" ,
41+ env : "not-a-bool" ,
42+ expected : true ,
43+ },
44+ }
45+
46+ for _ , tc := range tests {
47+ t .Run (tc .doc , func (t * testing.T ) {
48+ t .Setenv ("DOCKER_CLI_HINTS" , tc .env )
49+ assert .Equal (t , Enabled (), tc .expected )
50+ })
51+ }
52+ }
You can’t perform that action at this time.
0 commit comments