@@ -2,6 +2,8 @@ package gitbase
2
2
3
3
import (
4
4
"fmt"
5
+ "os"
6
+ "path/filepath"
5
7
"testing"
6
8
7
9
"github.com/stretchr/testify/require"
@@ -27,7 +29,7 @@ func TestChecksum(t *testing.T) {
27
29
c := & checksumable {pool }
28
30
checksum , err := c .Checksum ()
29
31
require .NoError (err )
30
- require .Equal ("ogfv7HAwFigDgtuW4tbnEP+Zl40 =" , checksum )
32
+ require .Equal ("mGPoKCyOIkXX4reGe1vTBPIOg2E =" , checksum )
31
33
32
34
pool = NewRepositoryPool (cache .DefaultMaxSize )
33
35
path := fixtures .ByTag ("worktree" ).One ().Worktree ().Root ()
@@ -36,5 +38,53 @@ func TestChecksum(t *testing.T) {
36
38
c = & checksumable {pool }
37
39
checksum , err = c .Checksum ()
38
40
require .NoError (err )
39
- require .Equal ("5kfLCygyBSZFMh+nFzFNk3zAUTQ=" , checksum )
41
+ require .Equal ("rwQnBj7HRazv9wuU//nQ+nuf0WY=" , checksum )
42
+ }
43
+
44
+ func TestChecksumSiva (t * testing.T ) {
45
+ require := require .New (t )
46
+
47
+ pool := NewRepositoryPool (cache .DefaultMaxSize )
48
+ require .NoError (
49
+ filepath .Walk ("_testdata" , func (path string , info os.FileInfo , err error ) error {
50
+ if err != nil {
51
+ return err
52
+ }
53
+
54
+ if IsSivaFile (path ) {
55
+ require .NoError (pool .AddSivaFile (path ))
56
+ }
57
+
58
+ return nil
59
+ }),
60
+ )
61
+
62
+ c := & checksumable {pool }
63
+ checksum , err := c .Checksum ()
64
+ require .NoError (err )
65
+ require .Equal ("wJEvZNAc7QRszsf9KhGu+UeKto0=" , checksum )
66
+ }
67
+
68
+ func TestChecksumStable (t * testing.T ) {
69
+ require := require .New (t )
70
+
71
+ require .NoError (fixtures .Init ())
72
+ defer func () {
73
+ require .NoError (fixtures .Clean ())
74
+ }()
75
+
76
+ pool := NewRepositoryPool (cache .DefaultMaxSize )
77
+
78
+ for i , f := range fixtures .ByTag ("worktree" ) {
79
+ path := f .Worktree ().Root ()
80
+ require .NoError (pool .AddGitWithID (fmt .Sprintf ("repo_%d" , i ), path ))
81
+ }
82
+
83
+ c := & checksumable {pool }
84
+
85
+ for i := 0 ; i < 100 ; i ++ {
86
+ checksum , err := c .Checksum ()
87
+ require .NoError (err )
88
+ require .Equal ("mGPoKCyOIkXX4reGe1vTBPIOg2E=" , checksum )
89
+ }
40
90
}
0 commit comments