From 834b035dd6082697f111809e9a30234e333f31bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 18 Feb 2016 16:11:23 +0000 Subject: [PATCH] Index test case with an apk --- index_test.go | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/index_test.go b/index_test.go index 73853d7..d078497 100644 --- a/index_test.go +++ b/index_test.go @@ -63,30 +63,30 @@ func TestLoadIndexXML(t *testing.T) { { ` - `, - Index{ - Repo: Repo{ - Name: "Foo", - Version: 14, - }, - }, - }, - { - ` - foo.bar Foo bar + + 1.0 + 1 + `, Index{ Repo: Repo{ Name: "Foo", + Version: 14, }, Apps: []App{ { ID: "foo.bar", Name: "Foo bar", + Apks: []Apk{ + { + VName: "1.0", + VCode: 1, + }, + }, }, }, }, @@ -94,11 +94,20 @@ func TestLoadIndexXML(t *testing.T) { } for _, c := range tests { r := strings.NewReader(c.in) - got, err := LoadIndexXML(r) + index, err := LoadIndexXML(r) if err != nil { t.Fatalf("Unexpected error: %v", err) } - if !reflect.DeepEqual(*got, c.want) { + got := *index + for i := range c.want.Apps { + app := &c.want.Apps[i] + for i := range app.Apks { + apk := &app.Apks[i] + apk.Repo = &got.Repo + apk.App = app + } + } + if !reflect.DeepEqual(got, c.want) { t.Fatalf("Unexpected index.\nGot:\n%v\nWant:\n%v\n", got, c.want) }