| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package main | 5 package main |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "errors" | 8 "errors" |
| 9 "fmt" | 9 "fmt" |
| 10 "sync" | 10 "sync" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 94 } |
| 95 | 95 |
| 96 // Check that the items/push states pairs match what the service gave. | 96 // Check that the items/push states pairs match what the service gave. |
| 97 for got := range gotc { | 97 for got := range gotc { |
| 98 gotPS, wantPS := got.ps, fake.pushStates[string(got.item.Digest)
] | 98 gotPS, wantPS := got.ps, fake.pushStates[string(got.item.Digest)
] |
| 99 if gotPS != wantPS { | 99 if gotPS != wantPS { |
| 100 t.Errorf("push state for item %v wrong", got.item) | 100 t.Errorf("push state for item %v wrong", got.item) |
| 101 break | 101 break |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 |
| 105 if got, want := checker.Hit.Count, 0; got != want { |
| 106 t.Errorf("checker hit count: got %v ; want: %v", got, want) |
| 107 } |
| 108 if got, want := checker.Miss.Count, 150; got != want { |
| 109 t.Errorf("checker hit count: got %v ; want: %v", got, want) |
| 110 } |
| 104 } | 111 } |
| 105 | 112 |
| 106 func TestCheckerDelay(t *testing.T) { | 113 func TestCheckerDelay(t *testing.T) { |
| 107 batchc := make(chan []*service.HandlersEndpointsV1Digest, 2) | 114 batchc := make(chan []*service.HandlersEndpointsV1Digest, 2) |
| 108 fake := &fakeIsolateService{batchc: batchc} | 115 fake := &fakeIsolateService{batchc: batchc} |
| 109 checker := newChecker(fake) | 116 checker := newChecker(fake) |
| 110 | 117 |
| 111 nop := func(item *Item, ps *isolatedclient.PushState) {} | 118 nop := func(item *Item, ps *isolatedclient.PushState) {} |
| 112 checker.AddItem(&Item{Digest: "aaa"}, false, nop) | 119 checker.AddItem(&Item{Digest: "aaa"}, false, nop) |
| 113 checker.AddItem(&Item{Digest: "bbb"}, false, nop) | 120 checker.AddItem(&Item{Digest: "bbb"}, false, nop) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 Path: fmt.Sprintf("/item/%d", i), | 153 Path: fmt.Sprintf("/item/%d", i), |
| 147 Digest: isolated.HexDigest(fmt.Sprintf("digest%d", i)), | 154 Digest: isolated.HexDigest(fmt.Sprintf("digest%d", i)), |
| 148 } | 155 } |
| 149 checker.AddItem(item, false, nop) | 156 checker.AddItem(item, false, nop) |
| 150 } | 157 } |
| 151 | 158 |
| 152 if err := checker.Close(); err != errBang { | 159 if err := checker.Close(); err != errBang { |
| 153 t.Fatalf("checker.Close: got error %v; want %v", err, errBang) | 160 t.Fatalf("checker.Close: got error %v; want %v", err, errBang) |
| 154 } | 161 } |
| 155 } | 162 } |
| OLD | NEW |