-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
38 lines (35 loc) · 847 Bytes
/
Copy pathmain_test.go
File metadata and controls
38 lines (35 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"testing"
"github.com/kukv/herdr-plugin-github-dash/internal/ui"
)
func TestParseTarget(t *testing.T) {
cases := []struct {
url string
want *ui.Target
}{
{
"https://github.com/kukv/test-repo/pull/7",
&ui.Target{Kind: ui.KindPR, Repo: "kukv/test-repo", Number: 7},
},
{
"https://github.com/kukv/test-repo/issues/42/",
&ui.Target{Kind: ui.KindIssue, Repo: "kukv/test-repo", Number: 42},
},
{"https://github.com/kukv/test-repo", nil},
{"https://example.com/kukv/test-repo/pull/7", nil},
{"", nil},
}
for _, c := range cases {
got := parseTarget(c.url)
if c.want == nil {
if got != nil {
t.Errorf("parseTarget(%q) = %+v, want nil", c.url, got)
}
continue
}
if got == nil || *got != *c.want {
t.Errorf("parseTarget(%q) = %+v, want %+v", c.url, got, c.want)
}
}
}