github.com/omniscale/go-osm@v0.3.1/parser/changeset/parser_test.go (about) 1 package changeset 2 3 import ( 4 "context" 5 "os" 6 "testing" 7 8 osm "github.com/omniscale/go-osm" 9 ) 10 11 func TestParse(t *testing.T) { 12 conf := Config{ 13 Changesets: make(chan osm.Changeset), 14 } 15 f, err := os.Open("999.osm.gz") 16 if err != nil { 17 t.Fatal(err) 18 } 19 defer f.Close() 20 21 p, err := NewGZIP(f, conf) 22 if err != nil { 23 t.Fatal(err) 24 } 25 go p.Parse(context.Background()) 26 27 changes := []osm.Changeset{} 28 for ch := range conf.Changesets { 29 changes = append(changes, ch) 30 } 31 32 if err := p.Error(); err != nil { 33 t.Error(err) 34 } 35 36 if n := len(changes); n != 27 { 37 t.Error("expected 27 changes, got", n) 38 } 39 c := changes[0] 40 if c.ID != 43406602 || c.NumChanges != 314 { 41 t.Error("unexpected changeset", c) 42 } 43 if n := len(c.Comments); n != 3 { 44 t.Error("expected 3 comments in changeset", c) 45 } 46 47 }