This commit adds an `--force-repo` flag that can be used to replace all the base repositories with a base url to a repository. This is useful for testing but also dangerous as it will not do any checks and happily use a fedora-42 repository for centos-8 depsolving. This will make the use-case of the koji builder easier and is also something that the `build` tool in `images` supports.
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/osbuild/images/pkg/rpmmd"
|
|
)
|
|
|
|
func TestParseRepoURLsHappy(t *testing.T) {
|
|
checkGPG := false
|
|
|
|
cfg, err := parseRepoURLs([]string{
|
|
"file:///path/to/repo",
|
|
"https://example.com/repo",
|
|
}, "forced")
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, cfg, []rpmmd.RepoConfig{
|
|
{
|
|
Id: "forced-repo-0",
|
|
Name: "forced repo#0 /path/to/repo",
|
|
BaseURLs: []string{"file:///path/to/repo"},
|
|
CheckGPG: &checkGPG,
|
|
CheckRepoGPG: &checkGPG,
|
|
},
|
|
{
|
|
Id: "forced-repo-1",
|
|
Name: "forced repo#1 example.com/repo",
|
|
BaseURLs: []string{"https://example.com/repo"},
|
|
CheckGPG: &checkGPG,
|
|
CheckRepoGPG: &checkGPG,
|
|
},
|
|
})
|
|
}
|
|
|
|
func TestParseExtraRepoSad(t *testing.T) {
|
|
_, err := parseRepoURLs([]string{"/just/a/path"}, "forced")
|
|
assert.EqualError(t, err, `scheme missing in "/just/a/path", please prefix with e.g. file:// or https://`)
|
|
|
|
_, err = parseRepoURLs([]string{"https://example.com", "/just/a/path"}, "forced")
|
|
assert.EqualError(t, err, `scheme missing in "/just/a/path", please prefix with e.g. file:// or https://`)
|
|
}
|