-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
69 lines (59 loc) · 1.5 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
package main
import (
"github.com/coyim/gotk3adapter/gdki"
"github.com/coyim/gotk3adapter/gioi"
"github.com/coyim/gotk3adapter/gtki"
"github.com/coyim/gotk3mocks/gdk"
"github.com/coyim/gotk3mocks/gio"
"github.com/coyim/gotk3mocks/gtk"
"github.com/digitalautonomy/keymirror/api"
"github.com/prashantv/gostub"
"github.com/sirupsen/logrus"
"testing"
"github.com/stretchr/testify/suite"
)
type mainSuite struct {
suite.Suite
}
func TestMainSuite(t *testing.T) {
suite.Run(t, new(mainSuite))
}
func (s *mainSuite) Test_main_startsTheGuiWithTheRealGTK() {
originalGTK := realGTK
defer func() {
realGTK = originalGTK
}()
ourGTK := >k.Mock{}
realGTK = ourGTK
originalGDK := realGDK
defer func() {
realGDK = originalGDK
}()
ourGDK := &gdk.Mock{}
realGDK = ourGDK
originalGIO := realGIO
defer func() {
realGIO = originalGIO
}()
ourGIO := &gio.Mock{}
realGIO = ourGIO
var calledWithGTK gtki.Gtk
var calledWithGDK gdki.Gdk
var calledWithGIO gioi.Gio
var calledWithLog logrus.Ext1FieldLogger
var calledWithKeyAccess api.KeyAccess
defer gostub.Stub(&startGUI, func(g gtki.Gtk, g2 gdki.Gdk, g3 gioi.Gio, log logrus.Ext1FieldLogger, ka api.KeyAccess) {
calledWithGTK = g
calledWithGDK = g2
calledWithGIO = g3
calledWithLog = log
calledWithKeyAccess = ka
}).Reset()
main()
s.Equal(ourGTK, calledWithGTK)
s.Equal(ourGDK, calledWithGDK)
s.Equal(ourGIO, calledWithGIO)
s.NotNil(calledWithLog)
s.Equal(logrus.TraceLevel, calledWithLog.(*logrus.Logger).Level)
s.NotNil(calledWithKeyAccess)
}