mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
added more tests to the checksums
This commit is contained in:
parent
881bba915b
commit
c2642e0c52
@ -21,6 +21,10 @@ func calculate(hash hash.Hash, path string) (result string, err error) {
|
|||||||
}
|
}
|
||||||
defer func() { _ = file.Close() }()
|
defer func() { _ = file.Close() }()
|
||||||
|
|
||||||
|
return doCalculate(hash, file)
|
||||||
|
}
|
||||||
|
|
||||||
|
func doCalculate(hash hash.Hash, file *os.File) (result string, err error) {
|
||||||
_, err = io.Copy(hash, file)
|
_, err = io.Copy(hash, file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package checksum
|
package checksum
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/sha256"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -25,3 +27,15 @@ func TestOpenFailure(t *testing.T) {
|
|||||||
assert.Empty(sum)
|
assert.Empty(sum)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFileDoesntExist(t *testing.T) {
|
||||||
|
var assert = assert.New(t)
|
||||||
|
folder, err := ioutil.TempDir("", "goreleasertest")
|
||||||
|
assert.NoError(err)
|
||||||
|
var path = filepath.Join(folder, "subject")
|
||||||
|
file, err := os.Create(path)
|
||||||
|
assert.NoError(err)
|
||||||
|
assert.NoError(file.Close())
|
||||||
|
_, err = doCalculate(sha256.New(), file)
|
||||||
|
assert.Error(err)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user