Browse Source

move examples to github_test package in examples_test.go

See #367 for discussion.

Change-Id: I10e26bddebeea2a1485fc4389caab1ff12421382
Glenn Lewis 10 years ago
parent
commit
e1bc3a7920
5 changed files with 75 additions and 60 deletions
  1. +75
    -0
      github/examples_test.go
  2. +0
    -14
      github/misc_test.go
  3. +0
    -18
      github/repos_contents_test.go
  4. +0
    -14
      github/repos_test.go
  5. +0
    -14
      github/users.go

+ 75
- 0
github/examples_test.go View File

@ -0,0 +1,75 @@
// Copyright 2016 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package github_test
import (
"fmt"
"log"
"github.com/google/go-github/github"
)
func ExampleClient_Markdown() {
client := github.NewClient(nil)
input := "# heading #\n\nLink to issue #1"
opt := &github.MarkdownOptions{Mode: "gfm", Context: "google/go-github"}
output, _, err := client.Markdown(input, opt)
if err != nil {
fmt.Println(err)
}
fmt.Println(output)
}
func ExampleRepositoriesService_GetReadme() {
client := github.NewClient(nil)
readme, _, err := client.Repositories.GetReadme("google", "go-github", nil)
if err != nil {
fmt.Println(err)
return
}
content, err := readme.GetContent()
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("google/go-github README:\n%v\n", content)
}
func ExampleRepositoriesService_List() {
client := github.NewClient(nil)
user := "willnorris"
opt := &github.RepositoryListOptions{Type: "owner", Sort: "updated", Direction: "desc"}
repos, _, err := client.Repositories.List(user, opt)
if err != nil {
fmt.Println(err)
}
fmt.Printf("Recently updated repositories by %q: %v", user, github.Stringify(repos))
}
func ExampleUsersService_ListAll() {
client := github.NewClient(nil)
opts := &github.UserListOptions{}
for {
users, _, err := client.Users.ListAll(opts)
if err != nil {
log.Fatalf("error listing users: %v", err)
}
if len(users) == 0 {
break
}
opts.Since = *users[len(users)-1].ID
// Process users...
}
}

+ 0
- 14
github/misc_test.go View File

@ -46,20 +46,6 @@ func TestMarkdown(t *testing.T) {
}
}
func ExampleClient_Markdown() {
client := NewClient(nil)
input := "# heading #\n\nLink to issue #1"
opt := &MarkdownOptions{Mode: "gfm", Context: "google/go-github"}
output, _, err := client.Markdown(input, opt)
if err != nil {
fmt.Println(err)
}
fmt.Println(output)
}
func TestListEmojis(t *testing.T) {
setup()
defer teardown()


+ 0
- 18
github/repos_contents_test.go View File

@ -119,24 +119,6 @@ func TestRepositoriesService_GetReadme(t *testing.T) {
}
}
func ExampleRepositoriesService_GetReadme() {
client := NewClient(nil)
readme, _, err := client.Repositories.GetReadme("google", "go-github", nil)
if err != nil {
fmt.Println(err)
return
}
content, err := readme.GetContent()
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("google/go-github README:\n%v\n", content)
}
func TestRepositoriesService_DownloadContents_Success(t *testing.T) {
setup()
defer teardown()


+ 0
- 14
github/repos_test.go View File

@ -67,20 +67,6 @@ func TestRepositoriesService_List_invalidUser(t *testing.T) {
testURLParseError(t, err)
}
func ExampleRepositoriesService_List() {
client := NewClient(nil)
user := "willnorris"
opt := &RepositoryListOptions{Type: "owner", Sort: "updated", Direction: "desc"}
repos, _, err := client.Repositories.List(user, opt)
if err != nil {
fmt.Println(err)
}
fmt.Printf("Recently updated repositories by %q: %v", user, Stringify(repos))
}
func TestRepositoriesService_ListByOrg(t *testing.T) {
setup()
defer teardown()


+ 0
- 14
github/users.go View File

@ -145,20 +145,6 @@ type UserListOptions struct {
// ListAll lists all GitHub users.
//
// To paginate through all users, populate 'Since' with the ID of the last user.
// Example (warning: this will quickly eat through your GitHub API quota!):
//
// opts := &github.UserListOptions{}
// for {
// users, _, err := client.Users.ListAll(opts)
// if err != nil {
// log.Fatalf("error listing users: %v", err)
// }
// if len(users) == 0 {
// break
// }
// opts.Since = *users[len(users)-1].ID
// // Process users...
// }
//
// GitHub API docs: http://developer.github.com/v3/users/#get-all-users
func (s *UsersService) ListAll(opt *UserListOptions) ([]User, *Response, error) {


Loading…
Cancel
Save