-
Notifications
You must be signed in to change notification settings - Fork 5
/
app_test.go
46 lines (38 loc) · 1.07 KB
/
app_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
package main
import (
"errors"
"testing"
"github.com/abhinav/tmux-fastcopy/internal/log/logtest"
"github.com/abhinav/tmux-fastcopy/internal/tmux/tmuxtest"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestApp_Run_badRegex(t *testing.T) {
t.Parallel()
mockCtrl := gomock.NewController(t)
err := (&app{
Log: logtest.NewLogger(t),
Tmux: tmuxtest.NewMockDriver(mockCtrl),
}).Run(&config{
Regexes: regexes{
"foo": "not(a{valid[regex",
},
})
require.Error(t, err, "run must fail")
assert.ErrorContains(t, err, `compile regex "foo"`)
}
func TestApp_Run_inspectPaneError(t *testing.T) {
t.Parallel()
mockCtrl := gomock.NewController(t)
tmuxDriver := tmuxtest.NewMockDriver(mockCtrl)
tmuxDriver.EXPECT().
DisplayMessage(tmuxtest.DisplayMessageRequestMatcher{Pane: "42"}).
Return(nil, errors.New("great sadness"))
err := (&app{
Log: logtest.NewLogger(t),
Tmux: tmuxDriver,
}).Run(&config{Pane: "42"})
require.Error(t, err, "run must fail")
assert.ErrorContains(t, err, "great sadness")
}