diff --git a/cmd/sanderling/replay_test.go b/cmd/sanderling/replay_test.go index ab01d68..1bcdd40 100644 --- a/cmd/sanderling/replay_test.go +++ b/cmd/sanderling/replay_test.go @@ -3,6 +3,7 @@ package main import ( "bytes" "io" + "net" "strings" "testing" ) @@ -34,6 +35,25 @@ func TestParseReplayArgs_RejectsTooManyPositional(t *testing.T) { } } +func TestBuildBrowseURL(t *testing.T) { + address := &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 8080} + cases := []struct { + name string + deepLinkID string + want string + }{ + {"root", "", "http://127.0.0.1:8080/"}, + {"deep link", "20240101-120000", "http://127.0.0.1:8080/runs/20240101-120000"}, + } + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + if got := buildBrowseURL(address, c.deepLinkID); got != c.want { + t.Errorf("buildBrowseURL(%q) = %q, want %q", c.deepLinkID, got, c.want) + } + }) + } +} + func TestRun_HelpListsReplayCommand(t *testing.T) { var stdout bytes.Buffer if err := run([]string{"sanderling"}, &stdout, io.Discard); err != nil {