(t *testing.T)
| 182 | } |
| 183 | |
| 184 | func TestCacheDO(t *testing.T) { |
| 185 | testCache := newTestCache(t, nil) |
| 186 | |
| 187 | // Make a request. |
| 188 | request := (&dns.Msg{}).SetQuestion("google.com.", dns.TypeA) |
| 189 | |
| 190 | // Fill the cache. |
| 191 | reply := (&dns.Msg{ |
| 192 | MsgHdr: dns.MsgHdr{ |
| 193 | Response: true, |
| 194 | }, |
| 195 | Answer: []dns.RR{newRR(t, "google.com.", dns.TypeA, 3600, net.IP{8, 8, 8, 8})}, |
| 196 | }).SetQuestion("google.com.", dns.TypeA) |
| 197 | reply.SetEdns0(4096, false) |
| 198 | |
| 199 | // Store in cache. |
| 200 | testCache.set(request, reply, upstreamWithAddr, testLogger) |
| 201 | |
| 202 | t.Run("without_do", func(t *testing.T) { |
| 203 | ci, expired, _ := testCache.get(request) |
| 204 | assert.False(t, expired) |
| 205 | assert.NotNil(t, ci) |
| 206 | }) |
| 207 | |
| 208 | t.Run("with_do", func(t *testing.T) { |
| 209 | reqClone := request.Copy() |
| 210 | t.Cleanup(func() { |
| 211 | request = reqClone |
| 212 | }) |
| 213 | |
| 214 | request.SetEdns0(4096, true) |
| 215 | |
| 216 | ci, expired, _ := testCache.get(request) |
| 217 | require.Nil(t, ci) |
| 218 | assert.False(t, expired) |
| 219 | }) |
| 220 | } |
| 221 | |
| 222 | func TestCacheCNAME(t *testing.T) { |
| 223 | testCache := newTestCache(t, nil) |
nothing calls this directly
no test coverage detected
searching dependent graphs…