forked from gitploy-io/gitploy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepos_test.go
More file actions
62 lines (50 loc) · 1.27 KB
/
repos_test.go
File metadata and controls
62 lines (50 loc) · 1.27 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package github
import (
"context"
"testing"
"github.com/gitploy-io/gitploy/model/ent"
"github.com/gitploy-io/gitploy/pkg/e"
"gopkg.in/h2non/gock.v1"
)
func TestGithub_DeleteWebhook(t *testing.T) {
t.Run("Return the ErrorCodeEntityNotFound error when the webhook is not found.", func(t *testing.T) {
t.Log("Mocking the delete webhook API")
gock.New("https://api.github.com").
Delete("/repos/gitploy-io/gitploy/hooks/1").
Reply(404)
g := NewGithub(&GithubConfig{})
const hookID = 1
err := g.DeleteWebhook(
context.Background(),
&ent.User{},
&ent.Repo{
Namespace: "gitploy-io",
Name: "gitploy",
},
hookID,
)
if !e.HasErrorCode(err, e.ErrorCodeEntityNotFound) {
t.Fatalf("DeleteWebhook doesn't returns an ErrorCodeEntityNotFound error: %v", err)
}
})
t.Run("Delete the webhook.", func(t *testing.T) {
t.Log("Mocking the delete webhook API")
gock.New("https://api.github.com").
Delete("/repos/gitploy-io/gitploy/hooks/1").
Reply(200)
g := NewGithub(&GithubConfig{})
const hookID = 1
err := g.DeleteWebhook(
context.Background(),
&ent.User{},
&ent.Repo{
Namespace: "gitploy-io",
Name: "gitploy",
},
hookID,
)
if err != nil {
t.Fatalf("DeleteWebhook returns an error: %v", err)
}
})
}