示例#1
0
文件: loader_test.go 项目: skhal/gh
func TestClient_NewClient(t *testing.T) {
	client := issues.NewClient(config)
	if client == nil {
		t.Errorf("actual: nil")
		t.Errorf("expected: not nil")
	}
}
示例#2
0
文件: loader_test.go 项目: skhal/gh
func TestClient_Build(t *testing.T) {
	client := issues.NewClient(config)
	if client == nil {
		t.Errorf("actual: nil")
		t.Errorf("expected: not nil")
		return
	}
	_, err := client.Build()
	if err != nil {
		t.Errorf("actual: %s", err)
		t.Errorf("expected: nil")
		return
	}
}
示例#3
0
文件: issues.go 项目: skhal/gh
// RunIssues runs issues command
func RunIssues(args []string) error {
	c := cfg.NewConfig()
	if err := cfg.Load(c); err != nil {
		return err
	}
	client := issues.NewClient(c)
	issues, err := client.Load()
	if err != nil {
		return err
	}
	tmpl := template.Must(template.New("issues").Parse(tmplIssues))
	err = tmpl.Execute(os.Stdout, issues)
	if err != nil {
		return err
	}
	return nil
}
示例#4
0
文件: loader_test.go 项目: skhal/gh
func TestClient_Build_Method(t *testing.T) {
	client := issues.NewClient(config)
	if client == nil {
		t.Errorf("actual: nil")
		t.Errorf("expected: not nil")
		return
	}
	req, err := client.Build()
	if err != nil {
		t.Errorf("actual: %s", err)
		t.Errorf("expected: nil")
		return
	}
	if actual, expected := req.Method, "GET"; expected != actual {
		t.Errorf("actual: %s", actual)
		t.Errorf("expected: %s", expected)
	}
}
示例#5
0
文件: loader_test.go 项目: skhal/gh
func TestClient_Build_URL(t *testing.T) {
	client := issues.NewClient(config)
	if client == nil {
		t.Errorf("actual: nil")
		t.Errorf("expected: not nil")
		return
	}
	req, err := client.Build()
	if err != nil {
		t.Errorf("actual: %s", err)
		t.Errorf("expected: nil")
		return
	}
	u := &url.URL{
		Scheme:   "https",
		Host:     "api.github.com",
		Path:     "/search/issues",
		RawQuery: fmt.Sprintf("q=%s", url.QueryEscape(fmt.Sprintf("repo:%s", config.Repo))),
	}
	if actual, expected := req.URL, u; *expected != *actual {
		t.Errorf("actual: %s", actual)
		t.Errorf("expected: %s", expected)
	}
}
示例#6
0
文件: loader_test.go 项目: skhal/gh
func TestClient_Build_Headers(t *testing.T) {
	client := issues.NewClient(config)
	if client == nil {
		t.Errorf("actual: nil")
		t.Errorf("expected: not nil")
		return
	}
	req, err := client.Build()
	if err != nil {
		t.Errorf("actual: %s", err)
		t.Errorf("expected: nil")
		return
	}
	auth, ok := req.Header["Authorization"]
	if !ok {
		t.Errorf("actual: %s", ok)
		t.Errorf("expected: true")
		return
	}
	if expected, actual := fmt.Sprintf("token %s", config.Token), strings.Join(auth, "|"); expected != actual {
		t.Errorf("actual: %s", actual)
		t.Errorf("expected: %s", expected)
	}
}