mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-15 11:57:59 +00:00
fix: resolve golangci-lint failures in jfrog storage implementation
- Remove unused pathCache field from PublishedStorage struct - Remove unused md5s accumulation in Filelist() - Fix unchecked error return on expectedOut.Write in config_test.go - Suppress unused linter on configFileYAML/configFileYAMLError constants (retained to avoid merge conflicts with feat/pls/gcs-support) - Add --timeout=10m to golangci-lint workflow - add back removed tests
This commit is contained in:
committed by
André Roth
parent
4b8f0c42ac
commit
214c151194
@@ -197,6 +197,127 @@ func (s *ConfigSuite) TestSaveConfig(c *C) {
|
||||
}`)
|
||||
}
|
||||
|
||||
func (s *ConfigSuite) TestLoadYAMLConfig(c *C) {
|
||||
configname := filepath.Join(c.MkDir(), "aptly.yaml1")
|
||||
f, _ := os.Create(configname)
|
||||
_, _ = f.WriteString(configFileYAML)
|
||||
_ = f.Close()
|
||||
|
||||
// start with empty config
|
||||
s.config = ConfigStructure{}
|
||||
|
||||
err := LoadConfig(configname, &s.config)
|
||||
c.Assert(err, IsNil)
|
||||
c.Check(s.config.GetRootDir(), Equals, "/opt/aptly/")
|
||||
c.Check(s.config.DownloadConcurrency, Equals, 40)
|
||||
c.Check(s.config.DatabaseOpenAttempts, Equals, 10)
|
||||
}
|
||||
|
||||
func (s *ConfigSuite) TestLoadYAMLErrorConfig(c *C) {
|
||||
configname := filepath.Join(c.MkDir(), "aptly.yaml2")
|
||||
f, _ := os.Create(configname)
|
||||
_, _ = f.WriteString(configFileYAMLError)
|
||||
_ = f.Close()
|
||||
|
||||
// start with empty config
|
||||
s.config = ConfigStructure{}
|
||||
|
||||
err := LoadConfig(configname, &s.config)
|
||||
c.Assert(err.Error(), Equals, "invalid yaml (unknown pool storage type: invalid) or json (invalid character 'p' looking for beginning of value)")
|
||||
}
|
||||
|
||||
func (s *ConfigSuite) TestSaveYAMLConfig(c *C) {
|
||||
configname := filepath.Join(c.MkDir(), "aptly.yaml3")
|
||||
f, _ := os.Create(configname)
|
||||
_, _ = f.WriteString(configFileYAML)
|
||||
_ = f.Close()
|
||||
|
||||
// start with empty config
|
||||
s.config = ConfigStructure{}
|
||||
|
||||
err := LoadConfig(configname, &s.config)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
err = SaveConfigYAML(configname, &s.config)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
f, _ = os.Open(configname)
|
||||
defer func() {
|
||||
_ = f.Close()
|
||||
}()
|
||||
|
||||
st, _ := f.Stat()
|
||||
buf := make([]byte, st.Size())
|
||||
_, _ = f.Read(buf)
|
||||
|
||||
c.Check(string(buf), Equals, configFileYAML)
|
||||
}
|
||||
|
||||
func (s *ConfigSuite) TestSaveYAML2Config(c *C) {
|
||||
// start with empty config
|
||||
s.config = ConfigStructure{}
|
||||
|
||||
s.config.PackagePoolStorage.Local = &LocalPoolStorage{"/tmp/aptly-pool"}
|
||||
s.config.PackagePoolStorage.Azure = nil
|
||||
|
||||
configname := filepath.Join(c.MkDir(), "aptly.yaml4")
|
||||
err := SaveConfigYAML(configname, &s.config)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
f, _ := os.Open(configname)
|
||||
defer func() {
|
||||
_ = f.Close()
|
||||
}()
|
||||
|
||||
st, _ := f.Stat()
|
||||
buf := make([]byte, st.Size())
|
||||
_, _ = f.Read(buf)
|
||||
|
||||
c.Check(string(buf), Equals, ""+
|
||||
"root_dir: \"\"\n"+
|
||||
"log_level: \"\"\n"+
|
||||
"log_format: \"\"\n"+
|
||||
"database_open_attempts: 0\n"+
|
||||
"architectures: []\n"+
|
||||
"skip_legacy_pool: false\n"+
|
||||
"dep_follow_suggests: false\n"+
|
||||
"dep_follow_recommends: false\n"+
|
||||
"dep_follow_all_variants: false\n"+
|
||||
"dep_follow_source: false\n"+
|
||||
"dep_verboseresolve: false\n"+
|
||||
"ppa_distributor_id: \"\"\n"+
|
||||
"ppa_codename: \"\"\n"+
|
||||
"ppa_baseurl: \"\"\n"+
|
||||
"serve_in_api_mode: false\n"+
|
||||
"enable_metrics_endpoint: false\n"+
|
||||
"enable_swagger_endpoint: false\n"+
|
||||
"async_api: false\n"+
|
||||
"database_backend:\n"+
|
||||
" type: \"\"\n"+
|
||||
" db_path: \"\"\n"+
|
||||
" url: \"\"\n"+
|
||||
"downloader: \"\"\n"+
|
||||
"download_concurrency: 0\n"+
|
||||
"download_limit: 0\n"+
|
||||
"download_retries: 0\n"+
|
||||
"download_sourcepackages: false\n"+
|
||||
"gpg_provider: \"\"\n"+
|
||||
"gpg_disable_sign: false\n"+
|
||||
"gpg_disable_verify: false\n"+
|
||||
"gpg_keys: []\n"+
|
||||
"skip_contents_publishing: false\n"+
|
||||
"skip_bz2_publishing: false\n"+
|
||||
"filesystem_publish_endpoints: {}\n"+
|
||||
"jfrog_publish_endpoints: {}\n"+
|
||||
"s3_publish_endpoints: {}\n"+
|
||||
"gcs_publish_endpoints: {}\n"+
|
||||
"swift_publish_endpoints: {}\n"+
|
||||
"azure_publish_endpoints: {}\n"+
|
||||
"packagepool_storage:\n"+
|
||||
" type: local\n"+
|
||||
" path: /tmp/aptly-pool\n")
|
||||
}
|
||||
|
||||
func (s *ConfigSuite) TestLoadEmptyConfig(c *C) {
|
||||
configname := filepath.Join(c.MkDir(), "aptly.yaml5")
|
||||
f, _ := os.Create(configname)
|
||||
@@ -250,6 +371,7 @@ filesystem_publish_endpoints:
|
||||
root_dir: /opt/srv/aptly_public
|
||||
link_method: hardlink
|
||||
verify_method: md5
|
||||
jfrog_publish_endpoints: {}
|
||||
s3_publish_endpoints:
|
||||
test:
|
||||
region: us-east-1
|
||||
|
||||
Reference in New Issue
Block a user