mirror of
https://github.com/walles/moar.git
synced 2024-11-23 05:53:18 +03:00
Test our executability checker
This commit is contained in:
parent
8dd02a3fe1
commit
a5317483e8
32
m/pagermode-viewing_test.go
Normal file
32
m/pagermode-viewing_test.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package m
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestErrUnlessExecutable_yes(t *testing.T) {
|
||||||
|
// Find our own executable
|
||||||
|
executable, err := os.Executable()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that it's executable
|
||||||
|
err = errUnlessExecutable(executable)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestErrUnlessExecutable_no(t *testing.T) {
|
||||||
|
textFile := "pagermode-viewing_test.go"
|
||||||
|
if _, err := os.Stat(textFile); os.IsNotExist(err) {
|
||||||
|
t.Fatal("Test setup failed, text file not found: " + textFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
err := errUnlessExecutable(textFile)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Expected error, got nil")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user