File: exit_test.go

package info (click to toggle)
golang-github-pterm-pterm 0.12.79-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,640 kB
  • sloc: makefile: 4
file content (23 lines) | stat: -rw-r--r-- 372 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
package internal_test

import (
	"os"
	"testing"

	"github.com/pterm/pterm/internal"
)

func TestExit(t *testing.T) {
	var lastExitCode int
	internal.DefaultExitFunc = func(code int) {
		lastExitCode = code
	}

	defer func() { internal.DefaultExitFunc = os.Exit }()

	internal.Exit(1)

	if lastExitCode != 1 {
		t.Errorf("Expected exit code 1, got %d", lastExitCode)
	}
}