- Deleted old deb822_encode.go and deb822_types.go files. - Introduced new deb822_encode.go with improved Marshall function and Writer struct for encoding. - Added deb822_decode.go for decoding functionality with enhanced error handling. - Created deb822_rawdata.go to define RawData type for handling raw deb822 values. - Implemented Description type in deb822/datatype/description.go for structured description handling. - Updated Package struct in dpkg/header.go to use new Description type. - Refactored UnmarshalBinary method in dpkg/header.go to utilize new deb822 decoding logic. - Added comprehensive tests for encoding and decoding in deb822_encode_test.go and deb822_decode_test.go. - Removed internal scanner package as it was no longer needed. Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
45 lines
699 B
Go
45 lines
699 B
Go
package apt
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/url"
|
|
"testing"
|
|
)
|
|
|
|
func TestRelease(t *testing.T) {
|
|
sources, err := ParseSourcelist(sourceDeb822)
|
|
if err != nil {
|
|
t.Skip(err)
|
|
return
|
|
}
|
|
|
|
rel, err := sources[0].Release()
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
d, _ := json.MarshalIndent(rel, "", " ")
|
|
t.Log(string(d))
|
|
}
|
|
|
|
func TestParsePackages(t *testing.T) {
|
|
pkgSum := Sum{File: "main/binary-amd64/Packages.gz"}
|
|
pkgs := pkgSum.Pkgs("stable", &AptSource{
|
|
Suites: []string{"main", "stable"},
|
|
URIs: []*url.URL{
|
|
{
|
|
Scheme: "http",
|
|
Host: "ftp.debian.org",
|
|
Path: "/debian",
|
|
},
|
|
},
|
|
})
|
|
|
|
for _, err := range pkgs {
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
}
|
|
}
|