Compare commits
2 Commits
bd41075e8a
...
55132437b3
Author | SHA1 | Date | |
---|---|---|---|
55132437b3 | |||
8b26e96af0 |
5
info.go
5
info.go
@ -54,8 +54,9 @@ func infoCmd(c *cli.Context) error {
|
||||
pkgs := flattenFoundPkgs(found, "show")
|
||||
|
||||
var names []string
|
||||
all := c.Bool("all")
|
||||
|
||||
if !c.Bool("all") {
|
||||
if !all {
|
||||
info, err := distro.ParseOSRelease(c.Context)
|
||||
if err != nil {
|
||||
log.Fatal("Error parsing os-release file").Err(err).Send()
|
||||
@ -64,7 +65,7 @@ func infoCmd(c *cli.Context) error {
|
||||
}
|
||||
|
||||
for _, pkg := range pkgs {
|
||||
if !c.Bool("all") {
|
||||
if !all {
|
||||
depsSet := false
|
||||
buildDepsSet := false
|
||||
for _, name := range names {
|
||||
|
@ -13,6 +13,10 @@ func FindPkgs(gdb *sqlx.DB, pkgs []string) (map[string][]db.Package, []string, e
|
||||
notFound := []string(nil)
|
||||
|
||||
for _, pkgName := range pkgs {
|
||||
if pkgName == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
result, err := db.GetPkgs(gdb, "name LIKE ?", pkgName)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
@ -67,3 +67,69 @@ func TestFindPkgs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindPkgsEmpty(t *testing.T) {
|
||||
gdb, err := sqlx.Open("sqlite", ":memory:")
|
||||
if err != nil {
|
||||
t.Fatalf("Expected no error, got %s", err)
|
||||
}
|
||||
defer gdb.Close()
|
||||
|
||||
err = db.Init(gdb)
|
||||
if err != nil {
|
||||
t.Fatalf("Expected no error, got %s", err)
|
||||
}
|
||||
|
||||
setCfgDirs(t)
|
||||
defer removeCacheDir(t)
|
||||
|
||||
err = db.InsertPackage(gdb, db.Package{
|
||||
Name: "test1",
|
||||
Repository: "default",
|
||||
Version: "0.0.1",
|
||||
Release: 1,
|
||||
Description: "Test package 1",
|
||||
Provides: db.NewJSON([]string{""}),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Expected no error, got %s", err)
|
||||
}
|
||||
|
||||
err = db.InsertPackage(gdb, db.Package{
|
||||
Name: "test2",
|
||||
Repository: "default",
|
||||
Version: "0.0.1",
|
||||
Release: 1,
|
||||
Description: "Test package 2",
|
||||
Provides: db.NewJSON([]string{"test"}),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Expected no error, got %s", err)
|
||||
}
|
||||
|
||||
found, notFound, err := repos.FindPkgs(gdb, []string{"test", ""})
|
||||
if err != nil {
|
||||
t.Fatalf("Expected no error, got %s", err)
|
||||
}
|
||||
|
||||
if len(notFound) != 0 {
|
||||
t.Errorf("Expected all packages to be found")
|
||||
}
|
||||
|
||||
if len(found) != 1 {
|
||||
t.Errorf("Expected 1 package found, got %d", len(found))
|
||||
}
|
||||
|
||||
testPkgs, ok := found["test"]
|
||||
if !ok {
|
||||
t.Fatalf("Expected 'test' packages to be found")
|
||||
}
|
||||
|
||||
if len(testPkgs) != 1 {
|
||||
t.Errorf("Expected one 'test' package to be found, got %d", len(testPkgs))
|
||||
}
|
||||
|
||||
if testPkgs[0].Name != "test2" {
|
||||
t.Errorf("Expected 'test2' package, got '%s'", testPkgs[0].Name)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user