-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
48 lines (37 loc) · 1.02 KB
/
Copy pathmain_test.go
File metadata and controls
48 lines (37 loc) · 1.02 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"os"
"testing"
"github.com/jgrancell/turtleshell/cli"
"github.com/jgrancell/turtleshell/configuration"
"github.com/jgrancell/turtleshell/history"
"github.com/jgrancell/turtleshell/variables"
)
func TestMain(t *testing.T) {
// this should succeed
exitcode := Terminal()
if exitcode != 127 {
t.Errorf("received terminal exitcode %d", exitcode)
}
}
func TestParseInput(t *testing.T) {
shell := &cli.Cli{}
shell.Version = version
os.Setenv("SHELL", "/bin/turtleshell")
shell.Configuration = configuration.Load("")
// Loading shell history
var err error
shell.History, err = history.Load("./testdata/history/history.txt")
if err != nil {
t.Errorf("Shell history initialization error: %s", err.Error())
}
// Loading shell variables
shell.Variables = variables.Load()
exitcode, ok := ParseInput(shell, "status")
if !ok {
t.Errorf("parse input for status failed, when it should have succeeded")
}
if exitcode != 0 {
t.Errorf("exitcode for status should have been 0, was %d", exitcode)
}
}