forked from SlyMarbo/rss
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support disabling the Item.ID lookup cache.
The default remains caching enabled.
- Loading branch information
1 parent
c617a19
commit e5aac1b
Showing
3 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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.") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters