Esempio n. 1
0
func doConsume(
	t *testing.T,
	c functional.Consumer,
	s functional.Stream,
	expectedError error) {
	if err := c.Consume(s); err != expectedError {
		t.Errorf("Expected %v, got %v", expectedError, err)
	}
}
Esempio n. 2
0
func (f FakeStore) EntriesByOwner(
	t db.Transaction, owner int64, consumer functional.Consumer) error {
	s := functional.NewStreamFromPtrs(f, nil)
	s = functional.Filter(functional.NewFilterer(func(ptr interface{}) error {
		p := ptr.(*vsafe.Entry)
		if p.Owner == owner {
			return nil
		}
		return functional.Skipped
	}),
		s)
	return consumer.Consume(s)
}
Esempio n. 3
0
// ReadMultiple executes sql and reads multiple rows.
// consumer may consume either business objects or db.Etagger objects.
// For the latter case, row must also implement RowForWriting
func ReadMultiple(
	conn *sqlite.Conn,
	row RowForReading,
	consumer functional.Consumer,
	sql string,
	params ...interface{}) error {
	stmt, err := conn.Prepare(sql)
	if err != nil {
		return err
	}
	defer stmt.Finalize()
	if err = stmt.Exec(params...); err != nil {
		return err
	}
	return consumer.Consume(ReadRows(row, stmt))
}