Skip to content

Commit

Permalink
control/index.go: adding BinaryIndex.GetConflicts()
Browse files Browse the repository at this point in the history
  • Loading branch information
pnx authored and paultag committed Sep 9, 2022
1 parent 0e9896b commit 7b4a71e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions control/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ type BinaryIndex struct {
DebugBuildIds []string `control:"Build-Ids" delim:" "`
}

// Parse the Conflicts Dependency relation on this package.
func (index *BinaryIndex) GetConflicts() dependency.Dependency {
return index.getOptionalDependencyField("Conflicts")
}

// Parse the Depends Dependency relation on this package.
func (index *BinaryIndex) GetDepends() dependency.Dependency {
return index.getOptionalDependencyField("Depends")
Expand Down
38 changes: 38 additions & 0 deletions control/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,42 @@ SHA256: fa53e4f50349c5c9b564b8dc1da86c503b0baf56ab95a4ef6e204b6f77bfe70c
assert(t, ddmsDepends.GetAllPossibilities()[0].Version.Number == "22.2+git20130830~92d25d6-1")
}

func TestBinaryIndexConflictsParse(t *testing.T) {
// Test Binary Index {{{
reader := bufio.NewReader(strings.NewReader(`Package: zvmcloudconnector-common
Architecture: all
Version: 2.0.0~b1~git2019062011.4fc9142.really.1.4.1-0ubuntu3
Priority: optional
Section: python
Source: zvmcloudconnector
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Corey Bryant <corey.bryant@canonical.com>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 56
Depends: adduser
Conflicts: somepackage (>= 5.0)
Filename: pool/main/z/zvmcloudconnector/zvmcloudconnector-common_2.0.0~b1~git2019062011.4fc9142.really.1.4.1-0ubuntu3_all.deb
Size: 11948
MD5sum: b6356b883d475e5552eb61f3d3dac051
SHA1: f411b822cdf581e7f83f9bbf59371f91a00ff9bb
SHA256: f55ba72804b82daa77fd10afe07ac75fd5ce24740bafd26bc587be34850b96c5
Homepage: https://github.com/mfcloud/python-zvm-sdk
Description: z/VM Development SDK for managing z/VM - Common Files
Description-md5: d05e72aec9e53ee776fc0735e135889b
`))
// }}}
sources, err := control.ParseBinaryIndex(reader)
isok(t, err)
assert(t, len(sources) == 1)

pkgconflicts := sources[0].GetConflicts()
conflicts := pkgconflicts.GetAllPossibilities()
assert(t, len(conflicts) == 1)

assert(t, conflicts[0].Name == "somepackage")
assert(t, conflicts[0].Version.Number == "5.0")
assert(t, conflicts[0].Version.Operator == ">=")
}

// vim: foldmethod=marker

0 comments on commit 7b4a71e

Please # to comment.