courgette/internal/runner/runner_test.go

38 lines
928 B
Go
Raw Normal View History

package runner
import (
"testing"
)
func TestGetContainerNameReturnsADeterministicName(t *testing.T) {
runner := Runner{}
containerName := runner.GetContainerName("testid")
if containerName != "runner-testid" {
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)
}
}