func TestClient_NewClient(t *testing.T) { client := issues.NewClient(config) if client == nil { t.Errorf("actual: nil") t.Errorf("expected: not nil") } }
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 } }
// 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 }
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) } }
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) } }
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) } }