internal/control/repo_test.go

695cb925d1f99f7735883046e455cdc436602cb1
gitbay/internal/control/repo_test.go

38 lines · 1165 bytes

 1package control
 2
 3import (
 4	"bytes"
 5	"strings"
 6	"testing"
 7
 8	"gitbay.org/gitbay/internal/protocol"
 9	"gitbay.org/gitbay/internal/store"
10)
11
12// repo show's mirror row must go through the same second-truncation every
13// other timestamp in a view uses, not print the store's raw milliseconds.
14func TestRepoShowMirrorTimeIsTruncatedToTheSecond(t *testing.T) {
15	st, repo, uid := newQueueTestRepo(t)
16	id, err := st.AddMirror(repo.ID, "push", "ssh://example.test/x.git", "", "")
17	if err != nil {
18		t.Fatal(err)
19	}
20	if err := st.SetMirrorResult(id, ""); err != nil {
21		t.Fatal(err)
22	}
23	if _, err := st.DB.Exec("UPDATE mirrors SET last_sync = ? WHERE id = ?", "2026-09-24T15:31:50.839Z", id); err != nil {
24		t.Fatal(err)
25	}
26
27	c, errOut := pruneCtx(st, t.TempDir(), store.User{ID: uid, Username: "alice", IsAdmin: true})
28	if code := runRepoShow(c, []string{repo.Path()}); code != protocol.ExitOK {
29		t.Fatalf("exit %d: %s", code, errOut.String())
30	}
31	out := c.Stdout.(*bytes.Buffer).String()
32	if strings.Contains(out, ".839Z") {
33		t.Errorf("milliseconds leaked: %s", out)
34	}
35	if !strings.Contains(out, "2026-09-24T15:31:50Z") {
36		t.Errorf("no truncated timestamp: %s", out)
37	}
38}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form