Merge pull request #2727 from cristiand391/remove-unused-methods

Remove unused methods
This commit is contained in:
Mislav Marohnić 2021-01-05 15:33:56 +01:00 committed by GitHub
commit ca83106a38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,8 +5,6 @@ import (
"io"
"net/http"
"os"
"path"
"strings"
)
// TODO: clean up methods in this file when there are no more callers
@ -17,22 +15,6 @@ func (r *Registry) StubResponse(status int, body io.Reader) {
})
}
func (r *Registry) StubWithFixture(status int, fixtureFileName string) func() {
fixturePath := path.Join("../test/fixtures/", fixtureFileName)
fixtureFile, err := os.Open(fixturePath)
r.Register(MatchAny, func(req *http.Request) (*http.Response, error) {
if err != nil {
return nil, err
}
return httpResponse(200, req, fixtureFile), nil
})
return func() {
if err == nil {
fixtureFile.Close()
}
}
}
func (r *Registry) StubWithFixturePath(status int, fixturePath string) func() {
fixtureFile, err := os.Open(fixturePath)
r.Register(MatchAny, func(req *http.Request) (*http.Response, error) {
@ -72,14 +54,6 @@ func (r *Registry) StubRepoResponseWithPermission(owner, repo, permission string
r.Register(GraphQL(`query RepositoryNetwork\b`), StringResponse(RepoNetworkStubResponse(owner, repo, "master", permission)))
}
func (r *Registry) StubRepoResponseWithDefaultBranch(owner, repo, defaultBranch string) {
r.Register(GraphQL(`query RepositoryNetwork\b`), StringResponse(RepoNetworkStubResponse(owner, repo, defaultBranch, "WRITE")))
}
func (r *Registry) StubForkedRepoResponse(ownRepo, parentRepo string) {
r.Register(GraphQL(`query RepositoryNetwork\b`), StringResponse(RepoNetworkStubForkResponse(ownRepo, parentRepo)))
}
func RepoNetworkStubResponse(owner, repo, defaultBranch, permission string) string {
return fmt.Sprintf(`
{ "data": { "repo_000": {
@ -93,28 +67,3 @@ func RepoNetworkStubResponse(owner, repo, defaultBranch, permission string) stri
} } }
`, repo, owner, defaultBranch, permission)
}
func RepoNetworkStubForkResponse(forkFullName, parentFullName string) string {
forkRepo := strings.SplitN(forkFullName, "/", 2)
parentRepo := strings.SplitN(parentFullName, "/", 2)
return fmt.Sprintf(`
{ "data": { "repo_000": {
"id": "REPOID2",
"name": "%s",
"owner": {"login": "%s"},
"defaultBranchRef": {
"name": "master"
},
"viewerPermission": "ADMIN",
"parent": {
"id": "REPOID1",
"name": "%s",
"owner": {"login": "%s"},
"defaultBranchRef": {
"name": "master"
},
"viewerPermission": "READ"
}
} } }
`, forkRepo[1], forkRepo[0], parentRepo[1], parentRepo[0])
}