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