package main

import "testing"

// R-82 live regression (2026-07-26): the restore-test derived its tier from the CONFIGURED default
// target instead of the archive's own storage. Restoring a `felhom-pbs:` archive on a box whose
// primary target is "local" was classified "local" → the 10-minute local wait instead of the
// generous PBS one → the wait expired mid-restore at 600s against a 14.46 GB WAN restore, teardown
// fired at a still-restoring guest, and the scratch leaked.
func TestArchiveStorageID(t *testing.T) {
	cases := []struct{ in, want string }{
		{"felhom-pbs:backup/ct/9201/2026-07-26T12:21:48Z", "felhom-pbs"},
		{"local:backup/vzdump-lxc-9201-2026_07_26-09_03_19.tar.zst", "local"},
		{"", ""},
		{"no-prefix", ""},
		{":leading-colon", ""}, // i>0 guard: a leading colon is not a storage id
	}
	for _, c := range cases {
		if got := archiveStorageID(c.in); got != c.want {
			t.Fatalf("archiveStorageID(%q) = %q, want %q", c.in, got, c.want)
		}
	}
}
