testing/fixture/results.go

31 lines
521 B
Go
Raw Permalink Normal View History

2024-05-08 20:28:36 +00:00
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
package fixture
import (
)
type Result interface{}
type ResultReader interface {
Values() []Result
Read() <-chan Result
}
type Results struct {
values []Result
}
func R(v []Result) *Results { return &Results{ values: v } }
func (r *Results) Values() []Result {
return r.values
}
func (r *Results) Read() <-chan Result {
rc := make(chan Result, len(r.values))
for i := range(r.Values()) {
rc <- i
}
return rc
}