Switch to using internal debian control file parser.

This commit is contained in:
Andrey Smirnov
2013-12-23 17:13:09 +04:00
parent bf11f7b4bb
commit c38592dc02
6 changed files with 59 additions and 81 deletions
+6 -17
View File
@@ -2,23 +2,19 @@ package debian
import (
"github.com/smira/aptly/database"
debc "github.com/smira/godebiancontrol"
. "launchpad.net/gocheck"
)
var packagePara = debc.Paragraph{"Source": "alien-arena", "Depends": "libc6 (>= 2.7), alien-arena-data (>= 7.40)", "Filename": "pool/contrib/a/alien-arena/alien-arena-common_7.40-2_i386.deb", "SHA1": "46955e48cad27410a83740a21d766ce362364024", "SHA256": "eb4afb9885cba6dc70cccd05b910b2dbccc02c5900578be5e99f0d3dbf9d76a5", "Priority": "extra", "Maintainer": "Debian Games Team <pkg-games-devel@lists.alioth.debian.org>", "Description": "Common files for Alien Arena client and server ALIEN ARENA is a standalone 3D first person online deathmatch shooter\n crafted from the original source code of Quake II and Quake III, released\n by id Software under the GPL license. With features including 32 bit\n graphics, new particle engine and effects, light blooms, reflective water,\n hi resolution textures and skins, hi poly models, stain maps, ALIEN ARENA\n pushes the envelope of graphical beauty rivaling today's top games.\n .\n This package installs the common files for Alien Arena.\n", "Homepage": "http://red.planetarena.org", "Tag": "role::app-data, role::shared-lib, special::auto-inst-parts", "Installed-Size": "456", "Version": "7.40-2", "Replaces": "alien-arena (<< 7.33-1)", "Size": "187518", "MD5sum": "1e8cba92c41420aa7baa8a5718d67122", "Package": "alien-arena-common", "Section": "contrib/games", "Architecture": "i386"}
var packageStanza = Stanza{"Source": "alien-arena", "Depends": "libc6 (>= 2.7), alien-arena-data (>= 7.40)", "Filename": "pool/contrib/a/alien-arena/alien-arena-common_7.40-2_i386.deb", "SHA1": "46955e48cad27410a83740a21d766ce362364024", "SHA256": "eb4afb9885cba6dc70cccd05b910b2dbccc02c5900578be5e99f0d3dbf9d76a5", "Priority": "extra", "Maintainer": "Debian Games Team <pkg-games-devel@lists.alioth.debian.org>", "Description": "Common files for Alien Arena client and server ALIEN ARENA is a standalone 3D first person online deathmatch shooter\n crafted from the original source code of Quake II and Quake III, released\n by id Software under the GPL license. With features including 32 bit\n graphics, new particle engine and effects, light blooms, reflective water,\n hi resolution textures and skins, hi poly models, stain maps, ALIEN ARENA\n pushes the envelope of graphical beauty rivaling today's top games.\n .\n This package installs the common files for Alien Arena.\n", "Homepage": "http://red.planetarena.org", "Tag": "role::app-data, role::shared-lib, special::auto-inst-parts", "Installed-Size": "456", "Version": "7.40-2", "Replaces": "alien-arena (<< 7.33-1)", "Size": "187518", "MD5sum": "1e8cba92c41420aa7baa8a5718d67122", "Package": "alien-arena-common", "Section": "contrib/games", "Architecture": "i386"}
type PackageSuite struct {
para debc.Paragraph
para Stanza
}
var _ = Suite(&PackageSuite{})
func (s *PackageSuite) SetUpTest(c *C) {
s.para = make(debc.Paragraph)
for k, v := range packagePara {
s.para[k] = v
}
s.para = packageStanza.Copy()
}
func (s *PackageSuite) TestNewFromPara(c *C) {
@@ -57,11 +53,8 @@ func (s *PackageSuite) TestString(c *C) {
func (s *PackageSuite) TestEquals(c *C) {
p := NewPackageFromControlFile(s.para)
para2 := make(debc.Paragraph)
for k, v := range packagePara {
para2[k] = v
}
p2 := NewPackageFromControlFile(para2)
stanza2 := packageStanza.Copy()
p2 := NewPackageFromControlFile(stanza2)
c.Check(p.Equals(p2), Equals, true)
p2.Depends = []string{"package1"}
@@ -77,11 +70,7 @@ type PackageCollectionSuite struct {
var _ = Suite(&PackageCollectionSuite{})
func (s *PackageCollectionSuite) SetUpTest(c *C) {
para := make(debc.Paragraph)
for k, v := range packagePara {
para[k] = v
}
s.p = NewPackageFromControlFile(para)
s.p = NewPackageFromControlFile(packageStanza.Copy())
s.db, _ = database.OpenDB(c.MkDir())
s.collection = NewPackageCollection(s.db)
}