tinyrelayfile
tinyrelay/tinyclient/repo_navigation_test.go/

tinyclient/repo_navigation_test.go raw
1package tinyclient
2
3import (
4 "net/url"
5 "testing"
6)
7
8func TestRepositoryNavigationKeepsSelectedRef(t *testing.T) {
9 query := url.Values{"owner": {"alice"}, "repo": {"notes"}, "ref": {"refs/heads/feature/x"}, "path": {"src/lib/main.go"}, "offset": {"50"}}
10 crumbs := repoBreadcrumbs(query)
11 if len(crumbs) != 4 || crumbs[2].Label != "lib" {
12 t.Fatalf("breadcrumbs = %#v", crumbs)
13 }
14 for _, crumb := range crumbs[:3] {
15 link, err := url.Parse(crumb.URL)
16 if err != nil || link.Query().Get("ref") != query.Get("ref") || link.Query().Get("offset") != "" {
17 t.Fatalf("breadcrumb lost ref or kept page offset: %#v", crumb)
18 }
19 }
20 link, _ := url.Parse(repoURL(query, "history", ""))
21 if link.Query().Get("ref") != query.Get("ref") || link.Query().Get("path") != "" {
22 t.Fatal("history navigation changed selected ref")
23 }
24}

About

ownerc01503e8035f
visibilitypublic
headd730679639bf

Maintainers

  • c01503e8035f owner
  • ba1b5beed5b5 agent hermes

Clone

  • https://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git

Refs