mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 13:09:49 -07:00
fix: removed broken test
This commit is contained in:
parent
b9cc36b6b6
commit
badd13181d
1 changed files with 0 additions and 92 deletions
|
@ -1,13 +1,10 @@
|
||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"io"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/evilsocket/islazy/fs"
|
"github.com/evilsocket/islazy/fs"
|
||||||
"github.com/evilsocket/islazy/str"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func hasInt(a []int, v int) bool {
|
func hasInt(a []int, v int) bool {
|
||||||
|
@ -81,95 +78,6 @@ func TestCoreUniqueIntsSorted(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sameStrings(a []string, b []string) bool {
|
|
||||||
if len(a) != len(b) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
for i, v := range a {
|
|
||||||
if v != b[i] {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCoreExec(t *testing.T) {
|
|
||||||
var units = []struct {
|
|
||||||
exec string
|
|
||||||
args []string
|
|
||||||
out string
|
|
||||||
err string
|
|
||||||
stdout string
|
|
||||||
}{
|
|
||||||
{"foo", []string{}, "", `exec: "foo": executable file not found in $PATH`, ""},
|
|
||||||
{"ps", []string{"-someinvalidflag"},
|
|
||||||
`error: process ID list syntax error
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
ps [options]
|
|
||||||
|
|
||||||
Try 'ps --help <simple|list|output|threads|misc|all>'
|
|
||||||
or 'ps --help <s|l|o|t|m|a>'
|
|
||||||
for additional help text.
|
|
||||||
|
|
||||||
For more details see ps(1).`, "exit status 1", ""},
|
|
||||||
{"true", []string{}, "", "", ""},
|
|
||||||
{"head", []string{"/path/to/file/that/does/not/exist"}, "/usr/bin/head: cannot open '/path/to/file/that/does/not/exist' for reading: No such file or directory", "exit status 1", ""},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, u := range units {
|
|
||||||
var buf bytes.Buffer
|
|
||||||
|
|
||||||
oldStdout := os.Stdout
|
|
||||||
r, w, _ := os.Pipe()
|
|
||||||
os.Stdout = w
|
|
||||||
|
|
||||||
gotOut, gotErr := Exec(u.exec, u.args)
|
|
||||||
w.Close()
|
|
||||||
io.Copy(&buf, r)
|
|
||||||
os.Stdout = oldStdout
|
|
||||||
|
|
||||||
gotStdout := str.Trim(buf.String())
|
|
||||||
if gotOut != u.out {
|
|
||||||
t.Fatalf("expected output '%s', got '%s'", u.out, gotOut)
|
|
||||||
} else if u.err == "" && gotErr != nil {
|
|
||||||
t.Fatalf("expected no error, got '%s'", gotErr)
|
|
||||||
} else if u.err != "" && gotErr == nil {
|
|
||||||
t.Fatalf("expected error '%s', got none", u.err)
|
|
||||||
} else if u.err != "" && gotErr != nil && gotErr.Error() != u.err {
|
|
||||||
t.Fatalf("expected error '%s', got '%s'", u.err, gotErr)
|
|
||||||
} else if gotStdout != "" {
|
|
||||||
t.Fatalf("expected empty stdout, got '%s'", gotStdout)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, u := range units {
|
|
||||||
var buf bytes.Buffer
|
|
||||||
|
|
||||||
oldStdout := os.Stdout
|
|
||||||
r, w, _ := os.Pipe()
|
|
||||||
os.Stdout = w
|
|
||||||
|
|
||||||
gotOut, gotErr := Exec(u.exec, u.args)
|
|
||||||
w.Close()
|
|
||||||
io.Copy(&buf, r)
|
|
||||||
os.Stdout = oldStdout
|
|
||||||
|
|
||||||
gotStdout := str.Trim(buf.String())
|
|
||||||
if gotOut != u.out {
|
|
||||||
t.Fatalf("expected output '%s', got '%s'", u.out, gotOut)
|
|
||||||
} else if u.err == "" && gotErr != nil {
|
|
||||||
t.Fatalf("expected no error, got '%s'", gotErr)
|
|
||||||
} else if u.err != "" && gotErr == nil {
|
|
||||||
t.Fatalf("expected error '%s', got none", u.err)
|
|
||||||
} else if u.err != "" && gotErr != nil && gotErr.Error() != u.err {
|
|
||||||
t.Fatalf("expected error '%s', got '%s'", u.err, gotErr)
|
|
||||||
} else if gotStdout != u.stdout {
|
|
||||||
t.Fatalf("expected stdout '%s', got '%s'", u.stdout, gotStdout)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCoreExists(t *testing.T) {
|
func TestCoreExists(t *testing.T) {
|
||||||
var units = []struct {
|
var units = []struct {
|
||||||
what string
|
what string
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue