forked from microsoft/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression tests for client debug flag.
- Add client debug info to the `docker info` command. Signed-off-by: David Calavera <[email protected]>
- Loading branch information
Showing
5 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/Sirupsen/logrus" | ||
"github.com/docker/docker/utils" | ||
) | ||
|
||
func TestClientDebugEnabled(t *testing.T) { | ||
defer utils.DisableDebug() | ||
|
||
clientFlags.Common.FlagSet.Parse([]string{"-D"}) | ||
clientFlags.PostParse() | ||
|
||
if os.Getenv("DEBUG") != "1" { | ||
t.Fatal("expected debug enabled, got false") | ||
} | ||
if logrus.GetLevel() != logrus.DebugLevel { | ||
t.Fatalf("expected logrus debug level, got %v", logrus.GetLevel()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package utils | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/Sirupsen/logrus" | ||
) | ||
|
||
func TestEnableDebug(t *testing.T) { | ||
defer func() { | ||
os.Setenv("DEBUG", "") | ||
logrus.SetLevel(logrus.InfoLevel) | ||
}() | ||
EnableDebug() | ||
if os.Getenv("DEBUG") != "1" { | ||
t.Fatalf("expected DEBUG=1, got %s\n", os.Getenv("DEBUG")) | ||
} | ||
if logrus.GetLevel() != logrus.DebugLevel { | ||
t.Fatalf("expected log level %v, got %v\n", logrus.DebugLevel, logrus.GetLevel()) | ||
} | ||
} | ||
|
||
func TestDisableDebug(t *testing.T) { | ||
DisableDebug() | ||
if os.Getenv("DEBUG") != "" { | ||
t.Fatalf("expected DEBUG=\"\", got %s\n", os.Getenv("DEBUG")) | ||
} | ||
if logrus.GetLevel() != logrus.InfoLevel { | ||
t.Fatalf("expected log level %v, got %v\n", logrus.InfoLevel, logrus.GetLevel()) | ||
} | ||
} | ||
|
||
func TestDebugEnabled(t *testing.T) { | ||
EnableDebug() | ||
if !IsDebugEnabled() { | ||
t.Fatal("expected debug enabled, got false") | ||
} | ||
DisableDebug() | ||
if IsDebugEnabled() { | ||
t.Fatal("expected debug disabled, got true") | ||
} | ||
} |