Skip to content

Commit

Permalink
Merge pull request #9 from shogo82148/add-dummy-provider-for-testing
Browse files Browse the repository at this point in the history
add dummy provider for testing
  • Loading branch information
shogo82148 authored Sep 2, 2021
2 parents 4c7c9d9 + ba920f9 commit b31ae49
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
13 changes: 13 additions & 0 deletions provider/github-app-token/cmd/dummy/main.go
Original file line number Diff line number Diff line change
@@ -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)
}
33 changes: 33 additions & 0 deletions provider/github-app-token/dummy.go
Original file line number Diff line number Diff line change
@@ -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{},
}
}

0 comments on commit b31ae49

Please sign in to comment.