2021-07-15 11:33:55 -04:00
|
|
|
package stack // import "github.com/docker/docker/pkg/stack"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
is "gotest.tools/v3/assert/cmp"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestDump(t *testing.T) {
|
|
|
|
Dump()
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDumpToFile(t *testing.T) {
|
2021-08-24 06:10:50 -04:00
|
|
|
directory, err := os.MkdirTemp("", "test-dump-tasks")
|
2021-07-15 11:33:55 -04:00
|
|
|
assert.Check(t, err)
|
|
|
|
defer os.RemoveAll(directory)
|
|
|
|
dumpPath, err := DumpToFile(directory)
|
|
|
|
assert.Check(t, err)
|
2021-08-24 06:10:50 -04:00
|
|
|
readFile, _ := os.ReadFile(dumpPath)
|
2021-07-15 11:33:55 -04:00
|
|
|
fileData := string(readFile)
|
|
|
|
assert.Check(t, is.Contains(fileData, "goroutine"))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDumpToFileWithEmptyInput(t *testing.T) {
|
|
|
|
path, err := DumpToFile("")
|
|
|
|
assert.Check(t, err)
|
|
|
|
assert.Check(t, is.Equal(os.Stderr.Name(), path))
|
|
|
|
}
|