Debian Codegraph @

plumbing/format/idxfile/idxfile_test.go

raw symbols SCIP
1 package idxfile_testscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/
2
3 import (
4 "bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/"
5 "cryptoscip-go gomod github.com/golang/go/src go1.25.0 crypto/"
6 "encoding/base64scip-go gomod github.com/golang/go/src go1.25.0 `encoding/base64`/"
7 "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/"
8 "ioscip-go gomod github.com/golang/go/src go1.25.0 io/"
9 "syncscip-go gomod github.com/golang/go/src go1.25.0 sync/"
10 "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/"
11
12 "github.com/stretchr/testify/suitescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/suite`/"
13
14 "github.com/go-git/go-git/v6/plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/"
15 "github.com/go-git/go-git/v6/plumbing/format/idxfilescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/"
16 "github.com/go-git/go-git/v6/plumbing/hashscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/hash`/"
17 )
18
19 func BenchmarkFindOffsetscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/BenchmarkFindOffset().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) {
20 idx, err := fixtureIndexscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureIndex().()
21 if err != nil {
22 b.Fatalscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatal().(err.Error())
23 }
24
25 for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() {
26 for _, h := range fixtureHashesscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureHashes. {
27 _, err := idx.FindOffsetscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/MemoryIndex#FindOffset().(h)
28 if err != nil {
29 b.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("error getting offset: %s", err)
30 }
31 }
32 }
33 }
34
35 func BenchmarkFindCRC32scip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/BenchmarkFindCRC32().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) {
36 idx, err := fixtureIndexscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureIndex().()
37 if err != nil {
38 b.Fatalscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatal().(err.Error())
39 }
40
41 for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() {
42 for _, h := range fixtureHashesscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureHashes. {
43 _, err := idx.FindCRC32scip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/MemoryIndex#FindCRC32().(h)
44 if err != nil {
45 b.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("error getting crc32: %s", err)
46 }
47 }
48 }
49 }
50
51 func BenchmarkContainsscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/BenchmarkContains().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) {
52 idx, err := fixtureIndexscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureIndex().()
53 if err != nil {
54 b.Fatalscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatal().(err.Error())
55 }
56
57 for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() {
58 for _, h := range fixtureHashesscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureHashes. {
59 ok, err := idx.Containsscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/MemoryIndex#Contains().(h)
60 if err != nil {
61 b.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("error checking if hash is in index: %s", err)
62 }
63
64 if !ok {
65 b.Errorscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Error().("expected hash to be in index")
66 }
67 }
68 }
69 }
70
71 func BenchmarkEntriesscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/BenchmarkEntries().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) {
72 idx, err := fixtureIndexscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureIndex().()
73 if err != nil {
74 b.Fatalscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatal().(err.Error())
75 }
76
77 for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() {
78 iter, err := idx.Entriesscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/MemoryIndex#Entries().()
79 if err != nil {
80 b.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("unexpected error getting entries: %s", err)
81 }
82
83 var entries int
84 for {
85 _, err := iter.Nextscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/EntryIter#Next.()
86 if err != nil {
87 if err == ioscip-go gomod github.com/golang/go/src go1.25.0 io/.EOFscip-go gomod github.com/golang/go/src go1.25.0 io/EOF. {
88 break
89 }
90
91 b.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("unexpected error getting entry: %s", err)
92 }
93
94 entries++
95 }
96
97 if entries != len(fixtureHashesscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureHashes.) {
98 b.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("expecting entries to be %d, got %d", len(fixtureHashesscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureHashes.), entries)
99 }
100 }
101 }
102
103 type IndexSuitescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/IndexSuite# struct {
104 suitescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/suite`/.Suitescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/IndexSuite#Suite.
105 }
106
107 func TestIndexSuitescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/TestIndexSuite().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
108 t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().()
109 suitescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/suite`/.Runscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/suite`/Run().(t, new(IndexSuitescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/IndexSuite#))
110 }
111
112 func (s *IndexSuitescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/IndexSuite#) TestFindHashscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/IndexSuite#TestFindHash().() {
113 idx, err := fixtureIndexscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureIndex().()
114 s.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#NoError().(err)
115
116 for i, pos := range fixtureOffsetsscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureOffsets. {
117 hash, err := idx.FindHashscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/MemoryIndex#FindHash().(pos)
118 s.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#NoError().(err)
119 s.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#Equal().(fixtureHashesscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureHashes.[i], hash)
120 }
121 }
122
123 func (s *IndexSuitescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/IndexSuite#) TestEntriesByOffsetscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/IndexSuite#TestEntriesByOffset().() {
124 idx, err := fixtureIndexscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureIndex().()
125 s.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#NoError().(err)
126
127 entries, err := idx.EntriesByOffsetscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/MemoryIndex#EntriesByOffset().()
128 s.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#NoError().(err)
129 defer entries.Closescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/EntryIter#Close.()
130
131 for _, pos := range fixtureOffsetsscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureOffsets. {
132 e, err := entries.Nextscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/EntryIter#Next.()
133 s.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#NoError().(err)
134
135 s.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#Equal().(uint64(pos), e.Offsetscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/Entry#Offset.)
136 }
137 }
138
139 var fixtureHashesscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureHashes. = []plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.Hashscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/Hash#{
140 plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.NewHashscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/NewHash().("303953e5aa461c203a324821bc1717f9b4fff895"),
141 plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.NewHashscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/NewHash().("5296768e3d9f661387ccbff18c4dea6c997fd78c"),
142 plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.NewHashscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/NewHash().("03fc8d58d44267274edef4585eaeeb445879d33f"),
143 plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.NewHashscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/NewHash().("8f3ceb4ea4cb9e4a0f751795eb41c9a4f07be772"),
144 plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.NewHashscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/NewHash().("e0d1d625010087f79c9e01ad9d8f95e1628dda02"),
145 plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.NewHashscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/NewHash().("90eba326cdc4d1d61c5ad25224ccbf08731dd041"),
146 plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.NewHashscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/NewHash().("bab53055add7bc35882758a922c54a874d6b1272"),
147 plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.NewHashscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/NewHash().("1b8995f51987d8a449ca5ea4356595102dc2fbd4"),
148 plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.NewHashscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/NewHash().("35858be9c6f5914cbe6768489c41eb6809a2bceb"),
149 }
150
151 var fixtureOffsetsscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureOffsets. = []int64{
152 12,
153 142,
154 1601322837,
155 2646996529,
156 3452385606,
157 3707047470,
158 5323223332,
159 5894072943,
160 5924278919,
161 }
162
163 func fixtureIndexscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureIndex().() (*idxfilescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/.MemoryIndexscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/MemoryIndex#, error) {
164 raw, err := ioscip-go gomod github.com/golang/go/src go1.25.0 io/.ReadAllscip-go gomod github.com/golang/go/src go1.25.0 io/ReadAll().(base64scip-go gomod github.com/golang/go/src go1.25.0 `encoding/base64`/.NewDecoderscip-go gomod github.com/golang/go/src go1.25.0 `encoding/base64`/NewDecoder().(base64scip-go gomod github.com/golang/go/src go1.25.0 `encoding/base64`/.StdEncodingscip-go gomod github.com/golang/go/src go1.25.0 `encoding/base64`/StdEncoding., bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.NewBufferStringscip-go gomod github.com/golang/go/src go1.25.0 bytes/NewBufferString().(fixtureLarge4GBscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureLarge4GB.)))
165 if err != nil {
166 return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("unexpected error decoding fixture: %s", err)
167 }
168
169 idx := new(idxfilescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/.MemoryIndexscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/MemoryIndex#)
170
171 d := idxfilescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/.NewDecoderscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/NewDecoder().(idxfilescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/.FromBytesscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/FromBytes().(raw), hashscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/hash`/.Newscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/hash`/New().(cryptoscip-go gomod github.com/golang/go/src go1.25.0 crypto/.SHA1scip-go gomod github.com/golang/go/src go1.25.0 crypto/SHA1.))
172 if err := d.Decodescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/Decoder#Decode().(idx); err != nil {
173 return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("unexpected error decoding index: %s", err)
174 }
175
176 return idx, nil
177 }
178
179 func TestOffsetHashConcurrentPopulationscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/TestOffsetHashConcurrentPopulation().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
180 t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().()
181 idx, err := fixtureIndexscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureIndex().()
182 if err != nil {
183 t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("failed to build fixture index: %v", err)
184 }
185
186 var wg syncscip-go gomod github.com/golang/go/src go1.25.0 sync/.WaitGroupscip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup#
187
188 for _, h := range fixtureHashesscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureHashes. {
189 wg.Goscip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup#Go().(func() {
190 for range 5000 {
191 _, _ = idx.FindOffsetscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/MemoryIndex#FindOffset().(h)
192 }
193 })
194 }
195
196 for _, off := range fixtureOffsetsscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile_test`/fixtureOffsets. {
197 wg.Goscip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup#Go().(func() {
198 for range 3000 {
199 _, _ = idx.FindHashscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/idxfile`/MemoryIndex#FindHash().(off)
200 }
201 })
202 }
203
204 wg.Waitscip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup#Wait().()
205 }