mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
test(cmd): unit-test buildBrowseURL deep-link vs root
This commit is contained in:
1 parent
adcd10cd52
commit
a6f39e3441
1 file changed
+20
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user