featurebase/client/csv/csv_it_test.go
reesporte 4c53f86e82 removed license from each go file
i used this script, a little clunky but it got the job done

```bash
for file in `find . -type f -print | grep '\.go'`; do
    sed '1,/^\/\/ limitations under the License.$/d' $file > $file.tmp;
    result=`cat $file.tmp`
    if [[ result != "" ]]; then
        gofmt $file.tmp &> /dev/null;
        if [[ $? == 0 ]]; then
            mv $file.tmp $file && gofmt -w $file;
        else
            rm $file.tmp;
        fi
    else
        rm $file.tmp;
    fi
done
```
2021-12-10 09:17:17 -06:00

47 lines
921 B
Go

//go:build integration
// +build integration
package csv_test
import (
"io"
"reflect"
"strings"
"testing"
"github.com/molecula/featurebase/v2/client"
"github.com/molecula/featurebase/v2/client/csv"
)
func TestCSVIterate(t *testing.T) {
text := `10,7
10,5
2,3
7,1`
iterator := csv.NewColumnIterator(csv.RowIDColumnID, strings.NewReader(text))
recs := consumeIterator(t, iterator)
target := []client.Record{
client.Column{RowID: 10, ColumnID: 7},
client.Column{RowID: 10, ColumnID: 5},
client.Column{RowID: 2, ColumnID: 3},
client.Column{RowID: 7, ColumnID: 1},
}
if !reflect.DeepEqual(target, recs) {
t.Fatalf("%v != %v", target, recs)
}
}
func consumeIterator(t *testing.T, it *csv.Iterator) []client.Record {
recs := []client.Record{}
for {
r, err := it.NextRecord()
if err == io.EOF {
break
}
if err != nil {
t.Fatal(err)
}
recs = append(recs, r)
}
return recs
}