package main

import "testing"

func TestOrasPushInvocationUsesRelativeWorkspacePaths(t *testing.T) {
	dir, args, err := orasPushInvocation("registry.bstein.dev/metis/titan-13:20260331t235724z", "/workspace/build/titan-13.img.xz", "/workspace/build/metadata.json")
	if err != nil {
		t.Fatalf("orasPushInvocation returned error: %v", err)
	}
	if dir != "/workspace/build" {
		t.Fatalf("expected work dir /workspace/build, got %q", dir)
	}
	if len(args) != 4 {
		t.Fatalf("expected 4 args, got %d", len(args))
	}
	if args[0] != "push" {
		t.Fatalf("expected push verb, got %q", args[0])
	}
	if args[1] != "registry.bstein.dev/metis/titan-13:20260331t235724z" {
		t.Fatalf("unexpected ref: %q", args[1])
	}
	if args[2] != "titan-13.img.xz:application/x-raw-disk-image" {
		t.Fatalf("unexpected image arg: %q", args[2])
	}
	if args[3] != "metadata.json:application/json" {
		t.Fatalf("unexpected metadata arg: %q", args[3])
	}
}

func TestHumanHostPathMapsMountedTmpBackToHostTmp(t *testing.T) {
	if got := humanHostPath("/host-tmp/metis-flash-test"); got != "/tmp/metis-flash-test" {
		t.Fatalf("expected /tmp/metis-flash-test, got %q", got)
	}
}
