forked from cli/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.go
More file actions
50 lines (40 loc) · 895 Bytes
/
testing.go
File metadata and controls
50 lines (40 loc) · 895 Bytes
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
package command
import (
"errors"
"github.com/github/gh-cli/api"
"github.com/github/gh-cli/context"
)
func initBlankContext(repo, branch string) {
initContext = func() context.Context {
ctx := context.NewBlank()
ctx.SetBaseRepo(repo)
ctx.SetBranch(branch)
return ctx
}
}
func initFakeHTTP() *api.FakeHTTP {
http := &api.FakeHTTP{}
apiClientForContext = func(context.Context) (*api.Client, error) {
return api.NewClient(api.ReplaceTripper(http)), nil
}
return http
}
// outputStub implements a simple utils.Runnable
type outputStub struct {
output []byte
}
func (s outputStub) Output() ([]byte, error) {
return s.output, nil
}
func (s outputStub) Run() error {
return nil
}
type errorStub struct {
message string
}
func (s errorStub) Output() ([]byte, error) {
return nil, errors.New(s.message)
}
func (s errorStub) Run() error {
return errors.New(s.message)
}