Implements csv parsing

This commit is contained in:
2016-01-17 12:58:59 +01:00
parent ab201424ad
commit b743fffb23
2 changed files with 128 additions and 19 deletions

View File

@@ -38,7 +38,7 @@ func (s *AlbumCsvReaderSuite) TestCanReadCsv(c *C) {
Editor: "Sarbacane",
Collection: "",
State: 1,
LegalDeposit: time.Date(2009, 10, 0, 0, 0, 0, 0, time.UTC),
LegalDeposit: time.Date(2009, 10, 1, 0, 0, 0, 0, time.UTC),
PurchaseDate: time.Date(2013, 9, 3, 0, 0, 0, 0, time.UTC),
SatID: "RACO-1",
},
@@ -50,7 +50,7 @@ func (s *AlbumCsvReaderSuite) TestCanReadCsv(c *C) {
Title: "Le roi Oscar et autres racontars",
Editor: "Sarbacane",
Collection: "",
LegalDeposit: time.Date(2011, 01, 0, 0, 0, 0, 0, time.UTC),
LegalDeposit: time.Date(2011, 01, 1, 0, 0, 0, 0, time.UTC),
State: 2,
PurchaseDate: time.Date(2013, 9, 3, 0, 0, 0, 0, time.UTC),
SatID: "RACO-2",
@@ -64,7 +64,7 @@ func (s *AlbumCsvReaderSuite) TestCanReadCsv(c *C) {
Title: "''Atar Gull'' ou le destin d'un esclave modèle",
Editor: "Dargaud",
Collection: "Long Courrier",
LegalDeposit: time.Date(2011, 10, 0, 0, 0, 0, 0, time.UTC),
LegalDeposit: time.Date(2011, 10, 1, 0, 0, 0, 0, time.UTC),
State: 3,
PurchaseDate: time.Date(2013, 9, 4, 0, 0, 0, 0, time.UTC),
SatID: "LONG-11",
@@ -78,7 +78,7 @@ func (s *AlbumCsvReaderSuite) TestCanReadCsv(c *C) {
Title: "Tanino Liberatore",
Editor: "Kesselring",
Collection: "",
LegalDeposit: time.Date(1985, 12, 0, 0, 0, 0, 0, time.UTC),
LegalDeposit: time.Date(1985, 12, 1, 0, 0, 0, 0, time.UTC),
State: 4,
PurchaseDate: time.Date(2013, 12, 7, 0, 0, 0, 0, time.UTC),
SatID: "LIB-00",
@@ -105,7 +105,7 @@ func (s *AlbumCsvReaderSuite) TestCanReadCsv(c *C) {
Title: "Humour noir et hommes en blanc",
Editor: "Éditions du Grésivaudan",
Collection: "",
LegalDeposit: time.Date(1972, 11, 0, 0, 0, 0, 0, time.UTC),
LegalDeposit: time.Date(1972, 11, 1, 0, 0, 0, 0, time.UTC),
State: 0,
PurchaseDate: time.Date(2013, 9, 3, 0, 0, 0, 0, time.UTC),
SatID: "SERR-1",
@@ -119,8 +119,8 @@ func (s *AlbumCsvReaderSuite) TestCanReadCsv(c *C) {
Title: "Le Sport",
Editor: "Glénat",
Collection: "",
LegalDeposit: time.Date(1977, 10, 0, 0, 0, 0, 0, time.UTC),
PrintDate: time.Date(1977, 11, 0, 0, 0, 0, 0, time.UTC),
LegalDeposit: time.Date(1977, 10, 1, 0, 0, 0, 0, time.UTC),
PrintDate: time.Date(1977, 11, 1, 0, 0, 0, 0, time.UTC),
State: 0,
PurchaseDate: time.Date(2013, 9, 3, 0, 0, 0, 0, time.UTC),
SatID: "SERR-2",
@@ -134,8 +134,8 @@ func (s *AlbumCsvReaderSuite) TestCanReadCsv(c *C) {
Title: "L'automobile",
Editor: "Glénat",
Collection: "",
LegalDeposit: time.Date(1978, 12, 0, 0, 0, 0, 0, time.UTC),
PrintDate: time.Date(1978, 12, 0, 0, 0, 0, 0, time.UTC),
LegalDeposit: time.Date(1978, 12, 1, 0, 0, 0, 0, time.UTC),
PrintDate: time.Date(1978, 12, 1, 0, 0, 0, 0, time.UTC),
State: 0,
PurchaseDate: time.Date(2013, 9, 3, 0, 0, 0, 0, time.UTC),
SatID: "SERR-3",
@@ -149,7 +149,7 @@ func (s *AlbumCsvReaderSuite) TestCanReadCsv(c *C) {
Title: "...vice compris",
Editor: "Glénat",
Collection: "",
LegalDeposit: time.Date(1979, 10, 0, 0, 0, 0, 0, time.UTC),
LegalDeposit: time.Date(1979, 10, 1, 0, 0, 0, 0, time.UTC),
State: 0,
PurchaseDate: time.Date(2013, 9, 3, 0, 0, 0, 0, time.UTC),
SatID: "SERR-7",
@@ -163,7 +163,7 @@ func (s *AlbumCsvReaderSuite) TestCanReadCsv(c *C) {
Title: "Savoir vivre",
Editor: "Glénat",
Collection: "",
LegalDeposit: time.Date(1981, 10, 0, 0, 0, 0, 0, time.UTC),
LegalDeposit: time.Date(1981, 10, 1, 0, 0, 0, 0, time.UTC),
State: 0,
PurchaseDate: time.Date(2013, 9, 3, 0, 0, 0, 0, time.UTC),
SatID: "SERR-5",
@@ -177,7 +177,7 @@ func (s *AlbumCsvReaderSuite) TestCanReadCsv(c *C) {
Title: "La Bouffe",
Editor: "Glénat",
Collection: "",
LegalDeposit: time.Date(1982, 10, 0, 0, 0, 0, 0, time.UTC),
LegalDeposit: time.Date(1982, 10, 1, 0, 0, 0, 0, time.UTC),
State: 0,
PurchaseDate: time.Date(2013, 9, 3, 0, 0, 0, 0, time.UTC),
SatID: "SERR-4",
@@ -191,18 +191,19 @@ func (s *AlbumCsvReaderSuite) TestCanReadCsv(c *C) {
Title: "Le bricolage",
Editor: "Glénat",
Collection: "",
LegalDeposit: time.Date(1983, 12, 0, 0, 0, 0, 0, time.UTC),
LegalDeposit: time.Date(1983, 12, 1, 0, 0, 0, 0, time.UTC),
State: 0,
PurchaseDate: time.Date(2013, 9, 3, 0, 0, 0, 0, time.UTC),
SatID: "SERR-6",
},
}
r := NewAlbumCsvReader(strings.NewReader(csvData))
r, err := NewAlbumCsvReader(strings.NewReader(csvData))
c.Assert(err, IsNil)
for _, e := range expected {
res, err := r.Read()
if c.Check(err, IsNil) == true {
c.Check(res, Equals, e)
c.Check(*res, Equals, e, Commentf("expected: %+v actual: %+v", e, res))
}
}