diff options
-rw-r--r-- | pkg/repository/apkindex.go | 13 | ||||
-rw-r--r-- | pkg/repository/package.go | 23 | ||||
-rw-r--r-- | pkg/repository/package_test.go | 16 |
3 files changed, 39 insertions, 13 deletions
diff --git a/pkg/repository/apkindex.go b/pkg/repository/apkindex.go index 1809bd4..bc9c473 100644 --- a/pkg/repository/apkindex.go +++ b/pkg/repository/apkindex.go @@ -10,19 +10,6 @@ import ( "strings" ) -type Package struct { - Name string - Version string - Arch string - Description string - License string - Origin string - Maintainer string - Checksum []byte - Dependencies []string - Provides []string -} - type ApkIndex struct { Signature []byte Description string diff --git a/pkg/repository/package.go b/pkg/repository/package.go new file mode 100644 index 0000000..745aeaa --- /dev/null +++ b/pkg/repository/package.go @@ -0,0 +1,23 @@ +package repository + +import "fmt" + +//Package represents a single package with the information present in an +//APKINDEX. +type Package struct { + Name string + Version string + Arch string + Description string + License string + Origin string + Maintainer string + Checksum []byte + Dependencies []string + Provides []string +} + +//Returns the package filename as it's named in a repository. +func (p *Package) Filename() string { + return fmt.Sprintf("%s-%s.apk", p.Name, p.Version) +} diff --git a/pkg/repository/package_test.go b/pkg/repository/package_test.go new file mode 100644 index 0000000..0ef3f14 --- /dev/null +++ b/pkg/repository/package_test.go @@ -0,0 +1,16 @@ +package repository + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestPackageReturnsProperFilename(t *testing.T) { + pkg := Package{ + Name: "test-package", + Version: "1.2.3-r0", + } + + assert.Equal(t, "test-package-1.2.3-r0.apk", pkg.Filename()) +} |