Skip to content

Commit

Permalink
Update imports
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessOne91 committed Sep 25, 2024
1 parent d7cdc16 commit 4a12566
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
14 changes: 7 additions & 7 deletions cmd/updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type Updates struct {
ReleaseRequest string
SRCRPMS []string
Products string
Repositories []HTTPRepoConfig
Repositories []get.HTTPRepoConfig
}

// package scoped array of all possible available archs to check for a repo
Expand Down Expand Up @@ -170,9 +170,9 @@ func muFindAndSync() {
//time.Sleep(60 * time.Second)
}

func ProcWebChunk(client *http.Client, product, maint string) ([]HTTPRepoConfig, error) {
httpFormattedRepos := []HTTPRepoConfig{}
repo := HTTPRepoConfig{
func ProcWebChunk(client *http.Client, product, maint string) ([]get.HTTPRepoConfig, error) {
httpFormattedRepos := []get.HTTPRepoConfig{}
repo := get.HTTPRepoConfig{
Archs: []string{},
}
repoUrl := maint + product
Expand All @@ -198,7 +198,7 @@ func ProcWebChunk(client *http.Client, product, maint string) ([]HTTPRepoConfig,
}

// ---- This function checks that all architecture slice of a *HTTPRepoConfig is filled right
func ArchMage(client *http.Client, repo *HTTPRepoConfig) error {
func ArchMage(client *http.Client, repo *get.HTTPRepoConfig) error {
archsChan := make(chan string)
// we need a dedicated goroutine to start the others, wait for them to finish
// and signal back that we're done doing HTTP calls
Expand Down Expand Up @@ -242,13 +242,13 @@ func ArchMage(client *http.Client, repo *HTTPRepoConfig) error {
return nil
}

func GetRepo(client *http.Client, mu string) (httpFormattedRepos []HTTPRepoConfig, err error) {
func GetRepo(client *http.Client, mu string) (httpFormattedRepos []get.HTTPRepoConfig, err error) {
productsChunks, err := getProductsForMU(client, mu)
if err != nil {
return nil, fmt.Errorf("error retrieving products for MU %s: %v", mu, err)
}

reposChan := make(chan []HTTPRepoConfig)
reposChan := make(chan []get.HTTPRepoConfig)
errChan := make(chan error)
// empty struct for 0 allocation: we need only to signal we're done, not pass data
doneChan := make(chan struct{})
Expand Down
23 changes: 12 additions & 11 deletions cmd/updates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/uyuni-project/minima/get"
)

var sle15sp4Entry = "SUSE_SLE-15-SP4_Update/"
Expand Down Expand Up @@ -101,7 +102,7 @@ func TestArchMage(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
repo := HTTPRepoConfig{
repo := get.HTTPRepoConfig{
URL: maint + sle15sp4Entry + tt.urlArch,
Archs: []string{},
}
Expand All @@ -120,14 +121,14 @@ func TestProcWebChunk(t *testing.T) {
maint string
product string
validArchs []string
want []HTTPRepoConfig
want []get.HTTPRepoConfig
netWorkErr bool
wantErr bool
}{
{
"Valid maint repo - single valid arch", "http://download.suse.de/ibs/SUSE:/Maintenance:/2/", "SUSE_SLE-15-SP4_Update/",
[]string{"aarch64"},
[]HTTPRepoConfig{
[]get.HTTPRepoConfig{
{
URL: "http://download.suse.de/ibs/SUSE:/Maintenance:/2/SUSE_SLE-15-SP4_Update/",
Archs: []string{"aarch64"},
Expand All @@ -139,7 +140,7 @@ func TestProcWebChunk(t *testing.T) {
{
"Valid maint repo - multiple valid archs", "http://download.suse.de/ibs/SUSE:/Maintenance:/3/", "SUSE_SLE-15-SP4_Update/",
[]string{"x86_64", "aarch64", "ppc64le", "s390x"},
[]HTTPRepoConfig{
[]get.HTTPRepoConfig{
{
URL: "http://download.suse.de/ibs/SUSE:/Maintenance:/3/SUSE_SLE-15-SP4_Update/",
Archs: []string{"x86_64", "aarch64", "ppc64le", "s390x"},
Expand All @@ -151,14 +152,14 @@ func TestProcWebChunk(t *testing.T) {
{
"Valid maint repo - no valid archs", "http://download.suse.de/ibs/SUSE:/Maintenance:/4/", "SUSE_SLE-15-SP4_Update/",
[]string{},
[]HTTPRepoConfig{},
[]get.HTTPRepoConfig{},
false,
true,
},
{
"Network error", "http://download.suse.de/ibs/SUSE:/Maintenance:/5/", "SUSE_SLE-15-SP4_Update/",
[]string{},
[]HTTPRepoConfig{},
[]get.HTTPRepoConfig{},
true,
true,
},
Expand Down Expand Up @@ -216,14 +217,14 @@ func TestGetRepo(t *testing.T) {
name string
mu string
validArchs []string
want []HTTPRepoConfig
want []get.HTTPRepoConfig
netWorkErr bool
wantErr bool
}{
{
"Single arch", "http://download.suse.de/ibs/SUSE:/Maintenance:/8/",
[]string{"x86_64"},
[]HTTPRepoConfig{
[]get.HTTPRepoConfig{
{
URL: "http://download.suse.de/ibs/SUSE:/Maintenance:/8/SUSE_SLE-15-SP4_Update/",
Archs: []string{"x86_64"},
Expand All @@ -239,7 +240,7 @@ func TestGetRepo(t *testing.T) {
{
"Multiple archs", "http://download.suse.de/ibs/SUSE:/Maintenance:/9/",
[]string{"x86_64", "aarch64", "ppc64le", "s390x"},
[]HTTPRepoConfig{
[]get.HTTPRepoConfig{
{
URL: "http://download.suse.de/ibs/SUSE:/Maintenance:/9/SUSE_SLE-15-SP4_Update/",
Archs: []string{"x86_64", "aarch64", "ppc64le", "s390x"},
Expand All @@ -255,14 +256,14 @@ func TestGetRepo(t *testing.T) {
{
"No available archs", "http://download.suse.de/ibs/SUSE:/Maintenance:/10/",
[]string{},
[]HTTPRepoConfig{},
[]get.HTTPRepoConfig{},
false,
true,
},
{
"Network error", "http://download.suse.de/ibs/SUSE:/Maintenance:/11/",
[]string{},
[]HTTPRepoConfig{},
[]get.HTTPRepoConfig{},
true,
true,
},
Expand Down

0 comments on commit 4a12566

Please sign in to comment.