{"modulePath":"github.com/mrz1836/nilbox","version":"v0.8.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package githubtest\n\nPackage githubtest holds the fakes of internal/github that the test suites share: a token source that never reaches GitHub, the bookkeeping of a fake GitHub's requests, and GitHub's refusal of a token. internal/testutil cannot hold them, as internal/github imports it. Only tests may import this package.\n\n## Constants\n\n```go\nconst Token = \"test-token-not-real\"\n```\nToken is the token a Tokens lends when it was given none: it never reaches GitHub.\n\n## Functions\n\n```go\nfunc BadCredentials() error\n```\nBadCredentials is GitHub refusing the token.\n\n## Types\n\n```go\ntype Calls struct {\n\t// contains filtered or unexported fields\n}\n```\nCalls counts a fake GitHub's requests by name and keeps their order. Its zero value is ready to use, and it is safe for concurrent use.\n\n```go\nfunc (c *Calls) Add(name string)\n```\nAdd records a request named name.\n\n```go\nfunc (c *Calls) Count(name string) int\n```\nCount returns how many requests named name were made.\n\n```go\nfunc (c *Calls) Len() int\n```\nLen returns how many requests were made, whatever their names.\n\n```go\nfunc (c *Calls) Since(names ...string) []string\n```\nSince names the requests made after the last one named any of names, in order: every request when none of names was made.\n\n```go\ntype Tokens struct {\n\t// contains filtered or unexported fields\n}\n```\nTokens is a token source that lends tokens in turn and records the ones it is told to forget. It is safe for concurrent use; a test reads it with Loans and Forgot once the calls it made have returned.\n\n```go\nfunc FailingTokens(errs []error, values ...string) *Tokens\n```\nFailingTokens returns Tokens whose loans fail in turn with errs, a nil error lending values as NewTokens does, and every loan after the last of errs lending a token.\n\n```go\nfunc NewTokens(values ...string) *Tokens\n```\nNewTokens returns Tokens that lend values in turn, the last of them again once the rest are lent, or Token when there are none.\n\n```go\nfunc (f *Tokens) Fail(err error)\n```\nFail makes every loan from now on fail with err, or lend again for nil.\n\n```go\nfunc (f *Tokens) Forget(tok github.Token)\n```\nForget records tok as given back, as GitHub refused it.\n\n```go\nfunc (f *Tokens) Forgot() []string\n```\nForgot returns the tokens given back, in order.\n\n```go\nfunc (f *Tokens) Loans() int\n```\nLoans returns how many tokens were asked for, the failed loans among them.\n\n```go\nfunc (f *Tokens) Swap(value string)\n```\nSwap lends value from now on, as gh auth switch does.\n\n```go\nfunc (f *Tokens) Token(ctx context.Context) (github.Token, error)\n```\nToken lends the next token. A loan counts even when it fails: on a context that is done, with its error; with the loan's own error from FailingTokens; or with the error Fail set.\n\n","path":"github.com/mrz1836/nilbox/internal/github/githubtest","name":"githubtest","synopsis":"Package githubtest holds the fakes of internal/github that the test suites share: a token source that never reaches GitHub, the bookkeeping of a fake GitHub's requests, and GitHub's refusal of a token.","isRedistributable":true}
