-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from gomicro/next-test
next test
- Loading branch information
Showing
121 changed files
with
9,685 additions
and
2,536 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package clienttest | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/gomicro/crawl" | ||
"github.com/google/go-github/github" | ||
) | ||
|
||
type ClientTest struct { | ||
cfg *Config | ||
} | ||
|
||
type Config struct { | ||
BaseBranchName string | ||
Logins []string | ||
LoginsError error | ||
Repos []*github.Repository | ||
ReposError error | ||
ProcessReposError error | ||
} | ||
|
||
func New(cfg *Config) *ClientTest { | ||
return &ClientTest{ | ||
cfg: cfg, | ||
} | ||
} | ||
|
||
func (ct *ClientTest) GetBaseBranchName() string { | ||
if ct.cfg != nil { | ||
return ct.cfg.BaseBranchName | ||
} | ||
|
||
return "" | ||
} | ||
|
||
func (ct *ClientTest) GetLogins(context.Context) ([]string, error) { | ||
if ct.cfg.LoginsError != nil { | ||
return nil, ct.cfg.LoginsError | ||
} | ||
|
||
return ct.cfg.Logins, nil | ||
} | ||
|
||
func (ct *ClientTest) GetRepos(ctx context.Context, progress *crawl.Progress, name string) ([]*github.Repository, error) { | ||
if ct.cfg.ReposError != nil { | ||
return nil, ct.cfg.ReposError | ||
} | ||
|
||
return ct.cfg.Repos, nil | ||
} | ||
|
||
func (ct *ClientTest) ProcessRepos(ctx context.Context, progress *crawl.Progress, repos []*github.Repository, dryRun bool) ([]string, error) { | ||
if ct.cfg.ProcessReposError != nil { | ||
return nil, ct.cfg.ProcessReposError | ||
} | ||
|
||
urls := make([]string, len(ct.cfg.Repos)) | ||
|
||
for i, r := range repos { | ||
name := r.GetName() | ||
owner := r.GetOwner().GetLogin() | ||
head := r.GetDefaultBranch() | ||
|
||
if !dryRun { | ||
urls = append(urls, fmt.Sprintf("https://github.com/%s/%s/pull/%d", owner, name, i)) | ||
continue | ||
} | ||
|
||
urls = append(urls, fmt.Sprintf("https://github.com/%s/%s/compare/%s...%s", owner, name, ct.cfg.BaseBranchName, head)) | ||
} | ||
|
||
return urls, nil | ||
} | ||
|
||
func (ct *ClientTest) ReleaseRepos(ctx context.Context, progress *crawl.Progress, repos []*github.Repository, dryRun bool) ([]string, error) { | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/gomicro/crawl" | ||
"github.com/google/go-github/github" | ||
) | ||
|
||
// interface for a train client | ||
type Clienter interface { | ||
GetBaseBranchName() string | ||
GetLogins(context.Context) ([]string, error) | ||
GetRepos(context.Context, *crawl.Progress, string) ([]*github.Repository, error) | ||
ProcessRepos(context.Context, *crawl.Progress, []*github.Repository, bool) ([]string, error) | ||
ReleaseRepos(context.Context, *crawl.Progress, []*github.Repository, bool) ([]string, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.