File: stackdump_test.go

package info (click to toggle)
docker.io 28.5.2%2Bdfsg3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 68,176 kB
  • sloc: sh: 5,867; makefile: 863; ansic: 184; python: 162; asm: 159
file content (28 lines) | stat: -rw-r--r-- 541 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package 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) {
	tmpDir := t.TempDir()
	dumpPath, err := DumpToFile(tmpDir)
	assert.Check(t, err)
	readFile, _ := os.ReadFile(dumpPath)
	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))
}