forked from jgraichen/os-image-updater
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
64 lines (48 loc) · 2.13 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestScanChecksumMD5(t *testing.T) {
data := strings.NewReader("md5: e3b56c4d7669e6577629efcc3eadbd38 filename.img")
checksum, err := scanChecksum("filename.img", data)
assert.Nil(t, err)
assert.Equal(t, "e3b56c4d7669e6577629efcc3eadbd38", checksum)
}
func TestScanChecksumMD5SUM(t *testing.T) {
data := strings.NewReader("e3b56c4d7669e6577629efcc3eadbd38 filename.img")
checksum, err := scanChecksum("filename.img", data)
assert.Nil(t, err)
assert.Equal(t, "e3b56c4d7669e6577629efcc3eadbd38", checksum)
}
func TestScanChecksumSHA1(t *testing.T) {
data := strings.NewReader("sha1: ef455af318e57186f66e056ffd6daa64271bc654 filename.img")
checksum, err := scanChecksum("filename.img", data)
assert.Nil(t, err)
assert.Equal(t, "ef455af318e57186f66e056ffd6daa64271bc654", checksum)
}
func TestScanChecksumSHA1SUM(t *testing.T) {
data := strings.NewReader("ef455af318e57186f66e056ffd6daa64271bc654 filename.img")
checksum, err := scanChecksum("filename.img", data)
assert.Nil(t, err)
assert.Equal(t, "ef455af318e57186f66e056ffd6daa64271bc654", checksum)
}
func TestScanChecksumSHA256(t *testing.T) {
data := strings.NewReader("sha256: 0261f6c651ef377b13367412049230b5f0307f38e62dc8f78d3525ef89df8c02 filename.img")
checksum, err := scanChecksum("filename.img", data)
assert.Nil(t, err)
assert.Equal(t, "0261f6c651ef377b13367412049230b5f0307f38e62dc8f78d3525ef89df8c02", checksum)
}
func TestScanChecksumSHA256SUM(t *testing.T) {
data := strings.NewReader("0261f6c651ef377b13367412049230b5f0307f38e62dc8f78d3525ef89df8c02 filename.img")
checksum, err := scanChecksum("filename.img", data)
assert.Nil(t, err)
assert.Equal(t, "0261f6c651ef377b13367412049230b5f0307f38e62dc8f78d3525ef89df8c02", checksum)
}
func TestScanChecksumRockyLinux(t *testing.T) {
data := strings.NewReader("# Comment\nSHA256(filename.img) = 0261f6c651ef377b13367412049230b5f0307f38e62dc8f78d3525ef89df8c02")
checksum, err := scanChecksum("filename.img", data)
assert.Nil(t, err)
assert.Equal(t, "0261f6c651ef377b13367412049230b5f0307f38e62dc8f78d3525ef89df8c02", checksum)
}