@@ -23,7 +23,7 @@ import (
2323 "testing"
2424)
2525
26- func TestDedupe (t * testing.T ) {
26+ func TestDedup (t * testing.T ) {
2727 ctx := context .Background ()
2828 testCases := []struct {
2929 desc string
@@ -59,18 +59,18 @@ func TestDedupe(t *testing.T) {
5959 return Index {Index : thisIdx }, nil
6060 }
6161 }
62- dedupeAdd := newInMemoryDedupe (256 )(delegate )
62+ dedupAdd := newInMemoryDedup (256 )(delegate )
6363
6464 // Add foo, bar, baz to prime the cache to make things interesting
6565 for _ , s := range []string {"foo" , "bar" , "baz" } {
66- if _ , err := dedupeAdd (ctx , NewEntry ([]byte (s )))(); err != nil {
67- t .Fatalf ("dedupeAdd (%q): %v" , s , err )
66+ if _ , err := dedupAdd (ctx , NewEntry ([]byte (s )))(); err != nil {
67+ t .Fatalf ("dedupAdd (%q): %v" , s , err )
6868 }
6969 }
7070
71- i , err := dedupeAdd (ctx , NewEntry ([]byte (tC .newValue )))()
71+ i , err := dedupAdd (ctx , NewEntry ([]byte (tC .newValue )))()
7272 if err != nil {
73- t .Fatalf ("dedupeAdd (%q): %v" , tC .newValue , err )
73+ t .Fatalf ("dedupAdd (%q): %v" , tC .newValue , err )
7474 }
7575 if i .Index != tC .wantIdx {
7676 t .Errorf ("got Index != want Index (%d != %d)" , i .Index , tC .wantIdx )
@@ -83,7 +83,7 @@ func TestDedupe(t *testing.T) {
8383 }
8484}
8585
86- func TestDedupeDoesNotCacheError (t * testing.T ) {
86+ func TestDedupDoesNotCacheError (t * testing.T ) {
8787 idx := uint64 (0 )
8888 rErr := true
8989
@@ -106,24 +106,24 @@ func TestDedupeDoesNotCacheError(t *testing.T) {
106106 return Index {Index : thisIdx }, err
107107 }
108108 }
109- dedupeAdd := newInMemoryDedupe (256 )(delegate )
109+ dedupAdd := newInMemoryDedup (256 )(delegate )
110110
111111 k := "foo"
112112 for i := range 10 {
113- idx , err := dedupeAdd (t .Context (), NewEntry ([]byte (k )))()
113+ idx , err := dedupAdd (t .Context (), NewEntry ([]byte (k )))()
114114
115115 // We expect an error from the delegate the first time.
116116 if i == 0 && err == nil {
117- t .Errorf ("dedupeAdd (%q)@%d: was successful, want error" , k , i )
117+ t .Errorf ("dedupAdd (%q)@%d: was successful, want error" , k , i )
118118 continue
119119 }
120120 // But the 2nd call should work.
121121 if i > 0 && err != nil {
122- t .Errorf ("dedupeAdd (%q)@%d: got %v, want no error" , k , i , err )
122+ t .Errorf ("dedupAdd (%q)@%d: got %v, want no error" , k , i , err )
123123 continue
124124 }
125125
126- // After which, all subsequent adds should dedupe to that successful add.
126+ // After which, all subsequent adds should dedup to that successful add.
127127 if i > 1 && ! idx .IsDup {
128128 t .Errorf ("got IsDup=false, want isDup=true" )
129129 continue
@@ -134,7 +134,7 @@ func TestDedupeDoesNotCacheError(t *testing.T) {
134134 }
135135}
136136
137- func BenchmarkDedupe (b * testing.B ) {
137+ func BenchmarkDedup (b * testing.B ) {
138138 ctx := context .Background ()
139139 // Outer loop is for benchmark calibration, inside here is each individual run of the benchmark
140140 for b .Loop () {
@@ -146,13 +146,13 @@ func BenchmarkDedupe(b *testing.B) {
146146 return Index {Index : thisIdx }, nil
147147 }
148148 }
149- dedupeAdd := newInMemoryDedupe (256 )(delegate )
149+ dedupAdd := newInMemoryDedup (256 )(delegate )
150150 wg := & sync.WaitGroup {}
151151 // Loop to create a bunch of leaves in parallel to test lock contention
152152 for leafIndex := range 1024 {
153153 wg .Add (1 )
154154 go func (index int ) {
155- _ , err := dedupeAdd (ctx , NewEntry (fmt .Appendf (nil , "leaf with value %d" , index % sha256 .Size )))()
155+ _ , err := dedupAdd (ctx , NewEntry (fmt .Appendf (nil , "leaf with value %d" , index % sha256 .Size )))()
156156 if err != nil {
157157 b .Error (err )
158158 }
0 commit comments