search

package
v2.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindRepositories = "repositories"
	KindIssues       = "issues"
)

Variables

View Source
var IssueFields = []string{
	"assignees",
	"author",
	"authorAssociation",
	"body",
	"closedAt",
	"commentsCount",
	"createdAt",
	"id",
	"isLocked",
	"isPullRequest",
	"labels",
	"number",
	"repository",
	"state",
	"title",
	"updatedAt",
	"url",
}
View Source
var RepositoryFields = []string{
	"createdAt",
	"defaultBranch",
	"description",
	"forksCount",
	"fullName",
	"hasDownloads",
	"hasIssues",
	"hasPages",
	"hasProjects",
	"hasWiki",
	"homepage",
	"id",
	"isArchived",
	"isDisabled",
	"isFork",
	"isPrivate",
	"language",
	"license",
	"name",
	"openIssuesCount",
	"owner",
	"pushedAt",
	"size",
	"stargazersCount",
	"updatedAt",
	"url",
	"visibility",
	"watchersCount",
}

Functions

This section is empty.

Types

type Issue added in v2.7.0

type Issue struct {
	Assignees         []User           `json:"assignees"`
	Author            User             `json:"user"`
	AuthorAssociation string           `json:"author_association"`
	Body              string           `json:"body"`
	ClosedAt          time.Time        `json:"closed_at"`
	CommentsCount     int              `json:"comments"`
	CreatedAt         time.Time        `json:"created_at"`
	ID                string           `json:"node_id"`
	Labels            []Label          `json:"labels"`
	IsLocked          bool             `json:"locked"`
	Number            int              `json:"number"`
	PullRequestLinks  PullRequestLinks `json:"pull_request"`
	RepositoryURL     string           `json:"repository_url"`
	State             string           `json:"state"`
	StateReason       string           `json:"state_reason"`
	Title             string           `json:"title"`
	URL               string           `json:"html_url"`
	UpdatedAt         time.Time        `json:"updated_at"`
}

func (Issue) ExportData added in v2.7.0

func (issue Issue) ExportData(fields []string) map[string]interface{}

func (Issue) IsPullRequest added in v2.7.0

func (issue Issue) IsPullRequest() bool

type IssuesResult added in v2.7.0

type IssuesResult struct {
	IncompleteResults bool    `json:"incomplete_results"`
	Items             []Issue `json:"items"`
	Total             int     `json:"total_count"`
}

type Label added in v2.7.0

type Label struct {
	Color       string `json:"color"`
	Description string `json:"description"`
	ID          string `json:"node_id"`
	Name        string `json:"name"`
}

type License

type License struct {
	Key  string `json:"key"`
	Name string `json:"name"`
	URL  string `json:"url"`
}
type PullRequestLinks struct {
	URL string `json:"html_url"`
}

type Qualifiers

type Qualifiers struct {
	Archived            *bool
	Assignee            string
	Author              string
	Base                string
	Closed              string
	Commenter           string
	Comments            string
	Created             string
	Draft               *bool
	Followers           string
	Fork                string
	Forks               string
	GoodFirstIssues     string
	Head                string
	HelpWantedIssues    string
	In                  []string
	Interactions        string
	Involves            string
	Is                  []string
	Label               []string
	Language            string
	License             []string
	Mentions            string
	Merged              string
	Milestone           string
	No                  []string
	Project             string
	Pushed              string
	Reactions           string
	Repo                []string
	Review              string
	ReviewRequested     string
	ReviewedBy          string
	Size                string
	Stars               string
	State               string
	Status              string
	Team                string
	TeamReviewRequested string
	Topic               []string
	Topics              string
	Type                string
	Updated             string
	User                string
}

func (Qualifiers) Map

func (q Qualifiers) Map() map[string][]string

type Query

type Query struct {
	Keywords   []string
	Kind       string
	Limit      int
	Order      string
	Page       int
	Qualifiers Qualifiers
	Sort       string
}

func (Query) String

func (q Query) String() string

type RepositoriesResult

type RepositoriesResult struct {
	IncompleteResults bool         `json:"incomplete_results"`
	Items             []Repository `json:"items"`
	Total             int          `json:"total_count"`
}

type Repository

type Repository struct {
	CreatedAt       time.Time `json:"created_at"`
	DefaultBranch   string    `json:"default_branch"`
	Description     string    `json:"description"`
	ForksCount      int       `json:"forks_count"`
	FullName        string    `json:"full_name"`
	HasDownloads    bool      `json:"has_downloads"`
	HasIssues       bool      `json:"has_issues"`
	HasPages        bool      `json:"has_pages"`
	HasProjects     bool      `json:"has_projects"`
	HasWiki         bool      `json:"has_wiki"`
	Homepage        string    `json:"homepage"`
	ID              string    `json:"node_id"`
	IsArchived      bool      `json:"archived"`
	IsDisabled      bool      `json:"disabled"`
	IsFork          bool      `json:"fork"`
	IsPrivate       bool      `json:"private"`
	Language        string    `json:"language"`
	License         License   `json:"license"`
	MasterBranch    string    `json:"master_branch"`
	Name            string    `json:"name"`
	OpenIssuesCount int       `json:"open_issues_count"`
	Owner           User      `json:"owner"`
	PushedAt        time.Time `json:"pushed_at"`
	Size            int       `json:"size"`
	StargazersCount int       `json:"stargazers_count"`
	URL             string    `json:"html_url"`
	UpdatedAt       time.Time `json:"updated_at"`
	Visibility      string    `json:"visibility"`
	WatchersCount   int       `json:"watchers_count"`
}

func (Repository) ExportData

func (repo Repository) ExportData(fields []string) map[string]interface{}

type Searcher

type Searcher interface {
	Repositories(Query) (RepositoriesResult, error)
	Issues(Query) (IssuesResult, error)
	URL(Query) string
}

func NewSearcher

func NewSearcher(client *http.Client, host string) Searcher

type SearcherMock

type SearcherMock struct {
	// IssuesFunc mocks the Issues method.
	IssuesFunc func(query Query) (IssuesResult, error)

	// RepositoriesFunc mocks the Repositories method.
	RepositoriesFunc func(query Query) (RepositoriesResult, error)

	// URLFunc mocks the URL method.
	URLFunc func(query Query) string
	// contains filtered or unexported fields
}

SearcherMock is a mock implementation of Searcher.

func TestSomethingThatUsesSearcher(t *testing.T) {

	// make and configure a mocked Searcher
	mockedSearcher := &SearcherMock{
		IssuesFunc: func(query Query) (IssuesResult, error) {
			panic("mock out the Issues method")
		},
		RepositoriesFunc: func(query Query) (RepositoriesResult, error) {
			panic("mock out the Repositories method")
		},
		URLFunc: func(query Query) string {
			panic("mock out the URL method")
		},
	}

	// use mockedSearcher in code that requires Searcher
	// and then make assertions.

}

func (*SearcherMock) Issues added in v2.7.0

func (mock *SearcherMock) Issues(query Query) (IssuesResult, error)

Issues calls IssuesFunc.

func (*SearcherMock) IssuesCalls added in v2.7.0

func (mock *SearcherMock) IssuesCalls() []struct {
	Query Query
}

IssuesCalls gets all the calls that were made to Issues. Check the length with:

len(mockedSearcher.IssuesCalls())

func (*SearcherMock) Repositories

func (mock *SearcherMock) Repositories(query Query) (RepositoriesResult, error)

Repositories calls RepositoriesFunc.

func (*SearcherMock) RepositoriesCalls

func (mock *SearcherMock) RepositoriesCalls() []struct {
	Query Query
}

RepositoriesCalls gets all the calls that were made to Repositories. Check the length with:

len(mockedSearcher.RepositoriesCalls())

func (*SearcherMock) URL

func (mock *SearcherMock) URL(query Query) string

URL calls URLFunc.

func (*SearcherMock) URLCalls

func (mock *SearcherMock) URLCalls() []struct {
	Query Query
}

URLCalls gets all the calls that were made to URL. Check the length with:

len(mockedSearcher.URLCalls())

type User

type User struct {
	GravatarID string `json:"gravatar_id"`
	ID         string `json:"node_id"`
	Login      string `json:"login"`
	SiteAdmin  bool   `json:"site_admin"`
	Type       string `json:"type"`
	URL        string `json:"html_url"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL