Introduce regexp query matching.

This commit is contained in:
Andrey Smirnov
2014-07-15 19:00:06 +04:00
parent a632469890
commit 56d777af0a
8 changed files with 66 additions and 15 deletions
+11 -4
View File
@@ -7,6 +7,7 @@ import (
. "launchpad.net/gocheck"
"os"
"path/filepath"
"regexp"
)
type PackageSuite struct {
@@ -266,10 +267,16 @@ func (s *PackageSuite) TestMatchesDependency(c *C) {
c.Check(p.MatchesDependency(Dependency{Pkg: "alien-arena-common", Architecture: "i386", Relation: VersionPatternMatch, Version: "7.40-[2"}), Equals, false)
c.Check(p.MatchesDependency(Dependency{Pkg: "alien-arena-common", Architecture: "i386", Relation: VersionPatternMatch, Version: "7.40-[34]"}), Equals, false)
// %
c.Check(func() {
p.MatchesDependency(Dependency{Pkg: "alien-arena-common", Architecture: "i386", Relation: VersionRegexp, Version: "7\\.40-.*"})
}, Panics, "regexp matching not implemented yet")
// ~
c.Check(
p.MatchesDependency(Dependency{Pkg: "alien-arena-common", Architecture: "i386", Relation: VersionRegexp, Version: "7\\.40-.*",
Regexp: regexp.MustCompile("7\\.40-.*")}), Equals, true)
c.Check(
p.MatchesDependency(Dependency{Pkg: "alien-arena-common", Architecture: "i386", Relation: VersionRegexp, Version: "7\\.40-.*",
Regexp: regexp.MustCompile("40")}), Equals, true)
c.Check(
p.MatchesDependency(Dependency{Pkg: "alien-arena-common", Architecture: "i386", Relation: VersionRegexp, Version: "7\\.40-.*",
Regexp: regexp.MustCompile("39-.*")}), Equals, false)
// Provides
c.Check(p.MatchesDependency(Dependency{Pkg: "game", Relation: VersionDontCare}), Equals, false)