forked from SlyMarbo/rss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
database_test.go
46 lines (36 loc) · 1.05 KB
/
database_test.go
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
package rss
import (
"testing"
)
var fixture = "Item.ID"
func TestDatabaseEnabled(t *testing.T) {
if database.req <- fixture; <-database.res {
t.Error("Should have not found the fixture string.")
}
if database.req <- fixture; !<-database.res {
t.Error("Should have found the fixture string.")
}
}
func TestDatabaseDisabled(t *testing.T) {
CacheParsedItemIDs(false)
if database.req <- fixture; <-database.res {
t.Error("Should have not found the fixture string even though it was recorded.")
}
n := len(database.known)
if database.req <- "foo"; <-database.res || len(database.known) != n {
t.Error("Should not record a new entry.")
}
}
func TestDatabaseReenabled(t *testing.T) {
CacheParsedItemIDs(true)
if database.req <- fixture; !<-database.res {
t.Error("Should have found the fixture string again.")
}
n := len(database.known)
if database.req <- "foo"; <-database.res || len(database.known) != n+1 {
t.Error("Should record a new entry.")
}
if database.req <- "foo"; !<-database.res {
t.Error("Should find the new entry.")
}
}