summaryrefslogtreecommitdiff
path: root/src/hub/src/spreadspace.org/sfive/s5store_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/hub/src/spreadspace.org/sfive/s5store_test.go')
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5store_test.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5store_test.go b/src/hub/src/spreadspace.org/sfive/s5store_test.go
index fd49d81..bd6c85f 100644
--- a/src/hub/src/spreadspace.org/sfive/s5store_test.go
+++ b/src/hub/src/spreadspace.org/sfive/s5store_test.go
@@ -431,6 +431,55 @@ func TestAppendAndFetch(t *testing.T) {
}
}
+func TestTimestampIndex(t *testing.T) {
+ os.Remove(testBoltPath)
+ store, err := NewStore(StoreConfig{testBoltPath, false})
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+ defer store.Close()
+
+ upd := updateData
+ upd.StartTime = time.Date(2014, time.August, 24, 14, 35, 33, 847000000, time.UTC)
+ upd.Data.Clients = clientsData
+ in := &UpdateFull{Header{0, "", -1, "", -1}, sourceData, upd}
+
+ if err = store.Append(in); err != nil {
+ t.Fatalf("failed to append update: %v", err)
+ }
+ if err = store.Append(in); err != nil {
+ t.Fatalf("failed to append update: %v", err)
+ }
+ in.Update.StartTime = in.Update.StartTime.Add(1 * time.Hour)
+ if err = store.Append(in); err != nil {
+ t.Fatalf("failed to append update: %v", err)
+ }
+ in.Update.StartTime = in.Update.StartTime.Add(24 * time.Hour)
+ if err = store.Append(in); err != nil {
+ t.Fatalf("failed to append update: %v", err)
+ }
+
+ err = store.db.View(func(tx *bolt.Tx) error {
+ tsb := tx.Bucket([]byte(timestampsIdxBn))
+
+ db24 := tsb.Bucket([]byte("2014-08-24"))
+ if db24 == nil {
+ t.Fatalf("the append should have created an bucket for 24.8.2014")
+ }
+ db25 := tsb.Bucket([]byte("2014-08-25"))
+ if db25 == nil {
+ t.Fatalf("the append should have created an bucket for 25.8.2014")
+ }
+
+ // TODO: check if db24 and db25 contain the correct entries
+
+ return nil
+ })
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+}
+
func TestReadOnly(t *testing.T) {
// create read-only db from not-existing file must fail
os.Remove(testBoltPath)