mirror of
https://github.com/nkanaev/yarr.git
synced 2025-11-05 09:10:38 +00:00
start storage tests
This commit is contained in:
41
src/storage/feed_test.go
Normal file
41
src/storage/feed_test.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCreateFeed(t *testing.T) {
|
||||
db := testDB()
|
||||
feed1 := db.CreateFeed("title", "", "http://example.com", "http://example.com/feed.xml", nil)
|
||||
if feed1 == nil || feed1.Id == 0 {
|
||||
t.Fatal("expected feed")
|
||||
}
|
||||
feed2 := db.GetFeed(feed1.Id)
|
||||
if feed2 == nil || !reflect.DeepEqual(feed1, feed2) {
|
||||
t.Fatal("invalid feed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadFeed(t *testing.T) {
|
||||
db := testDB()
|
||||
if db.GetFeed(100500) != nil {
|
||||
t.Fatal("cannot get nonexistent feed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeleteFeed(t *testing.T) {
|
||||
db := testDB()
|
||||
feed1 := db.CreateFeed("title", "", "http://example.com", "http://example.com/feed.xml", nil)
|
||||
|
||||
if db.DeleteFeed(100500) {
|
||||
t.Error("cannot delete what does not exist")
|
||||
}
|
||||
|
||||
if !db.DeleteFeed(feed1.Id) {
|
||||
t.Fatal("did not delete existing feed")
|
||||
}
|
||||
if db.GetFeed(feed1.Id) != nil {
|
||||
t.Fatal("feed still exists")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user