fix ineffectual assignment to err (ineffassign)
This commit is contained in:
54
unxz_test.go
54
unxz_test.go
@ -24,6 +24,9 @@ func testNullContent(t *testing.T) {
|
|||||||
defer aFile.Close()
|
defer aFile.Close()
|
||||||
|
|
||||||
aFileContent, err := ioutil.ReadAll(aFile)
|
aFileContent, err := ioutil.ReadAll(aFile)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
aOutFile, err := os.Open(path.Join(currentDir(), "./test/out/a.txt"))
|
aOutFile, err := os.Open(path.Join(currentDir(), "./test/out/a.txt"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -32,6 +35,9 @@ func testNullContent(t *testing.T) {
|
|||||||
defer aOutFile.Close()
|
defer aOutFile.Close()
|
||||||
|
|
||||||
aOutFileContent, err := ioutil.ReadAll(aOutFile)
|
aOutFileContent, err := ioutil.ReadAll(aOutFile)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
if string(aFileContent) != string(aOutFileContent) {
|
if string(aFileContent) != string(aOutFileContent) {
|
||||||
t.Fatal("Unxz file content error.")
|
t.Fatal("Unxz file content error.")
|
||||||
@ -50,6 +56,9 @@ func testContentEqual(t *testing.T) {
|
|||||||
defer bFile.Close()
|
defer bFile.Close()
|
||||||
|
|
||||||
bFileContent, err := ioutil.ReadAll(bFile)
|
bFileContent, err := ioutil.ReadAll(bFile)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
bOutFile, err := os.Open(path.Join(currentDir(), "./test/out/b.txt"))
|
bOutFile, err := os.Open(path.Join(currentDir(), "./test/out/b.txt"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -58,6 +67,9 @@ func testContentEqual(t *testing.T) {
|
|||||||
defer bOutFile.Close()
|
defer bOutFile.Close()
|
||||||
|
|
||||||
bOutFileContent, err := ioutil.ReadAll(bOutFile)
|
bOutFileContent, err := ioutil.ReadAll(bOutFile)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
if string(bFileContent) != string(bOutFileContent) {
|
if string(bFileContent) != string(bOutFileContent) {
|
||||||
t.Log(string(bFileContent))
|
t.Log(string(bFileContent))
|
||||||
@ -74,6 +86,9 @@ func testLink(t *testing.T) {
|
|||||||
defer cOutFile.Close()
|
defer cOutFile.Close()
|
||||||
|
|
||||||
cOutFileContent, err := ioutil.ReadAll(cOutFile)
|
cOutFileContent, err := ioutil.ReadAll(cOutFile)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
cOutLinkFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/c.txt"))
|
cOutLinkFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/c.txt"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -82,6 +97,9 @@ func testLink(t *testing.T) {
|
|||||||
defer cOutLinkFile.Close()
|
defer cOutLinkFile.Close()
|
||||||
|
|
||||||
cOutLinkFileContent, err := ioutil.ReadAll(cOutLinkFile)
|
cOutLinkFileContent, err := ioutil.ReadAll(cOutLinkFile)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
if string(cOutFileContent) != string(cOutLinkFileContent) {
|
if string(cOutFileContent) != string(cOutLinkFileContent) {
|
||||||
t.Fatal("Unxz file content error or link file content error.")
|
t.Fatal("Unxz file content error or link file content error.")
|
||||||
@ -101,6 +119,9 @@ func testLink(t *testing.T) {
|
|||||||
defer cOutFileNew.Close()
|
defer cOutFileNew.Close()
|
||||||
|
|
||||||
cOutFileContentNew, err := ioutil.ReadAll(cOutFileNew)
|
cOutFileContentNew, err := ioutil.ReadAll(cOutFileNew)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
t.Log("New c.txt content:", string(cOutFileContentNew))
|
t.Log("New c.txt content:", string(cOutFileContentNew))
|
||||||
|
|
||||||
cOutLinkFileNew, err := os.Open(path.Join(currentDir(), "./test/out/dir/c.txt"))
|
cOutLinkFileNew, err := os.Open(path.Join(currentDir(), "./test/out/dir/c.txt"))
|
||||||
@ -110,6 +131,9 @@ func testLink(t *testing.T) {
|
|||||||
defer cOutLinkFileNew.Close()
|
defer cOutLinkFileNew.Close()
|
||||||
|
|
||||||
cOutLinkFileContentNew, err := ioutil.ReadAll(cOutLinkFileNew)
|
cOutLinkFileContentNew, err := ioutil.ReadAll(cOutLinkFileNew)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
if string(cOutFileContentNew) != string(cOutLinkFileContentNew) {
|
if string(cOutFileContentNew) != string(cOutLinkFileContentNew) {
|
||||||
t.Fatal("Unxz file link error.")
|
t.Fatal("Unxz file link error.")
|
||||||
@ -118,6 +142,9 @@ func testLink(t *testing.T) {
|
|||||||
|
|
||||||
func testSymlink(t *testing.T) {
|
func testSymlink(t *testing.T) {
|
||||||
targetURL, err := filepath.EvalSymlinks(path.Join(currentDir(), "./test/out/d.txt"))
|
targetURL, err := filepath.EvalSymlinks(path.Join(currentDir(), "./test/out/d.txt"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
if targetURL != path.Join(currentDir(), "./test/out/dir/d.txt") {
|
if targetURL != path.Join(currentDir(), "./test/out/dir/d.txt") {
|
||||||
t.Fatal("Unxz file Symlink error.")
|
t.Fatal("Unxz file Symlink error.")
|
||||||
@ -130,6 +157,9 @@ func testSymlink(t *testing.T) {
|
|||||||
defer dOutSymlinkFile.Close()
|
defer dOutSymlinkFile.Close()
|
||||||
|
|
||||||
dOutSymlinkFileContent, err := ioutil.ReadAll(dOutSymlinkFile)
|
dOutSymlinkFileContent, err := ioutil.ReadAll(dOutSymlinkFile)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
dOutFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/d.txt"))
|
dOutFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/d.txt"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -138,6 +168,9 @@ func testSymlink(t *testing.T) {
|
|||||||
defer dOutFile.Close()
|
defer dOutFile.Close()
|
||||||
|
|
||||||
dOutFileContent, err := ioutil.ReadAll(dOutFile)
|
dOutFileContent, err := ioutil.ReadAll(dOutFile)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
if string(dOutSymlinkFileContent) != string(dOutFileContent) {
|
if string(dOutSymlinkFileContent) != string(dOutFileContent) {
|
||||||
t.Fatal("The content of symlink file is not equal to that of target file")
|
t.Fatal("The content of symlink file is not equal to that of target file")
|
||||||
@ -152,6 +185,9 @@ func testLintInDir(t *testing.T) {
|
|||||||
defer eOutFile.Close()
|
defer eOutFile.Close()
|
||||||
|
|
||||||
eOutFileContent, err := ioutil.ReadAll(eOutFile)
|
eOutFileContent, err := ioutil.ReadAll(eOutFile)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
eOutLinkFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/e.txt"))
|
eOutLinkFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/e.txt"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -160,6 +196,9 @@ func testLintInDir(t *testing.T) {
|
|||||||
defer eOutLinkFile.Close()
|
defer eOutLinkFile.Close()
|
||||||
|
|
||||||
eOutLinkFileContent, err := ioutil.ReadAll(eOutLinkFile)
|
eOutLinkFileContent, err := ioutil.ReadAll(eOutLinkFile)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
if string(eOutFileContent) != string(eOutLinkFileContent) {
|
if string(eOutFileContent) != string(eOutLinkFileContent) {
|
||||||
t.Fatal("Unxz file content error or link file content error.")
|
t.Fatal("Unxz file content error or link file content error.")
|
||||||
@ -179,6 +218,9 @@ func testLintInDir(t *testing.T) {
|
|||||||
defer eOutFileNew.Close()
|
defer eOutFileNew.Close()
|
||||||
|
|
||||||
eOutFileContentNew, err := ioutil.ReadAll(eOutFileNew)
|
eOutFileContentNew, err := ioutil.ReadAll(eOutFileNew)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
t.Log("New dir/dir/e.txt content:", string(eOutFileContentNew))
|
t.Log("New dir/dir/e.txt content:", string(eOutFileContentNew))
|
||||||
|
|
||||||
eOutLinkFileNew, err := os.Open(path.Join(currentDir(), "./test/out/dir/e.txt"))
|
eOutLinkFileNew, err := os.Open(path.Join(currentDir(), "./test/out/dir/e.txt"))
|
||||||
@ -188,6 +230,9 @@ func testLintInDir(t *testing.T) {
|
|||||||
defer eOutLinkFileNew.Close()
|
defer eOutLinkFileNew.Close()
|
||||||
|
|
||||||
eOutLinkFileContentNew, err := ioutil.ReadAll(eOutLinkFileNew)
|
eOutLinkFileContentNew, err := ioutil.ReadAll(eOutLinkFileNew)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
if string(eOutFileContentNew) != string(eOutLinkFileContentNew) {
|
if string(eOutFileContentNew) != string(eOutLinkFileContentNew) {
|
||||||
t.Fatal("Unxz file link error.")
|
t.Fatal("Unxz file link error.")
|
||||||
@ -196,6 +241,9 @@ func testLintInDir(t *testing.T) {
|
|||||||
|
|
||||||
func testSymlinkInDir(t *testing.T) {
|
func testSymlinkInDir(t *testing.T) {
|
||||||
inDirTargetURL, err := filepath.EvalSymlinks(path.Join(currentDir(), "./test/out/dir/dir/f.txt"))
|
inDirTargetURL, err := filepath.EvalSymlinks(path.Join(currentDir(), "./test/out/dir/dir/f.txt"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
t.Log("F outSymlinkFile link:", inDirTargetURL)
|
t.Log("F outSymlinkFile link:", inDirTargetURL)
|
||||||
|
|
||||||
if inDirTargetURL != path.Join(currentDir(), "./test/out/dir/f.txt") {
|
if inDirTargetURL != path.Join(currentDir(), "./test/out/dir/f.txt") {
|
||||||
@ -209,6 +257,9 @@ func testSymlinkInDir(t *testing.T) {
|
|||||||
defer fOutSymlinkFile.Close()
|
defer fOutSymlinkFile.Close()
|
||||||
|
|
||||||
fOutSymlinkFileContent, err := ioutil.ReadAll(fOutSymlinkFile)
|
fOutSymlinkFileContent, err := ioutil.ReadAll(fOutSymlinkFile)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
fOutFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/f.txt"))
|
fOutFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/f.txt"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -217,6 +268,9 @@ func testSymlinkInDir(t *testing.T) {
|
|||||||
defer fOutFile.Close()
|
defer fOutFile.Close()
|
||||||
|
|
||||||
fOutFileContent, err := ioutil.ReadAll(fOutFile)
|
fOutFileContent, err := ioutil.ReadAll(fOutFile)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
if string(fOutSymlinkFileContent) != string(fOutFileContent) {
|
if string(fOutSymlinkFileContent) != string(fOutFileContent) {
|
||||||
t.Fatal("The content of symlink file is not equal to that of target file")
|
t.Fatal("The content of symlink file is not equal to that of target file")
|
||||||
|
Reference in New Issue
Block a user