package engine

import "testing"

func TestNormalizeCapabilities(t *testing.T) {
	got, err := NormalizeCapabilities([]string{" runner/qemu ", "image/nixos", "runner/qemu"})
	if err != nil {
		t.Fatalf("NormalizeCapabilities() error = %v", err)
	}
	want := []string{"image/nixos", "runner/qemu"}
	if len(got) != len(want) || got[0] != want[0] || got[1] != want[1] {
		t.Fatalf("NormalizeCapabilities() = %v, want %v", got, want)
	}
}

func TestNormalizeCapabilitiesRejectsInvalidAtoms(t *testing.T) {
	for _, capabilities := range [][]string{{""}, {"   "}, {"image/nixos arm"}, {"image/nixos\tarm"}} {
		if got, err := NormalizeCapabilities(capabilities); err == nil {
			t.Errorf("NormalizeCapabilities(%q) = %v, nil; want error", capabilities, got)
		}
	}
}
