Skip to content

Commit 41c4a47

Browse files
authored
Merge pull request #74 from schnoddelbotz/master
tests: cover ExitCode() 0+1 case
2 parents 57e445f + 47d95a0 commit 41c4a47

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

term_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package terminal
22

33
import (
4+
"errors"
5+
"fmt"
46
"testing"
57
"time"
68

@@ -21,6 +23,27 @@ func TestExitCode(t *testing.T) {
2123
assert.Equal(t, term.ExitCode(), int(-1))
2224
}
2325

26+
func testExitCodeN(t *testing.T, n int) {
27+
term := New()
28+
term.Resize(fyne.NewSize(45, 45))
29+
go term.RunLocalShell()
30+
err := errors.New("NotYet")
31+
for err != nil {
32+
time.Sleep(50 * time.Millisecond)
33+
_, err = term.Write([]byte(fmt.Sprintf("exit %d\n", n)))
34+
}
35+
for term.ExitCode() == -1 {
36+
time.Sleep(50 * time.Millisecond)
37+
}
38+
39+
assert.Equal(t, n, term.ExitCode())
40+
}
41+
42+
func TestExitCode01(t *testing.T) {
43+
testExitCodeN(t, 0)
44+
testExitCodeN(t, 1)
45+
}
46+
2447
func TestTerminal_Resize(t *testing.T) {
2548
term := New()
2649
term.Resize(fyne.NewSize(45, 45))

0 commit comments

Comments
 (0)