GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — metafora/ignore_test.go at master · lytics/metafora

Expand file tree

/

ignore_test.go

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
49 lines (41 loc) · 1.18 KB
/

ignore_test.go

Copy path

File metadata and controls

49 lines (41 loc) · 1.18 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package metafora
import (
"testing"
"time"
)
func TestIgnore(t *testing.T) {
t.Parallel()
out := make(chan Task)
stop := make(chan struct{})
defer close(stop)
// Create ignorer
im := ignorer(out, stop)
// Ignore task for 200ms. Yes this is racy. Might need to bump deadline.
deadline1 := time.Now().Add(200 * time.Millisecond)
im.add(testTask{"1"}, deadline1)
// Ensure it's ignored
if !im.ignored("1") {
t.Fatal("test task should have been ignored but wasn't")
}
// Ignore task for 10ms to make sure tasks are returned in order (they aren't
// *guaranteed* to be in order since adds and evictions are concurrent)
deadline2 := time.Now().Add(10 * time.Millisecond)
im.add(testTask{"2"}, deadline2)
// Wait for the first eviction
eviction := <-out
if eviction.ID() != "2" {
t.Fatal("Expected 2 to be evicted before 1")
}
now := time.Now()
if now.Before(deadline2) {
t.Fatalf("First eviction happened too soon: %s < %s", now, deadline2)
}
eviction = <-out
if eviction.ID() != "1" {
t.Fatal("Expected 1 to be evicted second, found ", eviction)
}
now = time.Now()
if now.Before(deadline1) {
t.Fatalf("First eviction happened too soon: %s < %s", now, deadline1)
}
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.