e2e/badge_test.go

4a511e42574ead9c92dc73fd320f296cc4dbea07
gitbay/e2e/badge_test.go

35 lines · 1234 bytes

1 symbol in this file
 1package e2e
 2
 3import (
 4	"strings"
 5	"testing"
 6)
 7
 8// TestBuildBadge covers the badge endpoint: it reports the newest build,
 9// says "unknown" before any build exists, and 404s for a private repo so
10// it cannot be used to probe for one.
11func TestBuildBadge(t *testing.T) {
12	t.Parallel()
13	inst := startInstance(t)
14	aliceKey := inst.newKey(t, "alice")
15	inst.admin(t, "admin", "user", "create", "alice", "--key", aliceKey+".pub")
16	if _, errOut, code := inst.ssh(t, aliceKey, "", "repo", "create", "alice/app"); code != 0 {
17		t.Fatalf("repo create: %s", errOut)
18	}
19
20	status, body := inst.get(t, "/alice/app/badge/build.svg")
21	if status != 200 || !strings.Contains(body, "unknown") || !strings.Contains(body, "<svg") {
22		t.Fatalf("badge before any build: %d\n%s", status, body)
23	}
24
25	// Private repositories have no badge, like every other surface.
26	if _, _, code := inst.ssh(t, aliceKey, "", "repo", "create", "alice/vault", "--private"); code != 0 {
27		t.Fatal("private repo create failed")
28	}
29	if status, _ := inst.get(t, "/alice/vault/badge/build.svg"); status != 404 {
30		t.Fatalf("private badge: %d", status)
31	}
32	if status, _ := inst.get(t, "/alice/nope/badge/build.svg"); status != 404 {
33		t.Fatalf("missing repo badge: %d", status)
34	}
35}
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