feat(watchpr): poll GitHub PRs alongside Gitea
This commit is contained in:
@@ -181,3 +181,36 @@ func TestRemoteHost(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseWatchRef(t *testing.T) {
|
||||
tests := []struct {
|
||||
in string
|
||||
want PRRef
|
||||
}{
|
||||
{"unkin/repo#4", PRRef{Owner: "unkin", Repo: "repo", Number: 4}},
|
||||
{"github:IUCLabs/app#12", PRRef{Forge: ForgeGitHub, Owner: "IUCLabs", Repo: "app", Number: 12}},
|
||||
{"github:IUCLabs/app:12", PRRef{Forge: ForgeGitHub, Owner: "IUCLabs", Repo: "app", Number: 12}},
|
||||
{" https://github.com/IUCLabs/app/pull/12 ", PRRef{Forge: ForgeGitHub, Owner: "IUCLabs", Repo: "app", Number: 12}},
|
||||
{"https://github.com/IUCLabs/app/pull/12/", PRRef{Forge: ForgeGitHub, Owner: "IUCLabs", Repo: "app", Number: 12}},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
got, err := ParseWatchRef(tt.in)
|
||||
if err != nil || got != tt.want {
|
||||
t.Errorf("ParseWatchRef(%q) = %+v, %v; want %+v", tt.in, got, err, tt.want)
|
||||
}
|
||||
}
|
||||
for _, bad := range []string{
|
||||
"github:IUCLabs#1", "github:IUCLabs/app#0", "https://github.com/IUCLabs/app/issues/3",
|
||||
"https://github.com/IUCLabs/app/pull/3/files", "https://github.com/IUCLabs/app/pull/x", "gitlab:o/r#1",
|
||||
} {
|
||||
if got, err := ParseWatchRef(bad); err == nil {
|
||||
t.Errorf("ParseWatchRef(%q) = %+v, want error", bad, got)
|
||||
}
|
||||
}
|
||||
if s := (PRRef{Forge: ForgeGitHub, Owner: "o", Repo: "r", Number: 3}).String(); s != "github:o/r#3" {
|
||||
t.Errorf("String() = %q", s)
|
||||
}
|
||||
if _, err := ParsePRRef("github:o/r#3"); err == nil {
|
||||
t.Error("ParsePRRef must not accept GitHub refs: Gitea-only tools use it")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user