mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
bb068ed76b
* Provide docker functionality to retrieve images Co-authored-by: Sven Merk <33895725+nevskrem@users.noreply.github.com>
37 lines
847 B
Go
37 lines
847 B
Go
package docker
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetImageSource(t *testing.T) {
|
|
|
|
cases := []struct {
|
|
imageName string
|
|
registryURL string
|
|
localPath string
|
|
want string
|
|
}{
|
|
{"imageName", "", "", "imageName"},
|
|
{"imageName", "", "localPath", "daemon://localPath"},
|
|
{"imageName", "http://registryURL", "", "remote://registryURL/imageName"},
|
|
{"imageName", "https://containerRegistryUrl", "", "remote://containerRegistryUrl/imageName"},
|
|
{"imageName", "registryURL", "", "remote://registryURL/imageName"},
|
|
}
|
|
|
|
client := Client{}
|
|
|
|
for _, c := range cases {
|
|
|
|
options := ClientOptions{ImageName: c.imageName, RegistryURL: c.registryURL, LocalPath: c.localPath}
|
|
client.SetOptions(options)
|
|
|
|
got, err := client.GetImageSource()
|
|
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, c.want, got)
|
|
}
|
|
}
|