-
Notifications
You must be signed in to change notification settings - Fork 22
many: force-repo-dir instead of force-data-dir
#408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,18 +61,18 @@ func TestNewRepoRegistryImplExtraReposGetAppended(t *testing.T) { | |
| assert.Equal(t, repos[len(repos)-1].BaseURLs[0], "https://example.com/my/repo") | ||
| } | ||
|
|
||
| func TestNewRepoRegistryImplDatadir(t *testing.T) { | ||
| func TestNewRepoRegistryImplRepodir(t *testing.T) { | ||
| // prereq test: no testdistro-1 in the default repos | ||
| registry, err := newRepoRegistryImpl("", nil) | ||
| require.NoError(t, err) | ||
| assert.NotContains(t, registry.ListDistros(), "testdistro-1") | ||
| _, err = registry.DistroHasRepos("testdistro-1", "x86_64") | ||
| require.EqualError(t, err, `requested repository not found: for distribution "testdistro-1"`) | ||
|
|
||
| // create a custom datadir with testdistro-1.json, the basefilename | ||
| // create a custom repodir with testdistro-1.json, the basefilename | ||
| // must match a distro nameVer | ||
| dataDir := t.TempDir() | ||
| repoFile := filepath.Join(dataDir, "repositories", "testdistro-1.json") | ||
| repoDir := t.TempDir() | ||
| repoFile := filepath.Join(repoDir, "repositories", "testdistro-1.json") | ||
|
Comment on lines
+74
to
+75
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be beneficial to test this also without the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added a second test that tests without the |
||
| err = os.Mkdir(filepath.Dir(repoFile), 0755) | ||
| require.NoError(t, err) | ||
| repoContents := `{ | ||
|
|
@@ -88,7 +88,40 @@ func TestNewRepoRegistryImplDatadir(t *testing.T) { | |
| require.NoError(t, err) | ||
|
|
||
| // and ensure we have testdistro-1 now | ||
| registry, err = newRepoRegistryImpl(dataDir, nil) | ||
| registry, err = newRepoRegistryImpl(repoDir, nil) | ||
| require.NoError(t, err) | ||
| repos, err := registry.DistroHasRepos("testdistro-1", "x86_64") | ||
| require.NoError(t, err) | ||
| assert.Len(t, repos, 1) | ||
| assert.Equal(t, repos[0].Name, "testdistro-1-repo") | ||
| } | ||
|
|
||
| func TestNewRepoRegistryImplRepodirNoSubDir(t *testing.T) { | ||
| // prereq test: no testdistro-1 in the default repos | ||
| registry, err := newRepoRegistryImpl("", nil) | ||
| require.NoError(t, err) | ||
| assert.NotContains(t, registry.ListDistros(), "testdistro-1") | ||
| _, err = registry.DistroHasRepos("testdistro-1", "x86_64") | ||
| require.EqualError(t, err, `requested repository not found: for distribution "testdistro-1"`) | ||
|
|
||
| // create a custom repodir with testdistro-1.json, the basefilename | ||
| // must match a distro nameVer | ||
| repoDir := t.TempDir() | ||
| repoFile := filepath.Join(repoDir, "testdistro-1.json") | ||
| repoContents := `{ | ||
| "x86_64": [ | ||
| { | ||
| "name": "testdistro-1-repo", | ||
| "baseurl": "https://example.com/test/test/distro/1" | ||
| } | ||
| ] | ||
| } | ||
| ` | ||
| err = os.WriteFile(repoFile, []byte(repoContents), 0644) | ||
| require.NoError(t, err) | ||
|
|
||
| // and ensure we have testdistro-1 now | ||
| registry, err = newRepoRegistryImpl(repoDir, nil) | ||
| require.NoError(t, err) | ||
| repos, err := registry.DistroHasRepos("testdistro-1", "x86_64") | ||
| require.NoError(t, err) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the
force-data-diroption be normalized as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch yes, I've added normalization for that one too.