| 1 | package github |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "encoding/json" |
| 6 | "net/http" |
| 7 | "testing" |
| 8 | |
| 9 | "github.com/mmcloughlin/avo/internal/test" |
| 10 | ) |
| 11 | |
| 12 | func TestClientRepository(t *testing.T) { |
| 13 | test.RequiresNetwork(t) |
| 14 | |
| 15 | ctx := context.Background() |
| 16 | g := NewClient(WithHTTPClient(http.DefaultClient), WithTokenFromEnvironment()) |
| 17 | r, err := g.Repository(ctx, "golang", "go") |
| 18 | if err != nil { |
| 19 | t.Fatal(err) |
| 20 | } |
| 21 | |
| 22 | j, err := json.MarshalIndent(r, "", "\t") |
| 23 | if err != nil { |
| 24 | t.Fatal(err) |
| 25 | } |
| 26 | t.Logf("repository = %s", j) |
| 27 | } |
| 28 | |
| 29 | func TestClientIssue(t *testing.T) { |
| 30 | test.RequiresNetwork(t) |
| 31 | |
| 32 | ctx := context.Background() |
| 33 | g := NewClient(WithHTTPClient(http.DefaultClient), WithTokenFromEnvironment()) |
| 34 | r, err := g.Issue(ctx, "octocat", "hello-world", 42) |
| 35 | if err != nil { |
| 36 | t.Fatal(err) |
| 37 | } |
| 38 | |
| 39 | j, err := json.MarshalIndent(r, "", "\t") |
| 40 | if err != nil { |
| 41 | t.Fatal(err) |
| 42 | } |
| 43 | t.Logf("issue = %s", j) |
| 44 | } |