test: Catch capitalized error messages in tests

This commit is contained in:
James Shubin
2019-08-24 01:08:33 -04:00
parent f1eedc7a01
commit 87572e8922
9 changed files with 95 additions and 95 deletions

View File

@@ -78,7 +78,7 @@ func TestMiscEncodeDecode1(t *testing.T) {
e := gob.NewEncoder(&b1) e := gob.NewEncoder(&b1)
err = e.Encode(&input) // pass with & err = e.Encode(&input) // pass with &
if err != nil { if err != nil {
t.Errorf("Gob failed to Encode: %v", err) t.Errorf("gob failed to Encode: %v", err)
} }
str := base64.StdEncoding.EncodeToString(b1.Bytes()) str := base64.StdEncoding.EncodeToString(b1.Bytes())
@@ -86,27 +86,27 @@ func TestMiscEncodeDecode1(t *testing.T) {
var output interface{} var output interface{}
bb, err := base64.StdEncoding.DecodeString(str) bb, err := base64.StdEncoding.DecodeString(str)
if err != nil { if err != nil {
t.Errorf("Base64 failed to Decode: %v", err) t.Errorf("base64 failed to Decode: %v", err)
} }
b2 := bytes.NewBuffer(bb) b2 := bytes.NewBuffer(bb)
d := gob.NewDecoder(b2) d := gob.NewDecoder(b2)
err = d.Decode(&output) // pass with & err = d.Decode(&output) // pass with &
if err != nil { if err != nil {
t.Errorf("Gob failed to Decode: %v", err) t.Errorf("gob failed to Decode: %v", err)
} }
res1, ok := input.(engine.Res) res1, ok := input.(engine.Res)
if !ok { if !ok {
t.Errorf("Input %v is not a Res", res1) t.Errorf("input %v is not a Res", res1)
return return
} }
res2, ok := output.(engine.Res) res2, ok := output.(engine.Res)
if !ok { if !ok {
t.Errorf("Output %v is not a Res", res2) t.Errorf("output %v is not a Res", res2)
return return
} }
if err := res1.Cmp(res2); err != nil { if err := res1.Cmp(res2); err != nil {
t.Errorf("The input and output Res values do not match: %+v", err) t.Errorf("the input and output Res values do not match: %+v", err)
} }
} }
@@ -116,7 +116,7 @@ func TestMiscEncodeDecode2(t *testing.T) {
// encode // encode
input, err := engine.NewNamedResource("file", "file1") input, err := engine.NewNamedResource("file", "file1")
if err != nil { if err != nil {
t.Errorf("Can't create: %v", err) t.Errorf("can't create: %v", err)
return return
} }
// NOTE: Do not add this bit of code, because it would cause the path to // NOTE: Do not add this bit of code, because it would cause the path to
@@ -128,29 +128,29 @@ func TestMiscEncodeDecode2(t *testing.T) {
b64, err := engineUtil.ResToB64(input) b64, err := engineUtil.ResToB64(input)
if err != nil { if err != nil {
t.Errorf("Can't encode: %v", err) t.Errorf("can't encode: %v", err)
return return
} }
output, err := engineUtil.B64ToRes(b64) output, err := engineUtil.B64ToRes(b64)
if err != nil { if err != nil {
t.Errorf("Can't decode: %v", err) t.Errorf("can't decode: %v", err)
return return
} }
res1, ok := input.(engine.Res) res1, ok := input.(engine.Res)
if !ok { if !ok {
t.Errorf("Input %v is not a Res", res1) t.Errorf("input %v is not a Res", res1)
return return
} }
res2, ok := output.(engine.Res) res2, ok := output.(engine.Res)
if !ok { if !ok {
t.Errorf("Output %v is not a Res", res2) t.Errorf("output %v is not a Res", res2)
return return
} }
// this uses the standalone file cmp function // this uses the standalone file cmp function
if err := res1.Cmp(res2); err != nil { if err := res1.Cmp(res2); err != nil {
t.Errorf("The input and output Res values do not match: %+v", err) t.Errorf("the input and output Res values do not match: %+v", err)
} }
} }
@@ -160,7 +160,7 @@ func TestMiscEncodeDecode3(t *testing.T) {
// encode // encode
input, err := engine.NewNamedResource("file", "file1") input, err := engine.NewNamedResource("file", "file1")
if err != nil { if err != nil {
t.Errorf("Can't create: %v", err) t.Errorf("can't create: %v", err)
return return
} }
fileRes := input.(*FileRes) // must not panic fileRes := input.(*FileRes) // must not panic
@@ -169,29 +169,29 @@ func TestMiscEncodeDecode3(t *testing.T) {
b64, err := engineUtil.ResToB64(input) b64, err := engineUtil.ResToB64(input)
if err != nil { if err != nil {
t.Errorf("Can't encode: %v", err) t.Errorf("can't encode: %v", err)
return return
} }
output, err := engineUtil.B64ToRes(b64) output, err := engineUtil.B64ToRes(b64)
if err != nil { if err != nil {
t.Errorf("Can't decode: %v", err) t.Errorf("can't decode: %v", err)
return return
} }
res1, ok := input.(engine.Res) res1, ok := input.(engine.Res)
if !ok { if !ok {
t.Errorf("Input %v is not a Res", res1) t.Errorf("input %v is not a Res", res1)
return return
} }
res2, ok := output.(engine.Res) res2, ok := output.(engine.Res)
if !ok { if !ok {
t.Errorf("Output %v is not a Res", res2) t.Errorf("output %v is not a Res", res2)
return return
} }
// this uses the more complete, engine cmp function // this uses the more complete, engine cmp function
if err := engine.ResCmp(res1, res2); err != nil { if err := engine.ResCmp(res1, res2); err != nil {
t.Errorf("The input and output Res values do not match: %+v", err) t.Errorf("the input and output Res values do not match: %+v", err)
} }
} }

View File

@@ -31,7 +31,7 @@ func testToLower(t *testing.T, input, expected string) {
return return
} }
if value.Str() != expected { if value.Str() != expected {
t.Errorf("Invalid output, expected %s, got %s", expected, value.Str()) t.Errorf("invalid output, expected %s, got %s", expected, value.Str())
} }
} }

View File

@@ -550,7 +550,7 @@ func TestAstFunc1(t *testing.T) {
const magicEmpty = "# empty!" const magicEmpty = "# empty!"
dir, err := util.TestDirFull() dir, err := util.TestDirFull()
if err != nil { if err != nil {
t.Errorf("FAIL: could not get tests directory: %+v", err) t.Errorf("could not get tests directory: %+v", err)
return return
} }
t.Logf("tests directory is: %s", dir) t.Logf("tests directory is: %s", dir)
@@ -592,7 +592,7 @@ func TestAstFunc1(t *testing.T) {
// build test array automatically from reading the dir // build test array automatically from reading the dir
files, err := ioutil.ReadDir(dir) files, err := ioutil.ReadDir(dir)
if err != nil { if err != nil {
t.Errorf("FAIL: could not read through tests directory: %+v", err) t.Errorf("could not read through tests directory: %+v", err)
return return
} }
sorted := []string{} sorted := []string{}
@@ -608,13 +608,13 @@ func TestAstFunc1(t *testing.T) {
graphFileFull := dir + graphFile graphFileFull := dir + graphFile
info, err := os.Stat(graphFileFull) info, err := os.Stat(graphFileFull)
if err != nil || info.IsDir() { if err != nil || info.IsDir() {
t.Errorf("FAIL: missing: %s", graphFile) t.Errorf("missing: %s", graphFile)
t.Errorf("(err: %+v)", err) t.Errorf("(err: %+v)", err)
continue continue
} }
content, err := ioutil.ReadFile(graphFileFull) content, err := ioutil.ReadFile(graphFileFull)
if err != nil { if err != nil {
t.Errorf("FAIL: could not read graph file: %+v", err) t.Errorf("could not read graph file: %+v", err)
return return
} }
str := string(content) // expected graph str := string(content) // expected graph
@@ -971,7 +971,7 @@ func TestAstFunc2(t *testing.T) {
const magicEmpty = "# empty!" const magicEmpty = "# empty!"
dir, err := util.TestDirFull() dir, err := util.TestDirFull()
if err != nil { if err != nil {
t.Errorf("FAIL: could not get tests directory: %+v", err) t.Errorf("could not get tests directory: %+v", err)
return return
} }
t.Logf("tests directory is: %s", dir) t.Logf("tests directory is: %s", dir)
@@ -1014,7 +1014,7 @@ func TestAstFunc2(t *testing.T) {
// build test array automatically from reading the dir // build test array automatically from reading the dir
files, err := ioutil.ReadDir(dir) files, err := ioutil.ReadDir(dir)
if err != nil { if err != nil {
t.Errorf("FAIL: could not read through tests directory: %+v", err) t.Errorf("could not read through tests directory: %+v", err)
return return
} }
sorted := []string{} sorted := []string{}
@@ -1030,13 +1030,13 @@ func TestAstFunc2(t *testing.T) {
graphFileFull := dir + graphFile graphFileFull := dir + graphFile
info, err := os.Stat(graphFileFull) info, err := os.Stat(graphFileFull)
if err != nil || info.IsDir() { if err != nil || info.IsDir() {
t.Errorf("FAIL: missing: %s", graphFile) t.Errorf("missing: %s", graphFile)
t.Errorf("(err: %+v)", err) t.Errorf("(err: %+v)", err)
continue continue
} }
content, err := ioutil.ReadFile(graphFileFull) content, err := ioutil.ReadFile(graphFileFull)
if err != nil { if err != nil {
t.Errorf("FAIL: could not read graph file: %+v", err) t.Errorf("could not read graph file: %+v", err)
return return
} }
str := string(content) // expected graph str := string(content) // expected graph

View File

@@ -41,7 +41,7 @@ func runGraphCmp(t *testing.T, g1, g2 *pgraph.Graph) {
if err != nil { if err != nil {
t.Logf(" actual (g1): %v%s", g1, fullPrint(g1)) t.Logf(" actual (g1): %v%s", g1, fullPrint(g1))
t.Logf("expected (g2): %v%s", g2, fullPrint(g2)) t.Logf("expected (g2): %v%s", g2, fullPrint(g2))
t.Errorf("Cmp error:\n%v", err) t.Errorf("cmp error:\n%v", err)
} }
} }

View File

@@ -43,7 +43,7 @@ func TestGraphSync1(t *testing.T) {
err := g.GraphSync(newGraph, nil, nil, nil, nil) err := g.GraphSync(newGraph, nil, nil, nil, nil)
if err != nil { if err != nil {
t.Errorf("GraphSync failed: %v", err) t.Errorf("failed with: %+v", err)
return return
} }
@@ -83,7 +83,7 @@ func TestGraphSync2(t *testing.T) {
err := g.GraphSync(newGraph, strVertexCmpFn, vertexAddFn, vertexRemoveFn, strEdgeCmpFn) err := g.GraphSync(newGraph, strVertexCmpFn, vertexAddFn, vertexRemoveFn, strEdgeCmpFn)
if err != nil { if err != nil {
t.Errorf("GraphSync failed: %v", err) t.Errorf("failed with: %+v", err)
return return
} }

View File

@@ -38,7 +38,7 @@ func TestInitKindMetrics(t *testing.T) {
gatherer := prometheus.DefaultGatherer gatherer := prometheus.DefaultGatherer
metrics, err := gatherer.Gather() metrics, err := gatherer.Gather()
if err != nil { if err != nil {
t.Errorf("Error while gathering metrics: %s", err) t.Errorf("error while gathering metrics: %s", err)
return return
} }
@@ -71,7 +71,7 @@ func TestInitKindMetrics(t *testing.T) {
for name, count := range expectedMetrics { for name, count := range expectedMetrics {
if count[1] != count[0] { if count[1] != count[0] {
t.Errorf("%s: Expected %d metrics, got %d metrics", name, count[0], count[1]) t.Errorf("with: %s, expected %d metrics, got %d metrics", name, count[0], count[1])
} }
} }
} }

View File

@@ -58,7 +58,7 @@ function lowercase-errors() {
if grep -E 'errors\.New\(\"[A-Z]' "$1"; then if grep -E 'errors\.New\(\"[A-Z]' "$1"; then
return 1 return 1
fi fi
if grep -E 'fmt\.Errorf\(\"[A-Z]' "$1"; then if grep -E 't\.Errorf\(\"[A-Z]' "$1"; then # t.Errorf or fmt.Errorf
return 1 return 1
fi fi
# TODO: add errwrap.Wrap* related matching # TODO: add errwrap.Wrap* related matching

View File

@@ -44,7 +44,7 @@ func TestExpandHome(t *testing.T) {
} }
if actual != test.expanded { if actual != test.expanded {
t.Errorf("ExpandHome(%s): expected %s, actual %s", test.path, test.expanded, actual) t.Errorf("input: %s, expected: %s, actual: %s", test.path, test.expanded, actual)
} }
} }
} }

View File

@@ -43,7 +43,7 @@ func TestNumToAlpha(t *testing.T) {
for _, test := range numToAlphaTests { for _, test := range numToAlphaTests {
actual := NumToAlpha(test.number) actual := NumToAlpha(test.number)
if actual != test.result { if actual != test.result {
t.Errorf("NumToAlpha(%d): expected %s, actual %s", test.number, test.result, actual) t.Errorf("input: %d, expected: %s, actual: %s", test.number, test.result, actual)
} }
} }
} }
@@ -51,51 +51,51 @@ func TestNumToAlpha(t *testing.T) {
func TestUtilT1(t *testing.T) { func TestUtilT1(t *testing.T) {
if Dirname("/foo/bar/baz") != "/foo/bar/" { if Dirname("/foo/bar/baz") != "/foo/bar/" {
t.Errorf("Result is incorrect.") t.Errorf("result is incorrect.")
} }
if Dirname("/foo/bar/baz/") != "/foo/bar/" { if Dirname("/foo/bar/baz/") != "/foo/bar/" {
t.Errorf("Result is incorrect.") t.Errorf("result is incorrect.")
} }
if Dirname("/foo/") != "/" { if Dirname("/foo/") != "/" {
t.Errorf("Result is incorrect.") t.Errorf("result is incorrect.")
} }
if Dirname("/") != "" { // TODO: should this equal "/" or "" ? if Dirname("/") != "" { // TODO: should this equal "/" or "" ?
t.Errorf("Result is incorrect.") t.Errorf("result is incorrect.")
} }
if Dirname("foo/bar.conf") != "foo/" { if Dirname("foo/bar.conf") != "foo/" {
t.Errorf("Result is incorrect.") t.Errorf("result is incorrect.")
} }
if Dirname("foo/bar/baz.conf") != "foo/bar/" { if Dirname("foo/bar/baz.conf") != "foo/bar/" {
t.Errorf("Result is incorrect.") t.Errorf("result is incorrect.")
} }
if Dirname("bar.conf") != "" { if Dirname("bar.conf") != "" {
t.Errorf("Result is incorrect.") t.Errorf("result is incorrect.")
} }
if Basename("/foo/bar/baz") != "baz" { if Basename("/foo/bar/baz") != "baz" {
t.Errorf("Result is incorrect.") t.Errorf("result is incorrect.")
} }
if Basename("/foo/bar/baz/") != "baz/" { if Basename("/foo/bar/baz/") != "baz/" {
t.Errorf("Result is incorrect.") t.Errorf("result is incorrect.")
} }
if Basename("/foo/") != "foo/" { if Basename("/foo/") != "foo/" {
t.Errorf("Result is incorrect.") t.Errorf("result is incorrect.")
} }
if Basename("/") != "/" { // TODO: should this equal "" or "/" ? if Basename("/") != "/" { // TODO: should this equal "" or "/" ?
t.Errorf("Result is incorrect.") t.Errorf("result is incorrect.")
} }
if Basename("") != "" { // TODO: should this equal something different? if Basename("") != "" { // TODO: should this equal something different?
t.Errorf("Result is incorrect.") t.Errorf("result is incorrect.")
} }
} }
@@ -105,87 +105,87 @@ func TestUtilT2(t *testing.T) {
p0 := "/" p0 := "/"
r0 := []string{""} // TODO: is this correct? r0 := []string{""} // TODO: is this correct?
if len(PathSplit(p0)) != len(r0) { if len(PathSplit(p0)) != len(r0) {
t.Errorf("Result should be: %q.", r0) t.Errorf("result should be: %q.", r0)
t.Errorf("Result should have a length of: %v.", len(r0)) t.Errorf("result should have a length of: %v.", len(r0))
} }
p1 := "/foo/bar/baz" p1 := "/foo/bar/baz"
r1 := []string{"", "foo", "bar", "baz"} r1 := []string{"", "foo", "bar", "baz"}
if len(PathSplit(p1)) != len(r1) { if len(PathSplit(p1)) != len(r1) {
//t.Errorf("Result should be: %q.", r1) //t.Errorf("result should be: %q.", r1)
t.Errorf("Result should have a length of: %v.", len(r1)) t.Errorf("result should have a length of: %v.", len(r1))
} }
p2 := "/foo/bar/baz/" p2 := "/foo/bar/baz/"
r2 := []string{"", "foo", "bar", "baz"} r2 := []string{"", "foo", "bar", "baz"}
if len(PathSplit(p2)) != len(r2) { if len(PathSplit(p2)) != len(r2) {
t.Errorf("Result should have a length of: %v.", len(r2)) t.Errorf("result should have a length of: %v.", len(r2))
} }
} }
func TestUtilT3(t *testing.T) { func TestUtilT3(t *testing.T) {
if HasPathPrefix("/foo/bar/baz", "/foo/ba") != false { if HasPathPrefix("/foo/bar/baz", "/foo/ba") != false {
t.Errorf("Result should be false.") t.Errorf("result should be false.")
} }
if HasPathPrefix("/foo/bar/baz", "/foo/bar") != true { if HasPathPrefix("/foo/bar/baz", "/foo/bar") != true {
t.Errorf("Result should be true.") t.Errorf("result should be true.")
} }
if HasPathPrefix("/foo/bar/baz", "/foo/bar/") != true { if HasPathPrefix("/foo/bar/baz", "/foo/bar/") != true {
t.Errorf("Result should be true.") t.Errorf("result should be true.")
} }
if HasPathPrefix("/foo/bar/baz/", "/foo/bar") != true { if HasPathPrefix("/foo/bar/baz/", "/foo/bar") != true {
t.Errorf("Result should be true.") t.Errorf("result should be true.")
} }
if HasPathPrefix("/foo/bar/baz/", "/foo/bar/") != true { if HasPathPrefix("/foo/bar/baz/", "/foo/bar/") != true {
t.Errorf("Result should be true.") t.Errorf("result should be true.")
} }
if HasPathPrefix("/foo/bar/baz/", "/foo/bar/baz/dude") != false { if HasPathPrefix("/foo/bar/baz/", "/foo/bar/baz/dude") != false {
t.Errorf("Result should be false.") t.Errorf("result should be false.")
} }
if HasPathPrefix("/foo/bar/baz/boo/", "/foo/") != true { if HasPathPrefix("/foo/bar/baz/boo/", "/foo/") != true {
t.Errorf("Result should be true.") t.Errorf("result should be true.")
} }
} }
func TestUtilT4(t *testing.T) { func TestUtilT4(t *testing.T) {
if PathPrefixDelta("/foo/bar/baz", "/foo/ba") != -1 { if PathPrefixDelta("/foo/bar/baz", "/foo/ba") != -1 {
t.Errorf("Result should be -1.") t.Errorf("result should be -1.")
} }
if PathPrefixDelta("/foo/bar/baz", "/foo/bar") != 1 { if PathPrefixDelta("/foo/bar/baz", "/foo/bar") != 1 {
t.Errorf("Result should be 1.") t.Errorf("result should be 1.")
} }
if PathPrefixDelta("/foo/bar/baz", "/foo/bar/") != 1 { if PathPrefixDelta("/foo/bar/baz", "/foo/bar/") != 1 {
t.Errorf("Result should be 1.") t.Errorf("result should be 1.")
} }
if PathPrefixDelta("/foo/bar/baz/", "/foo/bar") != 1 { if PathPrefixDelta("/foo/bar/baz/", "/foo/bar") != 1 {
t.Errorf("Result should be 1.") t.Errorf("result should be 1.")
} }
if PathPrefixDelta("/foo/bar/baz/", "/foo/bar/") != 1 { if PathPrefixDelta("/foo/bar/baz/", "/foo/bar/") != 1 {
t.Errorf("Result should be 1.") t.Errorf("result should be 1.")
} }
if PathPrefixDelta("/foo/bar/baz/", "/foo/bar/baz/dude") != -1 { if PathPrefixDelta("/foo/bar/baz/", "/foo/bar/baz/dude") != -1 {
t.Errorf("Result should be -1.") t.Errorf("result should be -1.")
} }
if PathPrefixDelta("/foo/bar/baz/a/b/c/", "/foo/bar/baz") != 3 { if PathPrefixDelta("/foo/bar/baz/a/b/c/", "/foo/bar/baz") != 3 {
t.Errorf("Result should be 3.") t.Errorf("result should be 3.")
} }
if PathPrefixDelta("/foo/bar/baz/", "/foo/bar/baz") != 0 { if PathPrefixDelta("/foo/bar/baz/", "/foo/bar/baz") != 0 {
t.Errorf("Result should be 0.") t.Errorf("result should be 0.")
} }
} }
@@ -193,17 +193,17 @@ func TestUtilT8(t *testing.T) {
r0 := []string{"/"} r0 := []string{"/"}
if fullList0 := PathSplitFullReversed("/"); !reflect.DeepEqual(r0, fullList0) { if fullList0 := PathSplitFullReversed("/"); !reflect.DeepEqual(r0, fullList0) {
t.Errorf("PathSplitFullReversed expected: %v; got: %v.", r0, fullList0) t.Errorf("expected: %v; got: %v.", r0, fullList0)
} }
r1 := []string{"/foo/bar/baz/file", "/foo/bar/baz/", "/foo/bar/", "/foo/", "/"} r1 := []string{"/foo/bar/baz/file", "/foo/bar/baz/", "/foo/bar/", "/foo/", "/"}
if fullList1 := PathSplitFullReversed("/foo/bar/baz/file"); !reflect.DeepEqual(r1, fullList1) { if fullList1 := PathSplitFullReversed("/foo/bar/baz/file"); !reflect.DeepEqual(r1, fullList1) {
t.Errorf("PathSplitFullReversed expected: %v; got: %v.", r1, fullList1) t.Errorf("expected: %v; got: %v.", r1, fullList1)
} }
r2 := []string{"/foo/bar/baz/dir/", "/foo/bar/baz/", "/foo/bar/", "/foo/", "/"} r2 := []string{"/foo/bar/baz/dir/", "/foo/bar/baz/", "/foo/bar/", "/foo/", "/"}
if fullList2 := PathSplitFullReversed("/foo/bar/baz/dir/"); !reflect.DeepEqual(r2, fullList2) { if fullList2 := PathSplitFullReversed("/foo/bar/baz/dir/"); !reflect.DeepEqual(r2, fullList2) {
t.Errorf("PathSplitFullReversed expected: %v; got: %v.", r2, fullList2) t.Errorf("expected: %v; got: %v.", r2, fullList2)
} }
} }
@@ -341,9 +341,9 @@ func TestUtilT9(t *testing.T) {
sort.Strings(dirify) sort.Strings(dirify)
equals := reflect.DeepEqual(fileListOut, dirify) equals := reflect.DeepEqual(fileListOut, dirify)
if a, b := len(fileListOut), len(dirify); a != b { if a, b := len(fileListOut), len(dirify); a != b {
t.Errorf("DirifyFileList counts didn't match: %d != %d", a, b) t.Errorf("counts didn't match: %d != %d", a, b)
} else if !equals { } else if !equals {
t.Errorf("DirifyFileList did not match expected!") t.Errorf("did not match expected!")
for i := 0; i < len(dirify); i++ { for i := 0; i < len(dirify); i++ {
if fileListOut[i] != dirify[i] { if fileListOut[i] != dirify[i] {
t.Errorf("# %d: %v <> %v", i, fileListOut[i], dirify[i]) t.Errorf("# %d: %v <> %v", i, fileListOut[i], dirify[i])
@@ -377,9 +377,9 @@ func TestUtilT10(t *testing.T) {
sort.Strings(dirify) sort.Strings(dirify)
equals := reflect.DeepEqual(fileListOut, dirify) equals := reflect.DeepEqual(fileListOut, dirify)
if a, b := len(fileListOut), len(dirify); a != b { if a, b := len(fileListOut), len(dirify); a != b {
t.Errorf("DirifyFileList counts didn't match: %d != %d", a, b) t.Errorf("counts didn't match: %d != %d", a, b)
} else if !equals { } else if !equals {
t.Errorf("DirifyFileList did not match expected!") t.Errorf("did not match expected!")
for i := 0; i < len(dirify); i++ { for i := 0; i < len(dirify); i++ {
if fileListOut[i] != dirify[i] { if fileListOut[i] != dirify[i] {
t.Errorf("# %d: %v <> %v", i, fileListOut[i], dirify[i]) t.Errorf("# %d: %v <> %v", i, fileListOut[i], dirify[i])
@@ -395,7 +395,7 @@ func TestUtilT11(t *testing.T) {
out1 := RemoveCommonFilePrefixes(in1) out1 := RemoveCommonFilePrefixes(in1)
sort.Strings(out1) sort.Strings(out1)
if !reflect.DeepEqual(ex1, out1) { if !reflect.DeepEqual(ex1, out1) {
t.Errorf("RemoveCommonFilePrefixes expected: %v; got: %v.", ex1, out1) t.Errorf("expected: %v; got: %v.", ex1, out1)
} }
in2 := []string{"/", "/usr/"} in2 := []string{"/", "/usr/"}
@@ -404,14 +404,14 @@ func TestUtilT11(t *testing.T) {
out2 := RemoveCommonFilePrefixes(in2) out2 := RemoveCommonFilePrefixes(in2)
sort.Strings(out2) sort.Strings(out2)
if !reflect.DeepEqual(ex2, out2) { if !reflect.DeepEqual(ex2, out2) {
t.Errorf("RemoveCommonFilePrefixes expected: %v; got: %v.", ex2, out2) t.Errorf("expected: %v; got: %v.", ex2, out2)
} }
in3 := []string{"/"} in3 := []string{"/"}
ex3 := []string{"/"} ex3 := []string{"/"}
out3 := RemoveCommonFilePrefixes(in3) out3 := RemoveCommonFilePrefixes(in3)
if !reflect.DeepEqual(ex3, out3) { if !reflect.DeepEqual(ex3, out3) {
t.Errorf("RemoveCommonFilePrefixes expected: %v; got: %v.", ex3, out3) t.Errorf("expected: %v; got: %v.", ex3, out3)
} }
in4 := []string{"/usr/bin/foo", "/usr/bin/bar", "/usr/lib/", "/usr/share/"} in4 := []string{"/usr/bin/foo", "/usr/bin/bar", "/usr/lib/", "/usr/share/"}
@@ -420,7 +420,7 @@ func TestUtilT11(t *testing.T) {
out4 := RemoveCommonFilePrefixes(in4) out4 := RemoveCommonFilePrefixes(in4)
sort.Strings(out4) sort.Strings(out4)
if !reflect.DeepEqual(ex4, out4) { if !reflect.DeepEqual(ex4, out4) {
t.Errorf("RemoveCommonFilePrefixes expected: %v; got: %v.", ex4, out4) t.Errorf("expected: %v; got: %v.", ex4, out4)
} }
in5 := []string{"/usr/bin/foo", "/usr/bin/bar", "/usr/lib/", "/usr/share/", "/usr/bin"} in5 := []string{"/usr/bin/foo", "/usr/bin/bar", "/usr/lib/", "/usr/share/", "/usr/bin"}
@@ -429,7 +429,7 @@ func TestUtilT11(t *testing.T) {
out5 := RemoveCommonFilePrefixes(in5) out5 := RemoveCommonFilePrefixes(in5)
sort.Strings(out5) sort.Strings(out5)
if !reflect.DeepEqual(ex5, out5) { if !reflect.DeepEqual(ex5, out5) {
t.Errorf("RemoveCommonFilePrefixes expected: %v; got: %v.", ex5, out5) t.Errorf("expected: %v; got: %v.", ex5, out5)
} }
in6 := []string{"/etc/drbd.d/", "/lib/drbd/", "/usr/lib/drbd/", "/usr/lib/systemd/system/", "/usr/lib/tmpfiles.d/", "/usr/sbin/", "/usr/share/doc/drbd-utils/", "/usr/share/man/man5/", "/usr/share/man/man8/", "/usr/share/doc/", "/var/lib/"} in6 := []string{"/etc/drbd.d/", "/lib/drbd/", "/usr/lib/drbd/", "/usr/lib/systemd/system/", "/usr/lib/tmpfiles.d/", "/usr/sbin/", "/usr/share/doc/drbd-utils/", "/usr/share/man/man5/", "/usr/share/man/man8/", "/usr/share/doc/", "/var/lib/"}
@@ -438,7 +438,7 @@ func TestUtilT11(t *testing.T) {
out6 := RemoveCommonFilePrefixes(in6) out6 := RemoveCommonFilePrefixes(in6)
sort.Strings(out6) sort.Strings(out6)
if !reflect.DeepEqual(ex6, out6) { if !reflect.DeepEqual(ex6, out6) {
t.Errorf("RemoveCommonFilePrefixes expected: %v; got: %v.", ex6, out6) t.Errorf("expected: %v; got: %v.", ex6, out6)
} }
in7 := []string{"/etc/", "/lib/", "/usr/lib/", "/usr/lib/systemd/", "/usr/", "/usr/share/doc/", "/usr/share/man/", "/var/"} in7 := []string{"/etc/", "/lib/", "/usr/lib/", "/usr/lib/systemd/", "/usr/", "/usr/share/doc/", "/usr/share/man/", "/var/"}
@@ -447,7 +447,7 @@ func TestUtilT11(t *testing.T) {
out7 := RemoveCommonFilePrefixes(in7) out7 := RemoveCommonFilePrefixes(in7)
sort.Strings(out7) sort.Strings(out7)
if !reflect.DeepEqual(ex7, out7) { if !reflect.DeepEqual(ex7, out7) {
t.Errorf("RemoveCommonFilePrefixes expected: %v; got: %v.", ex7, out7) t.Errorf("expected: %v; got: %v.", ex7, out7)
} }
in8 := []string{ in8 := []string{
@@ -576,7 +576,7 @@ func TestUtilT11(t *testing.T) {
out8 := RemoveCommonFilePrefixes(in8) out8 := RemoveCommonFilePrefixes(in8)
sort.Strings(out8) sort.Strings(out8)
if !reflect.DeepEqual(ex8, out8) { if !reflect.DeepEqual(ex8, out8) {
t.Errorf("RemoveCommonFilePrefixes expected: %v; got: %v.", ex8, out8) t.Errorf("expected: %v; got: %v.", ex8, out8)
} }
in9 := []string{ in9 := []string{
@@ -623,7 +623,7 @@ func TestUtilT11(t *testing.T) {
out9 := RemoveCommonFilePrefixes(in9) out9 := RemoveCommonFilePrefixes(in9)
sort.Strings(out9) sort.Strings(out9)
if !reflect.DeepEqual(ex9, out9) { if !reflect.DeepEqual(ex9, out9) {
t.Errorf("RemoveCommonFilePrefixes expected: %v; got: %v.", ex9, out9) t.Errorf("expected: %v; got: %v.", ex9, out9)
} }
in10 := []string{ in10 := []string{
@@ -752,7 +752,7 @@ func TestUtilT11(t *testing.T) {
out10 := RemoveCommonFilePrefixes(in10) out10 := RemoveCommonFilePrefixes(in10)
sort.Strings(out10) sort.Strings(out10)
if !reflect.DeepEqual(ex10, out10) { if !reflect.DeepEqual(ex10, out10) {
t.Errorf("RemoveCommonFilePrefixes expected: %v; got: %v.", ex10, out10) t.Errorf("expected: %v; got: %v.", ex10, out10)
for i := 0; i < len(ex10); i++ { for i := 0; i < len(ex10); i++ {
if ex10[i] != out10[i] { if ex10[i] != out10[i] {
t.Errorf("# %d: %v <> %v", i, ex10[i], out10[i]) t.Errorf("# %d: %v <> %v", i, ex10[i], out10[i])
@@ -769,7 +769,7 @@ func TestUtilFlattenListWithSplit1(t *testing.T) {
sort.Strings(out) sort.Strings(out)
sort.Strings(ex) sort.Strings(ex)
if !reflect.DeepEqual(ex, out) { if !reflect.DeepEqual(ex, out) {
t.Errorf("FlattenListWithSplit expected: %v; got: %v.", ex, out) t.Errorf("expected: %v; got: %v.", ex, out)
} }
} }
@@ -780,7 +780,7 @@ func TestUtilFlattenListWithSplit1(t *testing.T) {
sort.Strings(out) sort.Strings(out)
sort.Strings(ex) sort.Strings(ex)
if !reflect.DeepEqual(ex, out) { if !reflect.DeepEqual(ex, out) {
t.Errorf("FlattenListWithSplit expected: %v; got: %v.", ex, out) t.Errorf("expected: %v; got: %v.", ex, out)
} }
} }
@@ -791,7 +791,7 @@ func TestUtilFlattenListWithSplit1(t *testing.T) {
sort.Strings(out) sort.Strings(out)
sort.Strings(ex) sort.Strings(ex)
if !reflect.DeepEqual(ex, out) { if !reflect.DeepEqual(ex, out) {
t.Errorf("FlattenListWithSplit expected: %v; got: %v.", ex, out) t.Errorf("expected: %v; got: %v.", ex, out)
} }
} }
@@ -802,7 +802,7 @@ func TestUtilFlattenListWithSplit1(t *testing.T) {
sort.Strings(out) sort.Strings(out)
sort.Strings(ex) sort.Strings(ex)
if !reflect.DeepEqual(ex, out) { if !reflect.DeepEqual(ex, out) {
t.Errorf("FlattenListWithSplit expected: %v; got: %v.", ex, out) t.Errorf("expected: %v; got: %v.", ex, out)
} }
} }
@@ -813,7 +813,7 @@ func TestUtilFlattenListWithSplit1(t *testing.T) {
sort.Strings(out) sort.Strings(out)
sort.Strings(ex) sort.Strings(ex)
if !reflect.DeepEqual(ex, out) { if !reflect.DeepEqual(ex, out) {
t.Errorf("FlattenListWithSplit expected: %v; got: %v.", ex, out) t.Errorf("expected: %v; got: %v.", ex, out)
} }
} }
@@ -824,7 +824,7 @@ func TestUtilFlattenListWithSplit1(t *testing.T) {
sort.Strings(out) sort.Strings(out)
sort.Strings(ex) sort.Strings(ex)
if !reflect.DeepEqual(ex, out) { if !reflect.DeepEqual(ex, out) {
t.Errorf("FlattenListWithSplit expected: %v; got: %v.", ex, out) t.Errorf("expected: %v; got: %v.", ex, out)
} }
} }
} }
@@ -1292,7 +1292,7 @@ func TestPriorityStrSliceSort0(t *testing.T) {
out := PriorityStrSliceSort(in, fn) out := PriorityStrSliceSort(in, fn)
if !reflect.DeepEqual(ex, out) { if !reflect.DeepEqual(ex, out) {
t.Errorf("PriorityStrSliceSort expected: %v; got: %v.", ex, out) t.Errorf("expected: %v; got: %v.", ex, out)
} }
} }
@@ -1306,7 +1306,7 @@ func TestPriorityStrSliceSort1(t *testing.T) {
out := PriorityStrSliceSort(in, fn) out := PriorityStrSliceSort(in, fn)
if !reflect.DeepEqual(ex, out) { if !reflect.DeepEqual(ex, out) {
t.Errorf("PriorityStrSliceSort expected: %v; got: %v.", ex, out) t.Errorf("expected: %v; got: %v.", ex, out)
} }
} }
@@ -1320,7 +1320,7 @@ func TestPriorityStrSliceSort2(t *testing.T) {
out := PriorityStrSliceSort(in, fn) out := PriorityStrSliceSort(in, fn)
if !reflect.DeepEqual(ex, out) { if !reflect.DeepEqual(ex, out) {
t.Errorf("PriorityStrSliceSort expected: %v; got: %v.", ex, out) t.Errorf("expected: %v; got: %v.", ex, out)
} }
} }
@@ -1334,7 +1334,7 @@ func TestPriorityStrSliceSort3(t *testing.T) {
out := PriorityStrSliceSort(in, fn) out := PriorityStrSliceSort(in, fn)
if !reflect.DeepEqual(ex, out) { if !reflect.DeepEqual(ex, out) {
t.Errorf("PriorityStrSliceSort expected: %v; got: %v.", ex, out) t.Errorf("expected: %v; got: %v.", ex, out)
} }
} }
@@ -1348,7 +1348,7 @@ func TestPriorityStrSliceSort4(t *testing.T) {
out := PriorityStrSliceSort(in, fn) out := PriorityStrSliceSort(in, fn)
if !reflect.DeepEqual(ex, out) { if !reflect.DeepEqual(ex, out) {
t.Errorf("PriorityStrSliceSort expected: %v; got: %v.", ex, out) t.Errorf("expected: %v; got: %v.", ex, out)
} }
} }