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() }()
|
||||
|
||||
return doCalculate(hash, file)
|
||||
}
|
||||
|
||||
func doCalculate(hash hash.Hash, file *os.File) (result string, err error) {
|
||||
_, err = io.Copy(hash, file)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -1,7 +1,9 @@
|
||||
package checksum
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@ -25,3 +27,15 @@ func TestOpenFailure(t *testing.T) {
|
||||
assert.Empty(sum)
|
||||
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