@@ -8,7 +8,13 @@ import (
88
99 fixtures "github.com/src-d/go-git-fixtures"
1010 "github.com/stretchr/testify/require"
11- "gopkg.in/src-d/go-git.v4/plumbing/cache"
11+ "gopkg.in/src-d/go-billy.v4/osfs"
12+ )
13+
14+ const (
15+ checksumMulti = "W/lxpR0jZ6O6BqVANTYTDMlAS/4="
16+ checksumSingle = "zqLF31JlrtJ57XNC+cQ+2hSkBkw="
17+ checksumSiva = "X27U+Lww5UOk1+/21bVFgI4uJyM="
1218)
1319
1420func TestChecksum (t * testing.T ) {
@@ -18,40 +24,48 @@ func TestChecksum(t *testing.T) {
1824 require .NoError (fixtures .Clean ())
1925 }()
2026
21- pool := NewRepositoryPool (cache .DefaultMaxSize )
27+ lib , pool , err := newMultiPool ()
28+ require .NoError (err )
2229
2330 for i , f := range fixtures .ByTag ("worktree" ) {
2431 path := f .Worktree ().Root ()
25- require .NoError (pool . AddGitWithID (fmt .Sprintf ("repo_%d" , i ), path ))
32+ require .NoError (lib . AddPlain (fmt .Sprintf ("repo_%d" , i ), path , nil ))
2633 }
2734
2835 c := & checksumable {pool }
2936 checksum , err := c .Checksum ()
3037 require .NoError (err )
31- require .Equal ("mGPoKCyOIkXX4reGe1vTBPIOg2E=" , checksum )
38+ require .Equal (checksumMulti , checksum )
3239
33- pool = NewRepositoryPool (cache .DefaultMaxSize )
40+ lib , pool , err = newMultiPool ()
41+ require .NoError (err )
3442 path := fixtures .ByTag ("worktree" ).One ().Worktree ().Root ()
35- require .NoError (pool . AddGitWithID ("worktree" , path ))
43+ require .NoError (lib . AddPlain ("worktree" , path , nil ))
3644
3745 c = & checksumable {pool }
3846 checksum , err = c .Checksum ()
3947 require .NoError (err )
40- require .Equal ("rwQnBj7HRazv9wuU//nQ+nuf0WY=" , checksum )
48+ require .Equal (checksumSingle , checksum )
4149}
4250
4351func TestChecksumSiva (t * testing.T ) {
4452 require := require .New (t )
4553
46- pool := NewRepositoryPool (cache .DefaultMaxSize )
54+ lib , pool , err := newMultiPool ()
55+ require .NoError (err )
56+
57+ cwd , err := os .Getwd ()
58+ require .NoError (err )
59+ cwdFS := osfs .New (cwd )
60+
4761 require .NoError (
4862 filepath .Walk ("_testdata" , func (path string , info os.FileInfo , err error ) error {
4963 if err != nil {
5064 return err
5165 }
5266
5367 if IsSivaFile (path ) {
54- require .NoError (pool . AddSivaFile (path ))
68+ require .NoError (lib . AddSiva (path , cwdFS ))
5569 }
5670
5771 return nil
@@ -61,7 +75,7 @@ func TestChecksumSiva(t *testing.T) {
6175 c := & checksumable {pool }
6276 checksum , err := c .Checksum ()
6377 require .NoError (err )
64- require .Equal ("wJEvZNAc7QRszsf9KhGu+UeKto0=" , checksum )
78+ require .Equal (checksumSiva , checksum )
6579}
6680
6781func TestChecksumStable (t * testing.T ) {
@@ -71,18 +85,19 @@ func TestChecksumStable(t *testing.T) {
7185 require .NoError (fixtures .Clean ())
7286 }()
7387
74- pool := NewRepositoryPool (cache .DefaultMaxSize )
88+ lib , pool , err := newMultiPool ()
89+ require .NoError (err )
7590
7691 for i , f := range fixtures .ByTag ("worktree" ) {
7792 path := f .Worktree ().Root ()
78- require .NoError (pool . AddGitWithID (fmt .Sprintf ("repo_%d" , i ), path ))
93+ require .NoError (lib . AddPlain (fmt .Sprintf ("repo_%d" , i ), path , nil ))
7994 }
8095
8196 c := & checksumable {pool }
8297
8398 for i := 0 ; i < 100 ; i ++ {
8499 checksum , err := c .Checksum ()
85100 require .NoError (err )
86- require .Equal ("mGPoKCyOIkXX4reGe1vTBPIOg2E=" , checksum )
101+ require .Equal (checksumMulti , checksum )
87102 }
88103}
0 commit comments