-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch_test.go
64 lines (48 loc) · 1.36 KB
/
patch_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
package chromedriver
import (
"io"
"os"
"os/exec"
"regexp"
"strings"
"testing"
"time"
// TODO: So stupid, get rid of this shit, we just have to do a fucking
// comparison
"github.com/stretchr/testify/require"
)
func TestPatcherLatest(t *testing.T) {
// CI is slow
RequestTimeout = 30 * time.Second
p, err := New("", 0)
require.NoError(t, err, "create patcher")
path, err := p.Patch()
require.NoError(t, err, "patch")
t.Log(path)
file, err := os.Open(path)
require.NoError(t, err, "open driver")
driver, err := io.ReadAll(file)
require.NoError(t, err, "read driver")
re := regexp.MustCompile("cdc_.{22}")
require.Equal(t, false, re.Match(driver))
_, err = exec.Command(path, "--version").Output()
require.NoError(t, err, "execute")
}
func TestPatcherVersionPin(t *testing.T) {
// CI is slow
RequestTimeout = 30 * time.Second
p, err := New("", 105)
require.NoError(t, err, "create patcher")
path, err := p.Patch()
require.NoError(t, err, "patch")
t.Log(path)
file, err := os.Open(path)
require.NoError(t, err, "open driver")
driver, err := io.ReadAll(file)
require.NoError(t, err, "read driver")
re := regexp.MustCompile("cdc_.{22}")
require.Equal(t, false, re.Match(driver))
output, err := exec.Command(path, "--version").Output()
require.NoError(t, err, "check version")
require.Equal(t, true, strings.Contains(string(output), "105"))
}