From c215dcb84964fa284c6c4186037027398ac6c935 Mon Sep 17 00:00:00 2001 From: Alexandre Tuleu Date: Wed, 20 Jan 2016 13:47:43 +0100 Subject: [PATCH] Makes album getter test pass --- album_description_getter.go | 15 ++++++++++++--- album_description_getter_test.go | 24 ++++++++++++++++++++++++ testdata/albums.json | 2 -- 3 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 album_description_getter_test.go diff --git a/album_description_getter.go b/album_description_getter.go index bb7b435..d796f1f 100644 --- a/album_description_getter.go +++ b/album_description_getter.go @@ -119,7 +119,10 @@ func (g *AlbumDescriptionGetter) Get(a *Album) error { return } for _, s := range sList { - a.Scenarist = append(a.Scenarist, linkFromSelection(s.Find("a"))) + l := linkFromSelection(s.Find("a")) + if len(l.Title) > 0 { + a.Scenarist = append(a.Scenarist, l) + } } errors <- nil }() @@ -132,7 +135,10 @@ func (g *AlbumDescriptionGetter) Get(a *Album) error { return } for _, s := range sList { - a.Designer = append(a.Designer, linkFromSelection(s.Find("a"))) + l := linkFromSelection(s.Find("a")) + if len(l.Title) > 0 { + a.Designer = append(a.Designer, l) + } } errors <- nil }() @@ -145,7 +151,10 @@ func (g *AlbumDescriptionGetter) Get(a *Album) error { return } for _, s := range sList { - a.Colorist = append(a.Colorist, linkFromSelection(s.Find("a"))) + l := linkFromSelection(s.Find("a")) + if len(l.Title) > 0 { + a.Colorist = append(a.Colorist, l) + } } errors <- nil }() diff --git a/album_description_getter_test.go b/album_description_getter_test.go new file mode 100644 index 0000000..192ad99 --- /dev/null +++ b/album_description_getter_test.go @@ -0,0 +1,24 @@ +package main + +import . "gopkg.in/check.v1" + +type AlbumDescriptionGetterSuite struct { + g *AlbumDescriptionGetter +} + +var _ = Suite(&AlbumDescriptionGetterSuite{}) + +func (s *AlbumDescriptionGetterSuite) SetUpTest(c *C) { + s.g = &AlbumDescriptionGetter{getter: testGetter} +} + +func (s *AlbumDescriptionGetterSuite) TestGet(c *C) { + + for _, a := range albumsDataTest { + aStripped := StripNonCsvField(a) + if c.Check(s.g.Get(&aStripped), IsNil) == true { + aStripped.FetchDate = a.FetchDate + c.Check(aStripped, DeepEquals, a) + } + } +} diff --git a/testdata/albums.json b/testdata/albums.json index 208470a..386fc8a 100644 --- a/testdata/albums.json +++ b/testdata/albums.json @@ -67,7 +67,6 @@ "Target": "http://www.bedetheque.com/auteur-839-BD-Loro.html" } ], - "Colorist": [ ], "FetchDate": "0001-01-01T00:00:00Z" }, { @@ -488,7 +487,6 @@ "Target": "http://www.bedetheque.com/auteur-17-BD-Bruyninx-Marc.html" } ], - "Colorist": [ ], "FetchDate": "0001-01-01T00:00:00Z" }, {