2016-02-17 08:41:00 +08:00
|
|
|
package util
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
"reflect"
|
|
|
|
"sort"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2016-02-23 10:02:23 +08:00
|
|
|
func TestRootStar(t *testing.T) {
|
2016-02-17 08:41:00 +08:00
|
|
|
// NOTE: will fail if there are newlines in /*.
|
2016-02-23 09:45:35 +08:00
|
|
|
want, err := exec.Command("ls", "/").Output()
|
2016-02-17 08:41:00 +08:00
|
|
|
mustOK(err)
|
|
|
|
wantNames := strings.Split(strings.Trim(string(want), "\n"), "\n")
|
|
|
|
for i := range wantNames {
|
|
|
|
wantNames[i] = "/" + wantNames[i]
|
|
|
|
}
|
|
|
|
|
2016-02-23 09:45:35 +08:00
|
|
|
names := RootStar()
|
2016-02-17 08:41:00 +08:00
|
|
|
|
|
|
|
sort.Strings(wantNames)
|
|
|
|
sort.Strings(names)
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(names, wantNames) {
|
2016-02-23 10:02:23 +08:00
|
|
|
t.Errorf("RootStar() -> %s, want %s", names, wantNames)
|
2016-02-17 08:41:00 +08:00
|
|
|
}
|
|
|
|
}
|