func TestIntegrationList_Pagination(t *testing.T) { storage, err := goejdb.Open("TestIntegrationList", goejdb.JBOWRITER|goejdb.JBOCREAT) if err != nil { t.Error(err) } defer storage.Del() defer os.Remove("TestIntegrationList") chatColl, err := storage.CreateColl("12345", nil) if err != nil { t.Error(err) } defer os.Remove("TestIntegrationList_12345") for i := 25; i > 0; i-- { bsonBytes, _ := bson.Marshal(quotes.Quote{When: i}) chatColl.SaveBson(bsonBytes) } manager := manageStorage{storage} res, err2 := manager.List("12345", 10) if err2 != nil { t.Error(err2) } assert.Equal(t, 10, len(*res)) }
// NewStorage creates a new storage func NewStorage(conf *ConfService) (*goejdb.Ejdb, error) { var storageConf StorageConfiguration conf.Get(&storageConf) // Create a new database file and open it db, err := goejdb.Open(storageConf.DBName, goejdb.JBOWRITER|goejdb.JBOCREAT) if err != nil { return nil, err } return db, nil }