forked from fynelabs/selfupdate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecutable_test.go
More file actions
35 lines (30 loc) · 752 Bytes
/
executable_test.go
File metadata and controls
35 lines (30 loc) · 752 Bytes
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
package selfupdate
import (
"fmt"
"path/filepath"
"runtime"
"testing"
"github.com/stretchr/testify/assert"
)
func TestAlwaysFindExecutableTime(t *testing.T) {
_, err := lastModifiedExecutable()
assert.Nil(t, err)
}
func TestAlwaysFindExecutable(t *testing.T) {
exe, err := ExecutableRealPath()
ext := filepath.Ext(exe)
assert.Nil(t, err)
assert.NotEmpty(t, exe)
if runtime.GOOS == "windows" {
assert.Equal(t, ".exe", ext)
} else {
assert.True(t, ext == ".test" || ext == "", fmt.Sprintf("Linux extesion not correct, got '%s'", ext))
}
}
func TestAlwaysFindOldExecutable(t *testing.T) {
exe, err := ExecutableDefaultOldPath()
ext := filepath.Ext(exe)
assert.Nil(t, err)
assert.NotEmpty(t, exe)
assert.Equal(t, ".old", ext)
}