(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func TestPrefetch(t *testing.T) { |
| 19 | tests := []struct { |
| 20 | qname string |
| 21 | ttl int |
| 22 | prefetch int |
| 23 | verifications []verification |
| 24 | }{ |
| 25 | { |
| 26 | qname: "hits.reset.example.org.", |
| 27 | ttl: 80, |
| 28 | prefetch: 1, |
| 29 | verifications: []verification{ |
| 30 | { |
| 31 | after: 0 * time.Second, |
| 32 | answer: "hits.reset.example.org. 80 IN A 127.0.0.1", |
| 33 | fetch: true, // Initial fetch |
| 34 | }, |
| 35 | { |
| 36 | after: 73 * time.Second, |
| 37 | answer: "hits.reset.example.org. 7 IN A 127.0.0.1", |
| 38 | fetch: true, // Triggers prefetch with 7 TTL (10% of 80 = 8 TTL threshold) |
| 39 | }, |
| 40 | { |
| 41 | after: 80 * time.Second, |
| 42 | answer: "hits.reset.example.org. 73 IN A 127.0.0.2", |
| 43 | }, |
| 44 | }, |
| 45 | }, |
| 46 | { |
| 47 | qname: "short.ttl.example.org.", |
| 48 | ttl: 5, |
| 49 | prefetch: 1, |
| 50 | verifications: []verification{ |
| 51 | { |
| 52 | after: 0 * time.Second, |
| 53 | answer: "short.ttl.example.org. 5 IN A 127.0.0.1", |
| 54 | fetch: true, |
| 55 | }, |
| 56 | { |
| 57 | after: 1 * time.Second, |
| 58 | answer: "short.ttl.example.org. 4 IN A 127.0.0.1", |
| 59 | }, |
| 60 | { |
| 61 | after: 4 * time.Second, |
| 62 | answer: "short.ttl.example.org. 1 IN A 127.0.0.1", |
| 63 | fetch: true, |
| 64 | }, |
| 65 | { |
| 66 | after: 5 * time.Second, |
| 67 | answer: "short.ttl.example.org. 4 IN A 127.0.0.2", |
| 68 | }, |
| 69 | }, |
| 70 | }, |
| 71 | { |
| 72 | qname: "no.prefetch.example.org.", |
| 73 | ttl: 30, |
| 74 | prefetch: 0, |
| 75 | verifications: []verification{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…