diff options
Diffstat (limited to 'src/hub/src/spreadspace.org/sfive/s5store_test.go')
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5store_test.go | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5store_test.go b/src/hub/src/spreadspace.org/sfive/s5store_test.go index 356b42f..c3609da 100644 --- a/src/hub/src/spreadspace.org/sfive/s5store_test.go +++ b/src/hub/src/spreadspace.org/sfive/s5store_test.go @@ -5,6 +5,18 @@ import ( "time" ) +func TestGetFilter(t *testing.T) { + queryStartTime := time.Date(2015, time.December, 24, 1, 1, 1, 0, time.UTC) + filterStruct := StatsFilter{start: &queryStartTime} + fe, np := getFilteredDataUpdateSelect(&filterStruct) + if fe != "(select * from DataUpdates where Start >= :filterstart)" { + t.Errorf("get filter sql failed: fe: %v", fe) + } + if !queryStartTime.Equal(*np["filterstart"].(*time.Time)) { + t.Errorf("get filter sql failed: np: %v != %v", np["filterstart"], queryStartTime) + } +} + func TestAppend(t *testing.T) { store, err := NewStore() if err != nil { @@ -22,6 +34,23 @@ func TestAppend(t *testing.T) { if err != nil { t.Errorf("Failed to append: %v", err) } + + clientCnt := store.CountClients(nil) + if 3 != clientCnt { + t.Errorf("Failed fo append, invalid number of clients, 3 != %v", clientCnt) + } + + updateCnt, err := store.CountUpdateEntries(nil) + if 1 != updateCnt { + t.Errorf("Failed to append, invalid number of updates, 1 != %v", updateCnt) + } + + queryStartTime := time.Date(2015, time.December, 24, 1, 1, 1, 0, time.UTC) + filterStruct := StatsFilter{start: &queryStartTime} + updateCnt, err = store.CountUpdateEntries(&filterStruct) + if 0 != updateCnt { + t.Errorf("Failed to filter entries by start time, 0 != %v", updateCnt) + } } func IgnoreTestCount(t *testing.T) { @@ -31,7 +60,7 @@ func IgnoreTestCount(t *testing.T) { } defer EatDataAndClose(store) - if 0 != store.ClientCount(nil) { + if 0 != store.CountClients(nil) { t.Errorf("Failed to count correctly.") } } |