From badd13181d91a58ff966cc5503b8de17f0f7ba30 Mon Sep 17 00:00:00 2001 From: Simone Margaritelli Date: Fri, 14 May 2021 16:16:58 +0200 Subject: [PATCH] fix: removed broken test --- core/core_test.go | 92 ----------------------------------------------- 1 file changed, 92 deletions(-) diff --git a/core/core_test.go b/core/core_test.go index 296e980b..2dc77c49 100644 --- a/core/core_test.go +++ b/core/core_test.go @@ -1,13 +1,10 @@ package core import ( - "bytes" - "io" "os" "testing" "github.com/evilsocket/islazy/fs" - "github.com/evilsocket/islazy/str" ) 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 ' - or 'ps --help ' - 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) { var units = []struct { what string