commit
d6c9004d64
15 changed files with 23 additions and 23 deletions
|
|
@ -19,7 +19,7 @@ import (
|
|||
func makeCachedClient(httpClient *http.Client, cacheTTL time.Duration) *http.Client {
|
||||
cacheDir := filepath.Join(os.TempDir(), "gh-cli-cache")
|
||||
return &http.Client{
|
||||
Transport: CacheReponse(cacheTTL, cacheDir)(httpClient.Transport),
|
||||
Transport: CacheResponse(cacheTTL, cacheDir)(httpClient.Transport),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -39,8 +39,8 @@ func isCacheableResponse(res *http.Response) bool {
|
|||
return res.StatusCode < 500 && res.StatusCode != 403
|
||||
}
|
||||
|
||||
// CacheReponse produces a RoundTripper that caches HTTP responses to disk for a specified amount of time
|
||||
func CacheReponse(ttl time.Duration, dir string) ClientOption {
|
||||
// CacheResponse produces a RoundTripper that caches HTTP responses to disk for a specified amount of time
|
||||
func CacheResponse(ttl time.Duration, dir string) ClientOption {
|
||||
fs := fileStorage{
|
||||
dir: dir,
|
||||
ttl: ttl,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func Test_CacheReponse(t *testing.T) {
|
||||
func Test_CacheResponse(t *testing.T) {
|
||||
counter := 0
|
||||
fakeHTTP := funcTripper{
|
||||
roundTrip: func(req *http.Request) (*http.Response, error) {
|
||||
|
|
@ -32,7 +32,7 @@ func Test_CacheReponse(t *testing.T) {
|
|||
}
|
||||
|
||||
cacheDir := filepath.Join(t.TempDir(), "gh-cli-cache")
|
||||
httpClient := NewHTTPClient(ReplaceTripper(fakeHTTP), CacheReponse(time.Minute, cacheDir))
|
||||
httpClient := NewHTTPClient(ReplaceTripper(fakeHTTP), CacheResponse(time.Minute, cacheDir))
|
||||
|
||||
do := func(method, url string, body io.Reader) (string, error) {
|
||||
req, err := http.NewRequest(method, url, body)
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@ func Test_Remotes_FindByName(t *testing.T) {
|
|||
eq(t, err, nil)
|
||||
eq(t, r.Name, "upstream")
|
||||
|
||||
r, err = list.FindByName("nonexist", "*")
|
||||
r, err = list.FindByName("nonexistent", "*")
|
||||
eq(t, err, nil)
|
||||
eq(t, r.Name, "mona")
|
||||
|
||||
_, err = list.FindByName("nonexist")
|
||||
_, err = list.FindByName("nonexistent")
|
||||
eq(t, err, errors.New(`no GitHub remotes found`))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ func Test_sshParse(t *testing.T) {
|
|||
`))
|
||||
eq(t, m["foo"], "example.com")
|
||||
eq(t, m["bar"], "%bar.net%")
|
||||
eq(t, m["nonexist"], "")
|
||||
eq(t, m["nonexistent"], "")
|
||||
}
|
||||
|
||||
func Test_Translator(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ example.com:
|
|||
val, err = config.Get("github.com", "git_protocol")
|
||||
eq(t, err, nil)
|
||||
eq(t, val, "ssh")
|
||||
val, err = config.Get("nonexist.io", "git_protocol")
|
||||
val, err = config.Get("nonexistent.io", "git_protocol")
|
||||
eq(t, err, nil)
|
||||
eq(t, val, "ssh")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ func TestGenManSeeAlso(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestManPrintFlagsHidesShortDeperecated(t *testing.T) {
|
||||
func TestManPrintFlagsHidesShortDeprecated(t *testing.T) {
|
||||
c := &cobra.Command{}
|
||||
c.Flags().StringP("foo", "f", "default", "Foo flag")
|
||||
_ = c.Flags().MarkShorthandDeprecated("foo", "don't use it no more")
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ func Stub() (*CommandStubber, func(T)) {
|
|||
return
|
||||
}
|
||||
t.Helper()
|
||||
t.Errorf("umatched stubs (%d): %s", len(unmatched), strings.Join(unmatched, ", "))
|
||||
t.Errorf("unmatched stubs (%d): %s", len(unmatched), strings.Join(unmatched, ", "))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ func TestIssueCreate_nonLegacyTemplate(t *testing.T) {
|
|||
as, teardown := prompt.InitAskStubber()
|
||||
defer teardown()
|
||||
|
||||
// tmeplate
|
||||
// template
|
||||
as.Stub([]*prompt.QuestionStub{
|
||||
{
|
||||
Name: "index",
|
||||
|
|
|
|||
|
|
@ -93,14 +93,14 @@ func Test_Write(t *testing.T) {
|
|||
{
|
||||
name: "multiple lines removed",
|
||||
input: input{
|
||||
in: []string{"begining line\nremove this whole line\nremove this one also\nnot this one"},
|
||||
in: []string{"beginning line\nremove this whole line\nremove this one also\nnot this one"},
|
||||
re: regexp.MustCompile("(?s)^remove.*$"),
|
||||
repl: "",
|
||||
},
|
||||
output: output{
|
||||
wantsErr: false,
|
||||
out: "begining line\nnot this one",
|
||||
length: 70,
|
||||
out: "beginning line\nnot this one",
|
||||
length: 71,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ func TestPRReview(t *testing.T) {
|
|||
{`--request-changes -b"bad"`, "REQUEST_CHANGES", "bad"},
|
||||
{`--approve`, "APPROVE", ""},
|
||||
{`--approve -b"hot damn"`, "APPROVE", "hot damn"},
|
||||
{`--comment --body "i donno"`, "COMMENT", "i donno"},
|
||||
{`--comment --body "i dunno"`, "COMMENT", "i dunno"},
|
||||
}
|
||||
|
||||
for _, kase := range cases {
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ type reviewerState struct {
|
|||
func formattedReviewerState(cs *iostreams.ColorScheme, reviewer *reviewerState) string {
|
||||
state := reviewer.State
|
||||
if state == dismissedReviewState {
|
||||
// Show "DISMISSED" review as "COMMENTED", since "dimissed" only makes
|
||||
// Show "DISMISSED" review as "COMMENTED", since "dismissed" only makes
|
||||
// sense when displayed in an events timeline but not in the final tally.
|
||||
state = commentedReviewState
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ func Test_RepoCreate(t *testing.T) {
|
|||
reg.StubResponse(200, bytes.NewBufferString(`{}`))
|
||||
|
||||
input := repoCreateInput{
|
||||
Description: "roasted chesnuts",
|
||||
Description: "roasted chestnuts",
|
||||
HomepageURL: "http://example.com",
|
||||
}
|
||||
|
||||
|
|
@ -39,8 +39,8 @@ func Test_RepoCreate(t *testing.T) {
|
|||
|
||||
bodyBytes, _ := ioutil.ReadAll(reg.Requests[0].Body)
|
||||
_ = json.Unmarshal(bodyBytes, &reqBody)
|
||||
if description := reqBody.Variables.Input["description"].(string); description != "roasted chesnuts" {
|
||||
t.Errorf("expected description to be %q, got %q", "roasted chesnuts", description)
|
||||
if description := reqBody.Variables.Input["description"].(string); description != "roasted chestnuts" {
|
||||
t.Errorf("expected description to be %q, got %q", "roasted chestnuts", description)
|
||||
}
|
||||
if homepage := reqBody.Variables.Input["homepageUrl"].(string); homepage != "http://example.com" {
|
||||
t.Errorf("expected homepageUrl to be %q, got %q", "http://example.com", homepage)
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ func gardenRun(opts *GardenOptions) error {
|
|||
oldTTYCommand := exec.Command("stty", sttyFileArg, "/dev/tty", "-g")
|
||||
oldTTYSettings, err := oldTTYCommand.CombinedOutput()
|
||||
if err != nil {
|
||||
fmt.Fprintln(out, "getting TTY setings failed:", string(oldTTYSettings))
|
||||
fmt.Fprintln(out, "getting TTY settings failed:", string(oldTTYSettings))
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ func rootUsageFunc(command *cobra.Command) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func rootFlagErrrorFunc(cmd *cobra.Command, err error) error {
|
||||
func rootFlagErrorFunc(cmd *cobra.Command, err error) error {
|
||||
if err == pflag.ErrHelp {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ func NewCmdRoot(f *cmdutil.Factory, version, buildDate string) *cobra.Command {
|
|||
cmd.PersistentFlags().Bool("help", false, "Show help for command")
|
||||
cmd.SetHelpFunc(helpHelper)
|
||||
cmd.SetUsageFunc(rootUsageFunc)
|
||||
cmd.SetFlagErrorFunc(rootFlagErrrorFunc)
|
||||
cmd.SetFlagErrorFunc(rootFlagErrorFunc)
|
||||
|
||||
formattedVersion := versionCmd.Format(version, buildDate)
|
||||
cmd.SetVersionTemplate(formattedVersion)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue