Started working on unit tests
Fixed some bugs in the CSVColumn processor
This commit is contained in:
parent
1c08248c69
commit
8c7e9453ee
3 changed files with 70 additions and 5 deletions
31
csv_test.go
Normal file
31
csv_test.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package scriptx_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/bitfield/script"
|
||||
"github.com/lmika/scriptx"
|
||||
)
|
||||
|
||||
func TestCSVColumn(t *testing.T) {
|
||||
t.Run("should return named column of CSV input", func(t *testing.T) {
|
||||
verifyPipeLines(t, func(p *script.Pipe) *script.Pipe {
|
||||
return p.Filter(scriptx.CSVColumn("state"))
|
||||
}, []string{
|
||||
"city,state,country",
|
||||
"Melbourne,Vic,AU",
|
||||
"Sydney,NSW,AU",
|
||||
"Canberra,\"Territory, Australian Capital\",AU",
|
||||
"New York,NY,US,Extra,Comments,Allowed",
|
||||
"Missing state is ignored",
|
||||
"# Comment is ignored",
|
||||
"Seattle,WA",
|
||||
}, []string{
|
||||
"Vic",
|
||||
"NSW",
|
||||
"Territory, Australian Capital",
|
||||
"NY",
|
||||
"WA",
|
||||
})
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue