-
Notifications
You must be signed in to change notification settings - Fork 28
/
main_test.go
70 lines (58 loc) · 1.51 KB
/
main_test.go
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"os"
"os/exec"
"runtime"
"testing"
"time"
"github.com/rivo/tview"
)
func TestConfigWindow(t *testing.T) {
InitUI()
go OpenFileDialog()
time.Sleep(500 * time.Millisecond)
if currentConfigWindowSelector == 0 {
t.Fatal("OpenFileDialog failed to open")
}
}
func TestMainWindow(t *testing.T) {
InitUI()
go MainWindow()
time.Sleep(500 * time.Millisecond)
if currentMainWindowSelector == 0 {
t.Fatal("MainWindow failed to open")
}
}
func TestConfigurationFileLoading(t *testing.T) {
var config Configuration
config.getConfiguration("tests/config_test_standard.yml")
if len(config.Input.Content.Grep) == 0 || config.Input.Content.Grep[0] != "package main" {
t.Fatal("config.getConfiguration fails to load and parse configuration file correctly")
}
}
func TestRC4CipheredConfigurationFileLoading(t *testing.T) {
var config Configuration
config.getConfiguration("tests/config_test_ciphered.yml")
if len(config.Input.Content.Grep) == 0 || config.Input.Content.Grep[0] != "package main" {
t.Fatal("config.getConfiguration fails to load and parse configuration file correctly")
}
}
func TestCleanUI(t *testing.T) {
UIapp = tview.NewApplication()
UIapp.ForceDraw()
UIactive = false
AppStarted = false
UIapp.Stop()
if UIactive || AppStarted {
t.Fatal("Can't reset GUI app for further testing")
}
if runtime.GOOS == "linux" {
cmd := exec.Command("clear")
cmd.Stdout = os.Stdout
cmd.Run()
} else {
cmd := exec.Command("cmd", "/c", "cls")
cmd.Stdout = os.Stdout
cmd.Run()
}
}