2024-08-01 22:43:18 +00:00
|
|
|
package runner
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetContainerNameReturnsADeterministicName(t *testing.T) {
|
|
|
|
runner := Runner{}
|
2024-08-02 02:48:54 +00:00
|
|
|
containerName := runner.GetContainerName("testid")
|
|
|
|
if containerName != "runner-testid" {
|
2024-08-01 22:43:18 +00:00
|
|
|
t.Errorf("Unexpected container name: %s", containerName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetImageUriByLabelReturnsAUriIfLabelled(t *testing.T) {
|
|
|
|
labels := map[string]string{
|
|
|
|
"test-label": "some-image",
|
|
|
|
}
|
|
|
|
runner := Runner{
|
|
|
|
Labels: labels,
|
|
|
|
}
|
|
|
|
imageUri := runner.GetImageUriByLabel("test-label")
|
|
|
|
if uri, _ := labels["test-label"]; imageUri != uri {
|
|
|
|
t.Errorf("Expected uri %s, got %s instead.", uri, imageUri)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetImageUriByLabelReturnsTheDefaultUriIfLabelUnknown(t *testing.T) {
|
|
|
|
labels := map[string]string{}
|
|
|
|
runner := Runner{
|
|
|
|
Labels: labels,
|
|
|
|
}
|
|
|
|
imageUri := runner.GetImageUriByLabel("test-label")
|
|
|
|
if imageUri != "debian:latest" {
|
|
|
|
t.Errorf("Expected default uri, got %s instead.", imageUri)
|
|
|
|
}
|
|
|
|
}
|