mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-15 07:18:04 +00:00
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
```
47 lines
921 B
Go
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
|
|
}
|