From ba920f9a402eafea1417a4b8a018359030e08961 Mon Sep 17 00:00:00 2001 From: Ichinose Shogo Date: Thu, 2 Sep 2021 08:05:02 +0900 Subject: [PATCH] add dummy provider for testing --- provider/github-app-token/cmd/dummy/main.go | 13 ++++++++ provider/github-app-token/dummy.go | 33 +++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 provider/github-app-token/cmd/dummy/main.go create mode 100644 provider/github-app-token/dummy.go diff --git a/provider/github-app-token/cmd/dummy/main.go b/provider/github-app-token/cmd/dummy/main.go new file mode 100644 index 00000000..889dc451 --- /dev/null +++ b/provider/github-app-token/cmd/dummy/main.go @@ -0,0 +1,13 @@ +package main + +import ( + "net/http" + + githubapptoken "github.com/shogo82148/actions-github-app-token/provider/github-app-token" +) + +func main() { + h := githubapptoken.NewDummyHandler() + http.Handle("/", h) + http.ListenAndServe(":8080", nil) +} diff --git a/provider/github-app-token/dummy.go b/provider/github-app-token/dummy.go new file mode 100644 index 00000000..299b4cd5 --- /dev/null +++ b/provider/github-app-token/dummy.go @@ -0,0 +1,33 @@ +package githubapptoken + +import ( + "context" + "net/http" + + "github.com/shogo82148/actions-github-app-token/provider/github-app-token/github" +) + +type githubClientDummy struct{} + +func (c *githubClientDummy) CreateStatus(ctx context.Context, token, owner, repo, ref string, status *github.CreateStatusRequest) (*github.CreateStatusResponse, error) { + if token != "ghs_dummyGitHubToken" || owner != "shogo82148" || repo != "actions-aws-assume-role" || ref != "e3a45c6c16c1464826b36a598ff39e6cc98c4da4" { + return nil, &github.UnexpectedStatusCodeError{StatusCode: http.StatusBadRequest} + } + return &github.CreateStatusResponse{ + Creator: &github.CreateStatusResponseCreator{ + Login: "github-actions[bot]", + ID: 41898282, + Type: "Bot", + }, + }, nil +} + +func (c *githubClientDummy) ValidateAPIURL(url string) error { + return nil +} + +func NewDummyHandler() *Handler { + return &Handler{ + github: &githubClientDummy{}, + } +}