3Q5g4j^?s7o37R>_YkNa#}U{$JoeZ>+1qZr6(hsLQg{L+1WcA)7St+Fj!2&Q~
z7yu4D_#JSU{H(#kXoE}{96EJIML4leU%3c
z0T~DxfMoF15I|di&t=vec9tV0)v7p73a`HUvH%ec4~oi#K8jx@h5-sC;0yN
zzyDOD(fAI;Kwj#W!_*27EFm2UIARdEbMN#+JD!}q66%>4Mqe|1m+BY5gII@;H+EL7Y))AU39kt-fl3#
zT2Fw>11G{ueDy|Y>l|VWqiPtsqM+*rffZOZgp)ssZQ*K!5bc
zZz62vw^O~o~cUVIcs)f=&OaKLSe-
zi9ry6m-Th8TmG&eHF-C(-^)3-e4YRneIrRhP)UHSbKD_<&ulXRSnjV20|Z}!NHZG)
z7_(f_1`6aiGvJM3OYdMfz2W`aI^#+nx>>HDs_z80U@kE1upp<1oB|;GY3jmVuw1*E
zDW3xdPkQt@0EfPtmP^;0CagF9?>Bi*Z}KMgRZ+07*qoM6N<$
Ef{+FK(*OVf
diff --git a/vendor/github.com/elazarl/goproxy/transport/roundtripper.go b/vendor/github.com/elazarl/goproxy/transport/roundtripper.go
deleted file mode 100644
index 3651ad86..00000000
--- a/vendor/github.com/elazarl/goproxy/transport/roundtripper.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package transport
-import "net/http"
-type RoundTripper interface {
- // RoundTrip executes a single HTTP transaction, returning
- // the Response for the request req. RoundTrip should not
- // attempt to interpret the response. In particular,
- // RoundTrip must return err == nil if it obtained a response,
- // regardless of the response's HTTP status code. A non-nil
- // err should be reserved for failure to obtain a response.
- // Similarly, RoundTrip should not attempt to handle
- // higher-level protocol details such as redirects,
- // authentication, or cookies.
- //
- // RoundTrip should not modify the request, except for
- // consuming the Body. The request's URL and Header fields
- // are guaranteed to be initialized.
- RoundTrip(*http.Request) (*http.Response, error)
- DetailedRoundTrip(*http.Request) (*RoundTripDetails, *http.Response, error)
-}
diff --git a/vendor/github.com/elazarl/goproxy/transport/transport.go b/vendor/github.com/elazarl/goproxy/transport/transport.go
deleted file mode 100644
index fc1c82b1..00000000
--- a/vendor/github.com/elazarl/goproxy/transport/transport.go
+++ /dev/null
@@ -1,789 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// HTTP client implementation. See RFC 2616.
-//
-// This is the low-level Transport implementation of RoundTripper.
-// The high-level interface is in client.go.
-
-// This file is DEPRECATED and keep solely for backward compatibility.
-
-package transport
-
-import (
- "net/http"
- "bufio"
- "compress/gzip"
- "crypto/tls"
- "encoding/base64"
- "errors"
- "fmt"
- "io"
- "io/ioutil"
- "log"
- "net"
- "net/url"
- "os"
- "strings"
- "sync"
-)
-
-// DefaultTransport is the default implementation of Transport and is
-// used by DefaultClient. It establishes a new network connection for
-// each call to Do and uses HTTP proxies as directed by the
-// $HTTP_PROXY and $NO_PROXY (or $http_proxy and $no_proxy)
-// environment variables.
-var DefaultTransport RoundTripper = &Transport{Proxy: ProxyFromEnvironment}
-
-// DefaultMaxIdleConnsPerHost is the default value of Transport's
-// MaxIdleConnsPerHost.
-const DefaultMaxIdleConnsPerHost = 2
-
-// Transport is an implementation of RoundTripper that supports http,
-// https, and http proxies (for either http or https with CONNECT).
-// Transport can also cache connections for future re-use.
-type Transport struct {
- lk sync.Mutex
- idleConn map[string][]*persistConn
- altProto map[string]RoundTripper // nil or map of URI scheme => RoundTripper
-
- // TODO: tunable on global max cached connections
- // TODO: tunable on timeout on cached connections
- // TODO: optional pipelining
-
- // Proxy specifies a function to return a proxy for a given
- // Request. If the function returns a non-nil error, the
- // request is aborted with the provided error.
- // If Proxy is nil or returns a nil *URL, no proxy is used.
- Proxy func(*http.Request) (*url.URL, error)
-
- // Dial specifies the dial function for creating TCP
- // connections.
- // If Dial is nil, net.Dial is used.
- Dial func(net, addr string) (c net.Conn, err error)
-
- // TLSClientConfig specifies the TLS configuration to use with
- // tls.Client. If nil, the default configuration is used.
- TLSClientConfig *tls.Config
-
- DisableKeepAlives bool
- DisableCompression bool
-
- // MaxIdleConnsPerHost, if non-zero, controls the maximum idle
- // (keep-alive) to keep to keep per-host. If zero,
- // DefaultMaxIdleConnsPerHost is used.
- MaxIdleConnsPerHost int
-}
-
-// ProxyFromEnvironment returns the URL of the proxy to use for a
-// given request, as indicated by the environment variables
-// $HTTP_PROXY and $NO_PROXY (or $http_proxy and $no_proxy).
-// An error is returned if the proxy environment is invalid.
-// A nil URL and nil error are returned if no proxy is defined in the
-// environment, or a proxy should not be used for the given request.
-func ProxyFromEnvironment(req *http.Request) (*url.URL, error) {
- proxy := getenvEitherCase("HTTP_PROXY")
- if proxy == "" {
- return nil, nil
- }
- if !useProxy(canonicalAddr(req.URL)) {
- return nil, nil
- }
- proxyURL, err := url.Parse(proxy)
- if err != nil || proxyURL.Scheme == "" {
- if u, err := url.Parse("http://" + proxy); err == nil {
- proxyURL = u
- err = nil
- }
- }
- if err != nil {
- return nil, fmt.Errorf("invalid proxy address %q: %v", proxy, err)
- }
- return proxyURL, nil
-}
-
-// ProxyURL returns a proxy function (for use in a Transport)
-// that always returns the same URL.
-func ProxyURL(fixedURL *url.URL) func(*http.Request) (*url.URL, error) {
- return func(*http.Request) (*url.URL, error) {
- return fixedURL, nil
- }
-}
-
-// transportRequest is a wrapper around a *Request that adds
-// optional extra headers to write.
-type transportRequest struct {
- *http.Request // original request, not to be mutated
- extra http.Header // extra headers to write, or nil
-}
-
-func (tr *transportRequest) extraHeaders() http.Header {
- if tr.extra == nil {
- tr.extra = make(http.Header)
- }
- return tr.extra
-}
-
-type RoundTripDetails struct {
- Host string
- TCPAddr *net.TCPAddr
- IsProxy bool
- Error error
-}
-
-func (t *Transport) DetailedRoundTrip(req *http.Request) (details *RoundTripDetails, resp *http.Response, err error) {
- if req.URL == nil {
- return nil, nil, errors.New("http: nil Request.URL")
- }
- if req.Header == nil {
- return nil, nil, errors.New("http: nil Request.Header")
- }
- if req.URL.Scheme != "http" && req.URL.Scheme != "https" {
- t.lk.Lock()
- var rt RoundTripper
- if t.altProto != nil {
- rt = t.altProto[req.URL.Scheme]
- }
- t.lk.Unlock()
- if rt == nil {
- return nil, nil, &badStringError{"unsupported protocol scheme", req.URL.Scheme}
- }
- return rt.DetailedRoundTrip(req)
- }
- treq := &transportRequest{Request: req}
- cm, err := t.connectMethodForRequest(treq)
- if err != nil {
- return nil, nil, err
- }
-
- // Get the cached or newly-created connection to either the
- // host (for http or https), the http proxy, or the http proxy
- // pre-CONNECTed to https server. In any case, we'll be ready
- // to send it requests.
- pconn, err := t.getConn(cm)
- if err != nil {
- return nil, nil, err
- }
-
- resp, err = pconn.roundTrip(treq)
- return &RoundTripDetails{pconn.host, pconn.ip, pconn.isProxy, err}, resp, err
-}
-
-// RoundTrip implements the RoundTripper interface.
-func (t *Transport) RoundTrip(req *http.Request) (resp *http.Response, err error) {
- _, resp, err = t.DetailedRoundTrip(req)
- return
-}
-
-// RegisterProtocol registers a new protocol with scheme.
-// The Transport will pass requests using the given scheme to rt.
-// It is rt's responsibility to simulate HTTP request semantics.
-//
-// RegisterProtocol can be used by other packages to provide
-// implementations of protocol schemes like "ftp" or "file".
-func (t *Transport) RegisterProtocol(scheme string, rt RoundTripper) {
- if scheme == "http" || scheme == "https" {
- panic("protocol " + scheme + " already registered")
- }
- t.lk.Lock()
- defer t.lk.Unlock()
- if t.altProto == nil {
- t.altProto = make(map[string]RoundTripper)
- }
- if _, exists := t.altProto[scheme]; exists {
- panic("protocol " + scheme + " already registered")
- }
- t.altProto[scheme] = rt
-}
-
-// CloseIdleConnections closes any connections which were previously
-// connected from previous requests but are now sitting idle in
-// a "keep-alive" state. It does not interrupt any connections currently
-// in use.
-func (t *Transport) CloseIdleConnections() {
- t.lk.Lock()
- defer t.lk.Unlock()
- if t.idleConn == nil {
- return
- }
- for _, conns := range t.idleConn {
- for _, pconn := range conns {
- pconn.close()
- }
- }
- t.idleConn = make(map[string][]*persistConn)
-}
-
-//
-// Private implementation past this point.
-//
-
-func getenvEitherCase(k string) string {
- if v := os.Getenv(strings.ToUpper(k)); v != "" {
- return v
- }
- return os.Getenv(strings.ToLower(k))
-}
-
-func (t *Transport) connectMethodForRequest(treq *transportRequest) (*connectMethod, error) {
- cm := &connectMethod{
- targetScheme: treq.URL.Scheme,
- targetAddr: canonicalAddr(treq.URL),
- }
- if t.Proxy != nil {
- var err error
- cm.proxyURL, err = t.Proxy(treq.Request)
- if err != nil {
- return nil, err
- }
- }
- return cm, nil
-}
-
-// proxyAuth returns the Proxy-Authorization header to set
-// on requests, if applicable.
-func (cm *connectMethod) proxyAuth() string {
- if cm.proxyURL == nil {
- return ""
- }
- if u := cm.proxyURL.User; u != nil {
- return "Basic " + base64.URLEncoding.EncodeToString([]byte(u.String()))
- }
- return ""
-}
-
-// putIdleConn adds pconn to the list of idle persistent connections awaiting
-// a new request.
-// If pconn is no longer needed or not in a good state, putIdleConn
-// returns false.
-func (t *Transport) putIdleConn(pconn *persistConn) bool {
- t.lk.Lock()
- defer t.lk.Unlock()
- if t.DisableKeepAlives || t.MaxIdleConnsPerHost < 0 {
- pconn.close()
- return false
- }
- if pconn.isBroken() {
- return false
- }
- key := pconn.cacheKey
- max := t.MaxIdleConnsPerHost
- if max == 0 {
- max = DefaultMaxIdleConnsPerHost
- }
- if len(t.idleConn[key]) >= max {
- pconn.close()
- return false
- }
- t.idleConn[key] = append(t.idleConn[key], pconn)
- return true
-}
-
-func (t *Transport) getIdleConn(cm *connectMethod) (pconn *persistConn) {
- t.lk.Lock()
- defer t.lk.Unlock()
- if t.idleConn == nil {
- t.idleConn = make(map[string][]*persistConn)
- }
- key := cm.String()
- for {
- pconns, ok := t.idleConn[key]
- if !ok {
- return nil
- }
- if len(pconns) == 1 {
- pconn = pconns[0]
- delete(t.idleConn, key)
- } else {
- // 2 or more cached connections; pop last
- // TODO: queue?
- pconn = pconns[len(pconns)-1]
- t.idleConn[key] = pconns[0 : len(pconns)-1]
- }
- if !pconn.isBroken() {
- return
- }
- }
- return
-}
-
-func (t *Transport) dial(network, addr string) (c net.Conn, raddr string, ip *net.TCPAddr, err error) {
- if t.Dial != nil {
- ip, err = net.ResolveTCPAddr("tcp", addr)
- if err!=nil {
- return
- }
- c, err = t.Dial(network, addr)
- raddr = addr
- return
- }
- addri, err := net.ResolveTCPAddr("tcp", addr)
- if err!=nil {
- return
- }
- c, err = net.DialTCP("tcp", nil, addri)
- raddr = addr
- ip = addri
- return
-}
-
-// getConn dials and creates a new persistConn to the target as
-// specified in the connectMethod. This includes doing a proxy CONNECT
-// and/or setting up TLS. If this doesn't return an error, the persistConn
-// is ready to write requests to.
-func (t *Transport) getConn(cm *connectMethod) (*persistConn, error) {
- if pc := t.getIdleConn(cm); pc != nil {
- return pc, nil
- }
-
- conn, raddr, ip, err := t.dial("tcp", cm.addr())
- if err != nil {
- if cm.proxyURL != nil {
- err = fmt.Errorf("http: error connecting to proxy %s: %v", cm.proxyURL, err)
- }
- return nil, err
- }
-
- pa := cm.proxyAuth()
-
- pconn := &persistConn{
- t: t,
- cacheKey: cm.String(),
- conn: conn,
- reqch: make(chan requestAndChan, 50),
- host: raddr,
- ip: ip,
- }
-
- switch {
- case cm.proxyURL == nil:
- // Do nothing.
- case cm.targetScheme == "http":
- pconn.isProxy = true
- if pa != "" {
- pconn.mutateHeaderFunc = func(h http.Header) {
- h.Set("Proxy-Authorization", pa)
- }
- }
- case cm.targetScheme == "https":
- connectReq := &http.Request{
- Method: "CONNECT",
- URL: &url.URL{Opaque: cm.targetAddr},
- Host: cm.targetAddr,
- Header: make(http.Header),
- }
- if pa != "" {
- connectReq.Header.Set("Proxy-Authorization", pa)
- }
- connectReq.Write(conn)
-
- // Read response.
- // Okay to use and discard buffered reader here, because
- // TLS server will not speak until spoken to.
- br := bufio.NewReader(conn)
- resp, err := http.ReadResponse(br, connectReq)
- if err != nil {
- conn.Close()
- return nil, err
- }
- if resp.StatusCode != 200 {
- f := strings.SplitN(resp.Status, " ", 2)
- conn.Close()
- return nil, errors.New(f[1])
- }
- }
-
- if cm.targetScheme == "https" {
- // Initiate TLS and check remote host name against certificate.
- conn = tls.Client(conn, t.TLSClientConfig)
- if err = conn.(*tls.Conn).Handshake(); err != nil {
- return nil, err
- }
- if t.TLSClientConfig == nil || !t.TLSClientConfig.InsecureSkipVerify {
- if err = conn.(*tls.Conn).VerifyHostname(cm.tlsHost()); err != nil {
- return nil, err
- }
- }
- pconn.conn = conn
- }
-
- pconn.br = bufio.NewReader(pconn.conn)
- pconn.bw = bufio.NewWriter(pconn.conn)
- go pconn.readLoop()
- return pconn, nil
-}
-
-// useProxy returns true if requests to addr should use a proxy,
-// according to the NO_PROXY or no_proxy environment variable.
-// addr is always a canonicalAddr with a host and port.
-func useProxy(addr string) bool {
- if len(addr) == 0 {
- return true
- }
- host, _, err := net.SplitHostPort(addr)
- if err != nil {
- return false
- }
- if host == "localhost" {
- return false
- }
- if ip := net.ParseIP(host); ip != nil {
- if ip.IsLoopback() {
- return false
- }
- }
-
- no_proxy := getenvEitherCase("NO_PROXY")
- if no_proxy == "*" {
- return false
- }
-
- addr = strings.ToLower(strings.TrimSpace(addr))
- if hasPort(addr) {
- addr = addr[:strings.LastIndex(addr, ":")]
- }
-
- for _, p := range strings.Split(no_proxy, ",") {
- p = strings.ToLower(strings.TrimSpace(p))
- if len(p) == 0 {
- continue
- }
- if hasPort(p) {
- p = p[:strings.LastIndex(p, ":")]
- }
- if addr == p || (p[0] == '.' && (strings.HasSuffix(addr, p) || addr == p[1:])) {
- return false
- }
- }
- return true
-}
-
-// connectMethod is the map key (in its String form) for keeping persistent
-// TCP connections alive for subsequent HTTP requests.
-//
-// A connect method may be of the following types:
-//
-// Cache key form Description
-// ----------------- -------------------------
-// ||http|foo.com http directly to server, no proxy
-// ||https|foo.com https directly to server, no proxy
-// http://proxy.com|https|foo.com http to proxy, then CONNECT to foo.com
-// http://proxy.com|http http to proxy, http to anywhere after that
-//
-// Note: no support to https to the proxy yet.
-//
-type connectMethod struct {
- proxyURL *url.URL // nil for no proxy, else full proxy URL
- targetScheme string // "http" or "https"
- targetAddr string // Not used if proxy + http targetScheme (4th example in table)
-}
-
-func (ck *connectMethod) String() string {
- proxyStr := ""
- if ck.proxyURL != nil {
- proxyStr = ck.proxyURL.String()
- }
- return strings.Join([]string{proxyStr, ck.targetScheme, ck.targetAddr}, "|")
-}
-
-// addr returns the first hop "host:port" to which we need to TCP connect.
-func (cm *connectMethod) addr() string {
- if cm.proxyURL != nil {
- return canonicalAddr(cm.proxyURL)
- }
- return cm.targetAddr
-}
-
-// tlsHost returns the host name to match against the peer's
-// TLS certificate.
-func (cm *connectMethod) tlsHost() string {
- h := cm.targetAddr
- if hasPort(h) {
- h = h[:strings.LastIndex(h, ":")]
- }
- return h
-}
-
-// persistConn wraps a connection, usually a persistent one
-// (but may be used for non-keep-alive requests as well)
-type persistConn struct {
- t *Transport
- cacheKey string // its connectMethod.String()
- conn net.Conn
- br *bufio.Reader // from conn
- bw *bufio.Writer // to conn
- reqch chan requestAndChan // written by roundTrip(); read by readLoop()
- isProxy bool
-
- // mutateHeaderFunc is an optional func to modify extra
- // headers on each outbound request before it's written. (the
- // original Request given to RoundTrip is not modified)
- mutateHeaderFunc func(http.Header)
-
- lk sync.Mutex // guards numExpectedResponses and broken
- numExpectedResponses int
- broken bool // an error has happened on this connection; marked broken so it's not reused.
-
- host string
- ip *net.TCPAddr
-}
-
-func (pc *persistConn) isBroken() bool {
- pc.lk.Lock()
- defer pc.lk.Unlock()
- return pc.broken
-}
-
-var remoteSideClosedFunc func(error) bool // or nil to use default
-
-func remoteSideClosed(err error) bool {
- if err == io.EOF {
- return true
- }
- if remoteSideClosedFunc != nil {
- return remoteSideClosedFunc(err)
- }
- return false
-}
-
-func (pc *persistConn) readLoop() {
- alive := true
- var lastbody io.ReadCloser // last response body, if any, read on this connection
-
- for alive {
- pb, err := pc.br.Peek(1)
-
- pc.lk.Lock()
- if pc.numExpectedResponses == 0 {
- pc.closeLocked()
- pc.lk.Unlock()
- if len(pb) > 0 {
- log.Printf("Unsolicited response received on idle HTTP channel starting with %q; err=%v",
- string(pb), err)
- }
- return
- }
- pc.lk.Unlock()
-
- rc := <-pc.reqch
-
- // Advance past the previous response's body, if the
- // caller hasn't done so.
- if lastbody != nil {
- lastbody.Close() // assumed idempotent
- lastbody = nil
- }
- resp, err := http.ReadResponse(pc.br, rc.req)
-
- if err != nil {
- pc.close()
- } else {
- hasBody := rc.req.Method != "HEAD" && resp.ContentLength != 0
- if rc.addedGzip && hasBody && resp.Header.Get("Content-Encoding") == "gzip" {
- resp.Header.Del("Content-Encoding")
- resp.Header.Del("Content-Length")
- resp.ContentLength = -1
- gzReader, zerr := gzip.NewReader(resp.Body)
- if zerr != nil {
- pc.close()
- err = zerr
- } else {
- resp.Body = &readFirstCloseBoth{&discardOnCloseReadCloser{gzReader}, resp.Body}
- }
- }
- resp.Body = &bodyEOFSignal{body: resp.Body}
- }
-
- if err != nil || resp.Close || rc.req.Close {
- alive = false
- }
-
- hasBody := resp != nil && resp.ContentLength != 0
- var waitForBodyRead chan bool
- if alive {
- if hasBody {
- lastbody = resp.Body
- waitForBodyRead = make(chan bool)
- resp.Body.(*bodyEOFSignal).fn = func() {
- if !pc.t.putIdleConn(pc) {
- alive = false
- }
- waitForBodyRead <- true
- }
- } else {
- // When there's no response body, we immediately
- // reuse the TCP connection (putIdleConn), but
- // we need to prevent ClientConn.Read from
- // closing the Response.Body on the next
- // loop, otherwise it might close the body
- // before the client code has had a chance to
- // read it (even though it'll just be 0, EOF).
- lastbody = nil
-
- if !pc.t.putIdleConn(pc) {
- alive = false
- }
- }
- }
-
- rc.ch <- responseAndError{resp, err}
-
- // Wait for the just-returned response body to be fully consumed
- // before we race and peek on the underlying bufio reader.
- if waitForBodyRead != nil {
- <-waitForBodyRead
- }
- }
-}
-
-type responseAndError struct {
- res *http.Response
- err error
-}
-
-type requestAndChan struct {
- req *http.Request
- ch chan responseAndError
-
- // did the Transport (as opposed to the client code) add an
- // Accept-Encoding gzip header? only if it we set it do
- // we transparently decode the gzip.
- addedGzip bool
-}
-
-func (pc *persistConn) roundTrip(req *transportRequest) (resp *http.Response, err error) {
- if pc.mutateHeaderFunc != nil {
- panic("mutateHeaderFunc not supported in modified Transport")
- pc.mutateHeaderFunc(req.extraHeaders())
- }
-
- // Ask for a compressed version if the caller didn't set their
- // own value for Accept-Encoding. We only attempted to
- // uncompress the gzip stream if we were the layer that
- // requested it.
- requestedGzip := false
- if !pc.t.DisableCompression && req.Header.Get("Accept-Encoding") == "" {
- // Request gzip only, not deflate. Deflate is ambiguous and
- // not as universally supported anyway.
- // See: http://www.gzip.org/zlib/zlib_faq.html#faq38
- requestedGzip = true
- req.extraHeaders().Set("Accept-Encoding", "gzip")
- }
-
- pc.lk.Lock()
- pc.numExpectedResponses++
- pc.lk.Unlock()
-
- // orig: err = req.Request.write(pc.bw, pc.isProxy, req.extra)
- if pc.isProxy {
- err = req.Request.WriteProxy(pc.bw)
- } else {
- err = req.Request.Write(pc.bw)
- }
- if err != nil {
- pc.close()
- return
- }
- pc.bw.Flush()
-
- ch := make(chan responseAndError, 1)
- pc.reqch <- requestAndChan{req.Request, ch, requestedGzip}
- re := <-ch
- pc.lk.Lock()
- pc.numExpectedResponses--
- pc.lk.Unlock()
-
- return re.res, re.err
-}
-
-func (pc *persistConn) close() {
- pc.lk.Lock()
- defer pc.lk.Unlock()
- pc.closeLocked()
-}
-
-func (pc *persistConn) closeLocked() {
- pc.broken = true
- pc.conn.Close()
- pc.mutateHeaderFunc = nil
-}
-
-var portMap = map[string]string{
- "http": "80",
- "https": "443",
-}
-
-// canonicalAddr returns url.Host but always with a ":port" suffix
-func canonicalAddr(url *url.URL) string {
- addr := url.Host
- if !hasPort(addr) {
- return addr + ":" + portMap[url.Scheme]
- }
- return addr
-}
-
-func responseIsKeepAlive(res *http.Response) bool {
- // TODO: implement. for now just always shutting down the connection.
- return false
-}
-
-// bodyEOFSignal wraps a ReadCloser but runs fn (if non-nil) at most
-// once, right before the final Read() or Close() call returns, but after
-// EOF has been seen.
-type bodyEOFSignal struct {
- body io.ReadCloser
- fn func()
- isClosed bool
-}
-
-func (es *bodyEOFSignal) Read(p []byte) (n int, err error) {
- n, err = es.body.Read(p)
- if es.isClosed && n > 0 {
- panic("http: unexpected bodyEOFSignal Read after Close; see issue 1725")
- }
- if err == io.EOF && es.fn != nil {
- es.fn()
- es.fn = nil
- }
- return
-}
-
-func (es *bodyEOFSignal) Close() (err error) {
- if es.isClosed {
- return nil
- }
- es.isClosed = true
- err = es.body.Close()
- if err == nil && es.fn != nil {
- es.fn()
- es.fn = nil
- }
- return
-}
-
-type readFirstCloseBoth struct {
- io.ReadCloser
- io.Closer
-}
-
-func (r *readFirstCloseBoth) Close() error {
- if err := r.ReadCloser.Close(); err != nil {
- r.Closer.Close()
- return err
- }
- if err := r.Closer.Close(); err != nil {
- return err
- }
- return nil
-}
-
-// discardOnCloseReadCloser consumes all its input on Close.
-type discardOnCloseReadCloser struct {
- io.ReadCloser
-}
-
-func (d *discardOnCloseReadCloser) Close() error {
- io.Copy(ioutil.Discard, d.ReadCloser) // ignore errors; likely invalid or already closed
- return d.ReadCloser.Close()
-}
diff --git a/vendor/github.com/elazarl/goproxy/transport/util.go b/vendor/github.com/elazarl/goproxy/transport/util.go
deleted file mode 100644
index af0eda1e..00000000
--- a/vendor/github.com/elazarl/goproxy/transport/util.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package transport
-
-import (
- "fmt"
- "strings"
-)
-
-type badStringError struct {
- what string
- str string
-}
-
-func (e *badStringError) Error() string { return fmt.Sprintf("%s %q", e.what, e.str) }
-
-func hasPort(s string) bool { return strings.LastIndex(s, ":") > strings.LastIndex(s, "]") }
diff --git a/vendor/github.com/gobwas/glob/cmd/globdraw/main.go b/vendor/github.com/gobwas/glob/cmd/globdraw/main.go
deleted file mode 100644
index 585880db..00000000
--- a/vendor/github.com/gobwas/glob/cmd/globdraw/main.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package main
-
-import (
- "flag"
- "fmt"
- "github.com/gobwas/glob"
- "github.com/gobwas/glob/match"
- "github.com/gobwas/glob/match/debug"
- "os"
- "strings"
- "unicode/utf8"
-)
-
-func main() {
- pattern := flag.String("p", "", "pattern to draw")
- sep := flag.String("s", "", "comma separated list of separators characters")
- flag.Parse()
-
- if *pattern == "" {
- flag.Usage()
- os.Exit(1)
- }
-
- var separators []rune
- if len(*sep) > 0 {
- for _, c := range strings.Split(*sep, ",") {
- if r, w := utf8.DecodeRuneInString(c); len(c) > w {
- fmt.Println("only single charactered separators are allowed")
- os.Exit(1)
- } else {
- separators = append(separators, r)
- }
- }
- }
-
- glob, err := glob.Compile(*pattern, separators...)
- if err != nil {
- fmt.Println("could not compile pattern:", err)
- os.Exit(1)
- }
-
- matcher := glob.(match.Matcher)
- fmt.Fprint(os.Stdout, debug.Graphviz(*pattern, matcher))
-}
diff --git a/vendor/github.com/gobwas/glob/cmd/globtest/main.go b/vendor/github.com/gobwas/glob/cmd/globtest/main.go
deleted file mode 100644
index 95c102f7..00000000
--- a/vendor/github.com/gobwas/glob/cmd/globtest/main.go
+++ /dev/null
@@ -1,82 +0,0 @@
-package main
-
-import (
- "flag"
- "fmt"
- "github.com/gobwas/glob"
- "os"
- "strings"
- "testing"
- "unicode/utf8"
-)
-
-func benchString(r testing.BenchmarkResult) string {
- nsop := r.NsPerOp()
- ns := fmt.Sprintf("%10d ns/op", nsop)
- allocs := "0"
- if r.N > 0 {
- if nsop < 100 {
- // The format specifiers here make sure that
- // the ones digits line up for all three possible formats.
- if nsop < 10 {
- ns = fmt.Sprintf("%13.2f ns/op", float64(r.T.Nanoseconds())/float64(r.N))
- } else {
- ns = fmt.Sprintf("%12.1f ns/op", float64(r.T.Nanoseconds())/float64(r.N))
- }
- }
-
- allocs = fmt.Sprintf("%d", r.MemAllocs/uint64(r.N))
- }
-
- return fmt.Sprintf("%8d\t%s\t%s allocs", r.N, ns, allocs)
-}
-
-func main() {
- pattern := flag.String("p", "", "pattern to draw")
- sep := flag.String("s", "", "comma separated list of separators")
- fixture := flag.String("f", "", "fixture")
- verbose := flag.Bool("v", false, "verbose")
- flag.Parse()
-
- if *pattern == "" {
- flag.Usage()
- os.Exit(1)
- }
-
- var separators []rune
- for _, c := range strings.Split(*sep, ",") {
- if r, w := utf8.DecodeRuneInString(c); len(c) > w {
- fmt.Println("only single charactered separators are allowed")
- os.Exit(1)
- } else {
- separators = append(separators, r)
- }
- }
-
- g, err := glob.Compile(*pattern, separators...)
- if err != nil {
- fmt.Println("could not compile pattern:", err)
- os.Exit(1)
- }
-
- if !*verbose {
- fmt.Println(g.Match(*fixture))
- return
- }
-
- fmt.Printf("result: %t\n", g.Match(*fixture))
-
- cb := testing.Benchmark(func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- glob.Compile(*pattern, separators...)
- }
- })
- fmt.Println("compile:", benchString(cb))
-
- mb := testing.Benchmark(func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- g.Match(*fixture)
- }
- })
- fmt.Println("match: ", benchString(mb))
-}
diff --git a/vendor/github.com/gobwas/glob/compiler/compiler_test.go b/vendor/github.com/gobwas/glob/compiler/compiler_test.go
deleted file mode 100644
index b58b1ebc..00000000
--- a/vendor/github.com/gobwas/glob/compiler/compiler_test.go
+++ /dev/null
@@ -1,624 +0,0 @@
-package compiler
-
-import (
- "github.com/gobwas/glob/match"
- "github.com/gobwas/glob/match/debug"
- "github.com/gobwas/glob/syntax/ast"
- "reflect"
- "testing"
-)
-
-var separators = []rune{'.'}
-
-func TestCommonChildren(t *testing.T) {
- for i, test := range []struct {
- nodes []*ast.Node
- left []*ast.Node
- right []*ast.Node
- }{
- {
- nodes: []*ast.Node{
- ast.NewNode(ast.KindNothing, nil,
- ast.NewNode(ast.KindText, ast.Text{"a"}),
- ast.NewNode(ast.KindText, ast.Text{"z"}),
- ast.NewNode(ast.KindText, ast.Text{"c"}),
- ),
- },
- },
- {
- nodes: []*ast.Node{
- ast.NewNode(ast.KindNothing, nil,
- ast.NewNode(ast.KindText, ast.Text{"a"}),
- ast.NewNode(ast.KindText, ast.Text{"z"}),
- ast.NewNode(ast.KindText, ast.Text{"c"}),
- ),
- ast.NewNode(ast.KindNothing, nil,
- ast.NewNode(ast.KindText, ast.Text{"a"}),
- ast.NewNode(ast.KindText, ast.Text{"b"}),
- ast.NewNode(ast.KindText, ast.Text{"c"}),
- ),
- },
- left: []*ast.Node{
- ast.NewNode(ast.KindText, ast.Text{"a"}),
- },
- right: []*ast.Node{
- ast.NewNode(ast.KindText, ast.Text{"c"}),
- },
- },
- {
- nodes: []*ast.Node{
- ast.NewNode(ast.KindNothing, nil,
- ast.NewNode(ast.KindText, ast.Text{"a"}),
- ast.NewNode(ast.KindText, ast.Text{"b"}),
- ast.NewNode(ast.KindText, ast.Text{"c"}),
- ast.NewNode(ast.KindText, ast.Text{"d"}),
- ),
- ast.NewNode(ast.KindNothing, nil,
- ast.NewNode(ast.KindText, ast.Text{"a"}),
- ast.NewNode(ast.KindText, ast.Text{"b"}),
- ast.NewNode(ast.KindText, ast.Text{"c"}),
- ast.NewNode(ast.KindText, ast.Text{"c"}),
- ast.NewNode(ast.KindText, ast.Text{"d"}),
- ),
- },
- left: []*ast.Node{
- ast.NewNode(ast.KindText, ast.Text{"a"}),
- ast.NewNode(ast.KindText, ast.Text{"b"}),
- },
- right: []*ast.Node{
- ast.NewNode(ast.KindText, ast.Text{"c"}),
- ast.NewNode(ast.KindText, ast.Text{"d"}),
- },
- },
- {
- nodes: []*ast.Node{
- ast.NewNode(ast.KindNothing, nil,
- ast.NewNode(ast.KindText, ast.Text{"a"}),
- ast.NewNode(ast.KindText, ast.Text{"b"}),
- ast.NewNode(ast.KindText, ast.Text{"c"}),
- ),
- ast.NewNode(ast.KindNothing, nil,
- ast.NewNode(ast.KindText, ast.Text{"a"}),
- ast.NewNode(ast.KindText, ast.Text{"b"}),
- ast.NewNode(ast.KindText, ast.Text{"b"}),
- ast.NewNode(ast.KindText, ast.Text{"c"}),
- ),
- },
- left: []*ast.Node{
- ast.NewNode(ast.KindText, ast.Text{"a"}),
- ast.NewNode(ast.KindText, ast.Text{"b"}),
- },
- right: []*ast.Node{
- ast.NewNode(ast.KindText, ast.Text{"c"}),
- },
- },
- {
- nodes: []*ast.Node{
- ast.NewNode(ast.KindNothing, nil,
- ast.NewNode(ast.KindText, ast.Text{"a"}),
- ast.NewNode(ast.KindText, ast.Text{"d"}),
- ),
- ast.NewNode(ast.KindNothing, nil,
- ast.NewNode(ast.KindText, ast.Text{"a"}),
- ast.NewNode(ast.KindText, ast.Text{"d"}),
- ),
- ast.NewNode(ast.KindNothing, nil,
- ast.NewNode(ast.KindText, ast.Text{"a"}),
- ast.NewNode(ast.KindText, ast.Text{"e"}),
- ),
- },
- left: []*ast.Node{
- ast.NewNode(ast.KindText, ast.Text{"a"}),
- },
- right: []*ast.Node{},
- },
- } {
- left, right := commonChildren(test.nodes)
- if !nodesEqual(left, test.left) {
- t.Errorf("[%d] left, right := commonChildren(); left = %v; want %v", i, left, test.left)
- }
- if !nodesEqual(right, test.right) {
- t.Errorf("[%d] left, right := commonChildren(); right = %v; want %v", i, right, test.right)
- }
- }
-}
-
-func nodesEqual(a, b []*ast.Node) bool {
- if len(a) != len(b) {
- return false
- }
- for i, av := range a {
- if !av.Equal(b[i]) {
- return false
- }
- }
- return true
-}
-
-func TestGlueMatchers(t *testing.T) {
- for id, test := range []struct {
- in []match.Matcher
- exp match.Matcher
- }{
- {
- []match.Matcher{
- match.NewSuper(),
- match.NewSingle(nil),
- },
- match.NewMin(1),
- },
- {
- []match.Matcher{
- match.NewAny(separators),
- match.NewSingle(separators),
- },
- match.EveryOf{match.Matchers{
- match.NewMin(1),
- match.NewContains(string(separators), true),
- }},
- },
- {
- []match.Matcher{
- match.NewSingle(nil),
- match.NewSingle(nil),
- match.NewSingle(nil),
- },
- match.EveryOf{match.Matchers{
- match.NewMin(3),
- match.NewMax(3),
- }},
- },
- {
- []match.Matcher{
- match.NewList([]rune{'a'}, true),
- match.NewAny([]rune{'a'}),
- },
- match.EveryOf{match.Matchers{
- match.NewMin(1),
- match.NewContains("a", true),
- }},
- },
- } {
- act, err := compileMatchers(test.in)
- if err != nil {
- t.Errorf("#%d convert matchers error: %s", id, err)
- continue
- }
-
- if !reflect.DeepEqual(act, test.exp) {
- t.Errorf("#%d unexpected convert matchers result:\nact: %#v;\nexp: %#v", id, act, test.exp)
- continue
- }
- }
-}
-
-func TestCompileMatchers(t *testing.T) {
- for id, test := range []struct {
- in []match.Matcher
- exp match.Matcher
- }{
- {
- []match.Matcher{
- match.NewSuper(),
- match.NewSingle(separators),
- match.NewText("c"),
- },
- match.NewBTree(
- match.NewText("c"),
- match.NewBTree(
- match.NewSingle(separators),
- match.NewSuper(),
- nil,
- ),
- nil,
- ),
- },
- {
- []match.Matcher{
- match.NewAny(nil),
- match.NewText("c"),
- match.NewAny(nil),
- },
- match.NewBTree(
- match.NewText("c"),
- match.NewAny(nil),
- match.NewAny(nil),
- ),
- },
- {
- []match.Matcher{
- match.NewRange('a', 'c', true),
- match.NewList([]rune{'z', 't', 'e'}, false),
- match.NewText("c"),
- match.NewSingle(nil),
- },
- match.NewRow(
- 4,
- match.Matchers{
- match.NewRange('a', 'c', true),
- match.NewList([]rune{'z', 't', 'e'}, false),
- match.NewText("c"),
- match.NewSingle(nil),
- }...,
- ),
- },
- } {
- act, err := compileMatchers(test.in)
- if err != nil {
- t.Errorf("#%d convert matchers error: %s", id, err)
- continue
- }
-
- if !reflect.DeepEqual(act, test.exp) {
- t.Errorf("#%d unexpected convert matchers result:\nact: %#v\nexp: %#v", id, act, test.exp)
- continue
- }
- }
-}
-
-func TestConvertMatchers(t *testing.T) {
- for id, test := range []struct {
- in, exp []match.Matcher
- }{
- {
- []match.Matcher{
- match.NewRange('a', 'c', true),
- match.NewList([]rune{'z', 't', 'e'}, false),
- match.NewText("c"),
- match.NewSingle(nil),
- match.NewAny(nil),
- },
- []match.Matcher{
- match.NewRow(
- 4,
- []match.Matcher{
- match.NewRange('a', 'c', true),
- match.NewList([]rune{'z', 't', 'e'}, false),
- match.NewText("c"),
- match.NewSingle(nil),
- }...,
- ),
- match.NewAny(nil),
- },
- },
- {
- []match.Matcher{
- match.NewRange('a', 'c', true),
- match.NewList([]rune{'z', 't', 'e'}, false),
- match.NewText("c"),
- match.NewSingle(nil),
- match.NewAny(nil),
- match.NewSingle(nil),
- match.NewSingle(nil),
- match.NewAny(nil),
- },
- []match.Matcher{
- match.NewRow(
- 3,
- match.Matchers{
- match.NewRange('a', 'c', true),
- match.NewList([]rune{'z', 't', 'e'}, false),
- match.NewText("c"),
- }...,
- ),
- match.NewMin(3),
- },
- },
- } {
- act := minimizeMatchers(test.in)
- if !reflect.DeepEqual(act, test.exp) {
- t.Errorf("#%d unexpected convert matchers 2 result:\nact: %#v\nexp: %#v", id, act, test.exp)
- continue
- }
- }
-}
-
-func TestCompiler(t *testing.T) {
- for id, test := range []struct {
- ast *ast.Node
- result match.Matcher
- sep []rune
- }{
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ),
- result: match.NewText("abc"),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindAny, nil),
- ),
- sep: separators,
- result: match.NewAny(separators),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindAny, nil),
- ),
- result: match.NewSuper(),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindSuper, nil),
- ),
- result: match.NewSuper(),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindSingle, nil),
- ),
- sep: separators,
- result: match.NewSingle(separators),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindRange, ast.Range{
- Lo: 'a',
- Hi: 'z',
- Not: true,
- }),
- ),
- result: match.NewRange('a', 'z', true),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindList, ast.List{
- Chars: "abc",
- Not: true,
- }),
- ),
- result: match.NewList([]rune{'a', 'b', 'c'}, true),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindAny, nil),
- ast.NewNode(ast.KindSingle, nil),
- ast.NewNode(ast.KindSingle, nil),
- ast.NewNode(ast.KindSingle, nil),
- ),
- sep: separators,
- result: match.EveryOf{Matchers: match.Matchers{
- match.NewMin(3),
- match.NewContains(string(separators), true),
- }},
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindAny, nil),
- ast.NewNode(ast.KindSingle, nil),
- ast.NewNode(ast.KindSingle, nil),
- ast.NewNode(ast.KindSingle, nil),
- ),
- result: match.NewMin(3),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindAny, nil),
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ast.NewNode(ast.KindSingle, nil),
- ),
- sep: separators,
- result: match.NewBTree(
- match.NewRow(
- 4,
- match.Matchers{
- match.NewText("abc"),
- match.NewSingle(separators),
- }...,
- ),
- match.NewAny(separators),
- nil,
- ),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindText, ast.Text{"/"}),
- ast.NewNode(ast.KindAnyOf, nil,
- ast.NewNode(ast.KindText, ast.Text{"z"}),
- ast.NewNode(ast.KindText, ast.Text{"ab"}),
- ),
- ast.NewNode(ast.KindSuper, nil),
- ),
- sep: separators,
- result: match.NewBTree(
- match.NewText("/"),
- nil,
- match.NewBTree(
- match.NewAnyOf(match.NewText("z"), match.NewText("ab")),
- nil,
- match.NewSuper(),
- ),
- ),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindSuper, nil),
- ast.NewNode(ast.KindSingle, nil),
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ast.NewNode(ast.KindSingle, nil),
- ),
- sep: separators,
- result: match.NewBTree(
- match.NewRow(
- 5,
- match.Matchers{
- match.NewSingle(separators),
- match.NewText("abc"),
- match.NewSingle(separators),
- }...,
- ),
- match.NewSuper(),
- nil,
- ),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindAny, nil),
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ),
- result: match.NewSuffix("abc"),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ast.NewNode(ast.KindAny, nil),
- ),
- result: match.NewPrefix("abc"),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ast.NewNode(ast.KindAny, nil),
- ast.NewNode(ast.KindText, ast.Text{"def"}),
- ),
- result: match.NewPrefixSuffix("abc", "def"),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindAny, nil),
- ast.NewNode(ast.KindAny, nil),
- ast.NewNode(ast.KindAny, nil),
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ast.NewNode(ast.KindAny, nil),
- ast.NewNode(ast.KindAny, nil),
- ),
- result: match.NewContains("abc", false),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindAny, nil),
- ast.NewNode(ast.KindAny, nil),
- ast.NewNode(ast.KindAny, nil),
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ast.NewNode(ast.KindAny, nil),
- ast.NewNode(ast.KindAny, nil),
- ),
- sep: separators,
- result: match.NewBTree(
- match.NewText("abc"),
- match.NewAny(separators),
- match.NewAny(separators),
- ),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindSuper, nil),
- ast.NewNode(ast.KindSingle, nil),
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ast.NewNode(ast.KindSuper, nil),
- ast.NewNode(ast.KindSingle, nil),
- ),
- result: match.NewBTree(
- match.NewText("abc"),
- match.NewMin(1),
- match.NewMin(1),
- ),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ),
- result: match.NewText("abc"),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindAnyOf, nil,
- ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindAnyOf, nil,
- ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ),
- ),
- ),
- ),
- ),
- result: match.NewText("abc"),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindAnyOf, nil,
- ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ast.NewNode(ast.KindSingle, nil),
- ),
- ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ast.NewNode(ast.KindList, ast.List{Chars: "def"}),
- ),
- ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ),
- ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ),
- ),
- ),
- result: match.NewBTree(
- match.NewText("abc"),
- nil,
- match.AnyOf{Matchers: match.Matchers{
- match.NewSingle(nil),
- match.NewList([]rune{'d', 'e', 'f'}, false),
- match.NewNothing(),
- }},
- ),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindRange, ast.Range{Lo: 'a', Hi: 'z'}),
- ast.NewNode(ast.KindRange, ast.Range{Lo: 'a', Hi: 'x', Not: true}),
- ast.NewNode(ast.KindAny, nil),
- ),
- result: match.NewBTree(
- match.NewRow(
- 2,
- match.Matchers{
- match.NewRange('a', 'z', false),
- match.NewRange('a', 'x', true),
- }...,
- ),
- nil,
- match.NewSuper(),
- ),
- },
- {
- ast: ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindAnyOf, nil,
- ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ast.NewNode(ast.KindList, ast.List{Chars: "abc"}),
- ast.NewNode(ast.KindText, ast.Text{"ghi"}),
- ),
- ast.NewNode(ast.KindPattern, nil,
- ast.NewNode(ast.KindText, ast.Text{"abc"}),
- ast.NewNode(ast.KindList, ast.List{Chars: "def"}),
- ast.NewNode(ast.KindText, ast.Text{"ghi"}),
- ),
- ),
- ),
- result: match.NewRow(
- 7,
- match.Matchers{
- match.NewText("abc"),
- match.AnyOf{Matchers: match.Matchers{
- match.NewList([]rune{'a', 'b', 'c'}, false),
- match.NewList([]rune{'d', 'e', 'f'}, false),
- }},
- match.NewText("ghi"),
- }...,
- ),
- },
- } {
- m, err := Compile(test.ast, test.sep)
- if err != nil {
- t.Errorf("compilation error: %s", err)
- continue
- }
-
- if !reflect.DeepEqual(m, test.result) {
- t.Errorf("[%d] Compile():\nexp: %#v\nact: %#v\n\ngraphviz:\nexp:\n%s\nact:\n%s\n", id, test.result, m, debug.Graphviz("", test.result.(match.Matcher)), debug.Graphviz("", m.(match.Matcher)))
- continue
- }
- }
-}
diff --git a/vendor/github.com/gobwas/glob/glob_test.go b/vendor/github.com/gobwas/glob/glob_test.go
deleted file mode 100644
index 810036fa..00000000
--- a/vendor/github.com/gobwas/glob/glob_test.go
+++ /dev/null
@@ -1,531 +0,0 @@
-package glob
-
-import (
- "regexp"
- "testing"
-)
-
-const (
- pattern_all = "[a-z][!a-x]*cat*[h][!b]*eyes*"
- regexp_all = `^[a-z][^a-x].*cat.*[h][^b].*eyes.*$`
- fixture_all_match = "my cat has very bright eyes"
- fixture_all_mismatch = "my dog has very bright eyes"
-
- pattern_plain = "google.com"
- regexp_plain = `^google\.com$`
- fixture_plain_match = "google.com"
- fixture_plain_mismatch = "gobwas.com"
-
- pattern_multiple = "https://*.google.*"
- regexp_multiple = `^https:\/\/.*\.google\..*$`
- fixture_multiple_match = "https://account.google.com"
- fixture_multiple_mismatch = "https://google.com"
-
- pattern_alternatives = "{https://*.google.*,*yandex.*,*yahoo.*,*mail.ru}"
- regexp_alternatives = `^(https:\/\/.*\.google\..*|.*yandex\..*|.*yahoo\..*|.*mail\.ru)$`
- fixture_alternatives_match = "http://yahoo.com"
- fixture_alternatives_mismatch = "http://google.com"
-
- pattern_alternatives_suffix = "{https://*gobwas.com,http://exclude.gobwas.com}"
- regexp_alternatives_suffix = `^(https:\/\/.*gobwas\.com|http://exclude.gobwas.com)$`
- fixture_alternatives_suffix_first_match = "https://safe.gobwas.com"
- fixture_alternatives_suffix_first_mismatch = "http://safe.gobwas.com"
- fixture_alternatives_suffix_second = "http://exclude.gobwas.com"
-
- pattern_prefix = "abc*"
- regexp_prefix = `^abc.*$`
- pattern_suffix = "*def"
- regexp_suffix = `^.*def$`
- pattern_prefix_suffix = "ab*ef"
- regexp_prefix_suffix = `^ab.*ef$`
- fixture_prefix_suffix_match = "abcdef"
- fixture_prefix_suffix_mismatch = "af"
-
- pattern_alternatives_combine_lite = "{abc*def,abc?def,abc[zte]def}"
- regexp_alternatives_combine_lite = `^(abc.*def|abc.def|abc[zte]def)$`
- fixture_alternatives_combine_lite = "abczdef"
-
- pattern_alternatives_combine_hard = "{abc*[a-c]def,abc?[d-g]def,abc[zte]?def}"
- regexp_alternatives_combine_hard = `^(abc.*[a-c]def|abc.[d-g]def|abc[zte].def)$`
- fixture_alternatives_combine_hard = "abczqdef"
-)
-
-type test struct {
- pattern, match string
- should bool
- delimiters []rune
-}
-
-func glob(s bool, p, m string, d ...rune) test {
- return test{p, m, s, d}
-}
-
-func TestGlob(t *testing.T) {
- for _, test := range []test{
- glob(true, "* ?at * eyes", "my cat has very bright eyes"),
-
- glob(true, "", ""),
- glob(false, "", "b"),
-
- glob(true, "*ä", "åä"),
- glob(true, "abc", "abc"),
- glob(true, "a*c", "abc"),
- glob(true, "a*c", "a12345c"),
- glob(true, "a?c", "a1c"),
- glob(true, "a.b", "a.b", '.'),
- glob(true, "a.*", "a.b", '.'),
- glob(true, "a.**", "a.b.c", '.'),
- glob(true, "a.?.c", "a.b.c", '.'),
- glob(true, "a.?.?", "a.b.c", '.'),
- glob(true, "?at", "cat"),
- glob(true, "?at", "fat"),
- glob(true, "*", "abc"),
- glob(true, `\*`, "*"),
- glob(true, "**", "a.b.c", '.'),
-
- glob(false, "?at", "at"),
- glob(false, "?at", "fat", 'f'),
- glob(false, "a.*", "a.b.c", '.'),
- glob(false, "a.?.c", "a.bb.c", '.'),
- glob(false, "*", "a.b.c", '.'),
-
- glob(true, "*test", "this is a test"),
- glob(true, "this*", "this is a test"),
- glob(true, "*is *", "this is a test"),
- glob(true, "*is*a*", "this is a test"),
- glob(true, "**test**", "this is a test"),
- glob(true, "**is**a***test*", "this is a test"),
-
- glob(false, "*is", "this is a test"),
- glob(false, "*no*", "this is a test"),
- glob(true, "[!a]*", "this is a test3"),
-
- glob(true, "*abc", "abcabc"),
- glob(true, "**abc", "abcabc"),
- glob(true, "???", "abc"),
- glob(true, "?*?", "abc"),
- glob(true, "?*?", "ac"),
- glob(false, "sta", "stagnation"),
- glob(true, "sta*", "stagnation"),
- glob(false, "sta?", "stagnation"),
- glob(false, "sta?n", "stagnation"),
-
- glob(true, "{abc,def}ghi", "defghi"),
- glob(true, "{abc,abcd}a", "abcda"),
- glob(true, "{a,ab}{bc,f}", "abc"),
- glob(true, "{*,**}{a,b}", "ab"),
- glob(false, "{*,**}{a,b}", "ac"),
-
- glob(true, "/{rate,[a-z][a-z][a-z]}*", "/rate"),
- glob(true, "/{rate,[0-9][0-9][0-9]}*", "/rate"),
- glob(true, "/{rate,[a-z][a-z][a-z]}*", "/usd"),
-
- glob(true, "{*.google.*,*.yandex.*}", "www.google.com", '.'),
- glob(true, "{*.google.*,*.yandex.*}", "www.yandex.com", '.'),
- glob(false, "{*.google.*,*.yandex.*}", "yandex.com", '.'),
- glob(false, "{*.google.*,*.yandex.*}", "google.com", '.'),
-
- glob(true, "{*.google.*,yandex.*}", "www.google.com", '.'),
- glob(true, "{*.google.*,yandex.*}", "yandex.com", '.'),
- glob(false, "{*.google.*,yandex.*}", "www.yandex.com", '.'),
- glob(false, "{*.google.*,yandex.*}", "google.com", '.'),
-
- glob(true, "*//{,*.}example.com", "https://www.example.com"),
- glob(true, "*//{,*.}example.com", "http://example.com"),
- glob(false, "*//{,*.}example.com", "http://example.com.net"),
-
- glob(true, pattern_all, fixture_all_match),
- glob(false, pattern_all, fixture_all_mismatch),
-
- glob(true, pattern_plain, fixture_plain_match),
- glob(false, pattern_plain, fixture_plain_mismatch),
-
- glob(true, pattern_multiple, fixture_multiple_match),
- glob(false, pattern_multiple, fixture_multiple_mismatch),
-
- glob(true, pattern_alternatives, fixture_alternatives_match),
- glob(false, pattern_alternatives, fixture_alternatives_mismatch),
-
- glob(true, pattern_alternatives_suffix, fixture_alternatives_suffix_first_match),
- glob(false, pattern_alternatives_suffix, fixture_alternatives_suffix_first_mismatch),
- glob(true, pattern_alternatives_suffix, fixture_alternatives_suffix_second),
-
- glob(true, pattern_alternatives_combine_hard, fixture_alternatives_combine_hard),
-
- glob(true, pattern_alternatives_combine_lite, fixture_alternatives_combine_lite),
-
- glob(true, pattern_prefix, fixture_prefix_suffix_match),
- glob(false, pattern_prefix, fixture_prefix_suffix_mismatch),
-
- glob(true, pattern_suffix, fixture_prefix_suffix_match),
- glob(false, pattern_suffix, fixture_prefix_suffix_mismatch),
-
- glob(true, pattern_prefix_suffix, fixture_prefix_suffix_match),
- glob(false, pattern_prefix_suffix, fixture_prefix_suffix_mismatch),
- } {
- t.Run("", func(t *testing.T) {
- g := MustCompile(test.pattern, test.delimiters...)
- result := g.Match(test.match)
- if result != test.should {
- t.Errorf(
- "pattern %q matching %q should be %v but got %v\n%s",
- test.pattern, test.match, test.should, result, g,
- )
- }
- })
- }
-}
-
-func TestQuoteMeta(t *testing.T) {
- for id, test := range []struct {
- in, out string
- }{
- {
- in: `[foo*]`,
- out: `\[foo\*\]`,
- },
- {
- in: `{foo*}`,
- out: `\{foo\*\}`,
- },
- {
- in: `*?\[]{}`,
- out: `\*\?\\\[\]\{\}`,
- },
- {
- in: `some text and *?\[]{}`,
- out: `some text and \*\?\\\[\]\{\}`,
- },
- } {
- act := QuoteMeta(test.in)
- if act != test.out {
- t.Errorf("#%d QuoteMeta(%q) = %q; want %q", id, test.in, act, test.out)
- }
- if _, err := Compile(act); err != nil {
- t.Errorf("#%d _, err := Compile(QuoteMeta(%q) = %q); err = %q", id, test.in, act, err)
- }
- }
-}
-
-func BenchmarkParseGlob(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Compile(pattern_all)
- }
-}
-func BenchmarkParseRegexp(b *testing.B) {
- for i := 0; i < b.N; i++ {
- regexp.MustCompile(regexp_all)
- }
-}
-
-func BenchmarkAllGlobMatch(b *testing.B) {
- m, _ := Compile(pattern_all)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_all_match)
- }
-}
-func BenchmarkAllGlobMatchParallel(b *testing.B) {
- m, _ := Compile(pattern_all)
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _ = m.Match(fixture_all_match)
- }
- })
-}
-
-func BenchmarkAllRegexpMatch(b *testing.B) {
- m := regexp.MustCompile(regexp_all)
- f := []byte(fixture_all_match)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-func BenchmarkAllGlobMismatch(b *testing.B) {
- m, _ := Compile(pattern_all)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_all_mismatch)
- }
-}
-func BenchmarkAllGlobMismatchParallel(b *testing.B) {
- m, _ := Compile(pattern_all)
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _ = m.Match(fixture_all_mismatch)
- }
- })
-}
-func BenchmarkAllRegexpMismatch(b *testing.B) {
- m := regexp.MustCompile(regexp_all)
- f := []byte(fixture_all_mismatch)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-
-func BenchmarkMultipleGlobMatch(b *testing.B) {
- m, _ := Compile(pattern_multiple)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_multiple_match)
- }
-}
-func BenchmarkMultipleRegexpMatch(b *testing.B) {
- m := regexp.MustCompile(regexp_multiple)
- f := []byte(fixture_multiple_match)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-func BenchmarkMultipleGlobMismatch(b *testing.B) {
- m, _ := Compile(pattern_multiple)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_multiple_mismatch)
- }
-}
-func BenchmarkMultipleRegexpMismatch(b *testing.B) {
- m := regexp.MustCompile(regexp_multiple)
- f := []byte(fixture_multiple_mismatch)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-
-func BenchmarkAlternativesGlobMatch(b *testing.B) {
- m, _ := Compile(pattern_alternatives)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_alternatives_match)
- }
-}
-func BenchmarkAlternativesGlobMismatch(b *testing.B) {
- m, _ := Compile(pattern_alternatives)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_alternatives_mismatch)
- }
-}
-func BenchmarkAlternativesRegexpMatch(b *testing.B) {
- m := regexp.MustCompile(regexp_alternatives)
- f := []byte(fixture_alternatives_match)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-func BenchmarkAlternativesRegexpMismatch(b *testing.B) {
- m := regexp.MustCompile(regexp_alternatives)
- f := []byte(fixture_alternatives_mismatch)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-
-func BenchmarkAlternativesSuffixFirstGlobMatch(b *testing.B) {
- m, _ := Compile(pattern_alternatives_suffix)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_alternatives_suffix_first_match)
- }
-}
-func BenchmarkAlternativesSuffixFirstGlobMismatch(b *testing.B) {
- m, _ := Compile(pattern_alternatives_suffix)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_alternatives_suffix_first_mismatch)
- }
-}
-func BenchmarkAlternativesSuffixSecondGlobMatch(b *testing.B) {
- m, _ := Compile(pattern_alternatives_suffix)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_alternatives_suffix_second)
- }
-}
-func BenchmarkAlternativesCombineLiteGlobMatch(b *testing.B) {
- m, _ := Compile(pattern_alternatives_combine_lite)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_alternatives_combine_lite)
- }
-}
-func BenchmarkAlternativesCombineHardGlobMatch(b *testing.B) {
- m, _ := Compile(pattern_alternatives_combine_hard)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_alternatives_combine_hard)
- }
-}
-func BenchmarkAlternativesSuffixFirstRegexpMatch(b *testing.B) {
- m := regexp.MustCompile(regexp_alternatives_suffix)
- f := []byte(fixture_alternatives_suffix_first_match)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-func BenchmarkAlternativesSuffixFirstRegexpMismatch(b *testing.B) {
- m := regexp.MustCompile(regexp_alternatives_suffix)
- f := []byte(fixture_alternatives_suffix_first_mismatch)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-func BenchmarkAlternativesSuffixSecondRegexpMatch(b *testing.B) {
- m := regexp.MustCompile(regexp_alternatives_suffix)
- f := []byte(fixture_alternatives_suffix_second)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-func BenchmarkAlternativesCombineLiteRegexpMatch(b *testing.B) {
- m := regexp.MustCompile(regexp_alternatives_combine_lite)
- f := []byte(fixture_alternatives_combine_lite)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-func BenchmarkAlternativesCombineHardRegexpMatch(b *testing.B) {
- m := regexp.MustCompile(regexp_alternatives_combine_hard)
- f := []byte(fixture_alternatives_combine_hard)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-
-func BenchmarkPlainGlobMatch(b *testing.B) {
- m, _ := Compile(pattern_plain)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_plain_match)
- }
-}
-func BenchmarkPlainRegexpMatch(b *testing.B) {
- m := regexp.MustCompile(regexp_plain)
- f := []byte(fixture_plain_match)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-func BenchmarkPlainGlobMismatch(b *testing.B) {
- m, _ := Compile(pattern_plain)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_plain_mismatch)
- }
-}
-func BenchmarkPlainRegexpMismatch(b *testing.B) {
- m := regexp.MustCompile(regexp_plain)
- f := []byte(fixture_plain_mismatch)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-
-func BenchmarkPrefixGlobMatch(b *testing.B) {
- m, _ := Compile(pattern_prefix)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_prefix_suffix_match)
- }
-}
-func BenchmarkPrefixRegexpMatch(b *testing.B) {
- m := regexp.MustCompile(regexp_prefix)
- f := []byte(fixture_prefix_suffix_match)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-func BenchmarkPrefixGlobMismatch(b *testing.B) {
- m, _ := Compile(pattern_prefix)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_prefix_suffix_mismatch)
- }
-}
-func BenchmarkPrefixRegexpMismatch(b *testing.B) {
- m := regexp.MustCompile(regexp_prefix)
- f := []byte(fixture_prefix_suffix_mismatch)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-
-func BenchmarkSuffixGlobMatch(b *testing.B) {
- m, _ := Compile(pattern_suffix)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_prefix_suffix_match)
- }
-}
-func BenchmarkSuffixRegexpMatch(b *testing.B) {
- m := regexp.MustCompile(regexp_suffix)
- f := []byte(fixture_prefix_suffix_match)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-func BenchmarkSuffixGlobMismatch(b *testing.B) {
- m, _ := Compile(pattern_suffix)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_prefix_suffix_mismatch)
- }
-}
-func BenchmarkSuffixRegexpMismatch(b *testing.B) {
- m := regexp.MustCompile(regexp_suffix)
- f := []byte(fixture_prefix_suffix_mismatch)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-
-func BenchmarkPrefixSuffixGlobMatch(b *testing.B) {
- m, _ := Compile(pattern_prefix_suffix)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_prefix_suffix_match)
- }
-}
-func BenchmarkPrefixSuffixRegexpMatch(b *testing.B) {
- m := regexp.MustCompile(regexp_prefix_suffix)
- f := []byte(fixture_prefix_suffix_match)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
-func BenchmarkPrefixSuffixGlobMismatch(b *testing.B) {
- m, _ := Compile(pattern_prefix_suffix)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(fixture_prefix_suffix_mismatch)
- }
-}
-func BenchmarkPrefixSuffixRegexpMismatch(b *testing.B) {
- m := regexp.MustCompile(regexp_prefix_suffix)
- f := []byte(fixture_prefix_suffix_mismatch)
-
- for i := 0; i < b.N; i++ {
- _ = m.Match(f)
- }
-}
diff --git a/vendor/github.com/gobwas/glob/match/any_of_test.go b/vendor/github.com/gobwas/glob/match/any_of_test.go
deleted file mode 100644
index 3b478cf5..00000000
--- a/vendor/github.com/gobwas/glob/match/any_of_test.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestAnyOfIndex(t *testing.T) {
- for id, test := range []struct {
- matchers Matchers
- fixture string
- index int
- segments []int
- }{
- {
- Matchers{
- NewAny(nil),
- NewText("b"),
- NewText("c"),
- },
- "abc",
- 0,
- []int{0, 1, 2, 3},
- },
- {
- Matchers{
- NewPrefix("b"),
- NewSuffix("c"),
- },
- "abc",
- 0,
- []int{3},
- },
- {
- Matchers{
- NewList([]rune("[def]"), false),
- NewList([]rune("[abc]"), false),
- },
- "abcdef",
- 0,
- []int{1},
- },
- } {
- everyOf := NewAnyOf(test.matchers...)
- index, segments := everyOf.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
diff --git a/vendor/github.com/gobwas/glob/match/any_test.go b/vendor/github.com/gobwas/glob/match/any_test.go
deleted file mode 100644
index 358f5534..00000000
--- a/vendor/github.com/gobwas/glob/match/any_test.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestAnyIndex(t *testing.T) {
- for id, test := range []struct {
- sep []rune
- fixture string
- index int
- segments []int
- }{
- {
- []rune{'.'},
- "abc",
- 0,
- []int{0, 1, 2, 3},
- },
- {
- []rune{'.'},
- "abc.def",
- 0,
- []int{0, 1, 2, 3},
- },
- } {
- p := NewAny(test.sep)
- index, segments := p.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
-
-func BenchmarkIndexAny(b *testing.B) {
- m := NewAny(bench_separators)
-
- for i := 0; i < b.N; i++ {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
-}
-
-func BenchmarkIndexAnyParallel(b *testing.B) {
- m := NewAny(bench_separators)
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
- })
-}
diff --git a/vendor/github.com/gobwas/glob/match/btree_test.go b/vendor/github.com/gobwas/glob/match/btree_test.go
deleted file mode 100644
index 3bd9ea55..00000000
--- a/vendor/github.com/gobwas/glob/match/btree_test.go
+++ /dev/null
@@ -1,90 +0,0 @@
-package match
-
-import (
- "testing"
-)
-
-func TestBTree(t *testing.T) {
- for id, test := range []struct {
- tree BTree
- str string
- exp bool
- }{
- {
- NewBTree(NewText("abc"), NewSuper(), NewSuper()),
- "abc",
- true,
- },
- {
- NewBTree(NewText("a"), NewSingle(nil), NewSingle(nil)),
- "aaa",
- true,
- },
- {
- NewBTree(NewText("b"), NewSingle(nil), nil),
- "bbb",
- false,
- },
- {
- NewBTree(
- NewText("c"),
- NewBTree(
- NewSingle(nil),
- NewSuper(),
- nil,
- ),
- nil,
- ),
- "abc",
- true,
- },
- } {
- act := test.tree.Match(test.str)
- if act != test.exp {
- t.Errorf("#%d match %q error: act: %t; exp: %t", id, test.str, act, test.exp)
- continue
- }
- }
-}
-
-type fakeMatcher struct {
- len int
- name string
-}
-
-func (f *fakeMatcher) Match(string) bool {
- return true
-}
-
-var i = 3
-
-func (f *fakeMatcher) Index(s string) (int, []int) {
- seg := make([]int, 0, i)
- for x := 0; x < i; x++ {
- seg = append(seg, x)
- }
- return 0, seg
-}
-func (f *fakeMatcher) Len() int {
- return f.len
-}
-func (f *fakeMatcher) String() string {
- return f.name
-}
-
-func BenchmarkMatchBTree(b *testing.B) {
- l := &fakeMatcher{4, "left_fake"}
- r := &fakeMatcher{4, "right_fake"}
- v := &fakeMatcher{2, "value_fake"}
-
- // must be <= len(l + r + v)
- fixture := "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij"
-
- bt := NewBTree(v, l, r)
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- bt.Match(fixture)
- }
- })
-}
diff --git a/vendor/github.com/gobwas/glob/match/contains_test.go b/vendor/github.com/gobwas/glob/match/contains_test.go
deleted file mode 100644
index 931322eb..00000000
--- a/vendor/github.com/gobwas/glob/match/contains_test.go
+++ /dev/null
@@ -1,74 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestContainsIndex(t *testing.T) {
- for id, test := range []struct {
- prefix string
- not bool
- fixture string
- index int
- segments []int
- }{
- {
- "ab",
- false,
- "abc",
- 0,
- []int{2, 3},
- },
- {
- "ab",
- false,
- "fffabfff",
- 0,
- []int{5, 6, 7, 8},
- },
- {
- "ab",
- true,
- "abc",
- 0,
- []int{0},
- },
- {
- "ab",
- true,
- "fffabfff",
- 0,
- []int{0, 1, 2, 3},
- },
- } {
- p := NewContains(test.prefix, test.not)
- index, segments := p.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
-
-func BenchmarkIndexContains(b *testing.B) {
- m := NewContains(string(bench_separators), true)
-
- for i := 0; i < b.N; i++ {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
-}
-
-func BenchmarkIndexContainsParallel(b *testing.B) {
- m := NewContains(string(bench_separators), true)
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
- })
-}
diff --git a/vendor/github.com/gobwas/glob/match/debug/debug.go b/vendor/github.com/gobwas/glob/match/debug/debug.go
deleted file mode 100644
index 5c5dbc1a..00000000
--- a/vendor/github.com/gobwas/glob/match/debug/debug.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package debug
-
-import (
- "bytes"
- "fmt"
- "github.com/gobwas/glob/match"
- "math/rand"
-)
-
-func Graphviz(pattern string, m match.Matcher) string {
- return fmt.Sprintf(`digraph G {graph[label="%s"];%s}`, pattern, graphviz_internal(m, fmt.Sprintf("%x", rand.Int63())))
-}
-
-func graphviz_internal(m match.Matcher, id string) string {
- buf := &bytes.Buffer{}
-
- switch matcher := m.(type) {
- case match.BTree:
- fmt.Fprintf(buf, `"%s"[label="%s"];`, id, matcher.Value.String())
- for _, m := range []match.Matcher{matcher.Left, matcher.Right} {
- switch n := m.(type) {
- case nil:
- rnd := rand.Int63()
- fmt.Fprintf(buf, `"%x"[label=""];`, rnd)
- fmt.Fprintf(buf, `"%s"->"%x";`, id, rnd)
-
- default:
- sub := fmt.Sprintf("%x", rand.Int63())
- fmt.Fprintf(buf, `"%s"->"%s";`, id, sub)
- fmt.Fprintf(buf, graphviz_internal(n, sub))
- }
- }
-
- case match.AnyOf:
- fmt.Fprintf(buf, `"%s"[label="AnyOf"];`, id)
- for _, m := range matcher.Matchers {
- rnd := rand.Int63()
- fmt.Fprintf(buf, graphviz_internal(m, fmt.Sprintf("%x", rnd)))
- fmt.Fprintf(buf, `"%s"->"%x";`, id, rnd)
- }
-
- case match.EveryOf:
- fmt.Fprintf(buf, `"%s"[label="EveryOf"];`, id)
- for _, m := range matcher.Matchers {
- rnd := rand.Int63()
- fmt.Fprintf(buf, graphviz_internal(m, fmt.Sprintf("%x", rnd)))
- fmt.Fprintf(buf, `"%s"->"%x";`, id, rnd)
- }
-
- default:
- fmt.Fprintf(buf, `"%s"[label="%s"];`, id, m.String())
- }
-
- return buf.String()
-}
diff --git a/vendor/github.com/gobwas/glob/match/every_of_test.go b/vendor/github.com/gobwas/glob/match/every_of_test.go
deleted file mode 100644
index eb83f862..00000000
--- a/vendor/github.com/gobwas/glob/match/every_of_test.go
+++ /dev/null
@@ -1,45 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestEveryOfIndex(t *testing.T) {
- for id, test := range []struct {
- matchers Matchers
- fixture string
- index int
- segments []int
- }{
- {
- Matchers{
- NewAny(nil),
- NewText("b"),
- NewText("c"),
- },
- "dbc",
- -1,
- nil,
- },
- {
- Matchers{
- NewAny(nil),
- NewPrefix("b"),
- NewSuffix("c"),
- },
- "abc",
- 1,
- []int{2},
- },
- } {
- everyOf := NewEveryOf(test.matchers...)
- index, segments := everyOf.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
diff --git a/vendor/github.com/gobwas/glob/match/list_test.go b/vendor/github.com/gobwas/glob/match/list_test.go
deleted file mode 100644
index 10a54379..00000000
--- a/vendor/github.com/gobwas/glob/match/list_test.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestListIndex(t *testing.T) {
- for id, test := range []struct {
- list []rune
- not bool
- fixture string
- index int
- segments []int
- }{
- {
- []rune("ab"),
- false,
- "abc",
- 0,
- []int{1},
- },
- {
- []rune("ab"),
- true,
- "fffabfff",
- 0,
- []int{1},
- },
- } {
- p := NewList(test.list, test.not)
- index, segments := p.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
-
-func BenchmarkIndexList(b *testing.B) {
- m := NewList([]rune("def"), false)
-
- for i := 0; i < b.N; i++ {
- m.Index(bench_pattern)
- }
-}
-
-func BenchmarkIndexListParallel(b *testing.B) {
- m := NewList([]rune("def"), false)
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- m.Index(bench_pattern)
- }
- })
-}
diff --git a/vendor/github.com/gobwas/glob/match/match_test.go b/vendor/github.com/gobwas/glob/match/match_test.go
deleted file mode 100644
index 4c1b83c7..00000000
--- a/vendor/github.com/gobwas/glob/match/match_test.go
+++ /dev/null
@@ -1,90 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
- "unicode/utf8"
-)
-
-var bench_separators = []rune{'.'}
-
-const bench_pattern = "abcdefghijklmnopqrstuvwxyz0123456789"
-
-func TestAppendMerge(t *testing.T) {
- for id, test := range []struct {
- segments [2][]int
- exp []int
- }{
- {
- [2][]int{
- {0, 6, 7},
- {0, 1, 3},
- },
- []int{0, 1, 3, 6, 7},
- },
- {
- [2][]int{
- {0, 1, 3, 6, 7},
- {0, 1, 10},
- },
- []int{0, 1, 3, 6, 7, 10},
- },
- } {
- act := appendMerge(test.segments[0], test.segments[1])
- if !reflect.DeepEqual(act, test.exp) {
- t.Errorf("#%d merge sort segments unexpected:\nact: %v\nexp:%v", id, act, test.exp)
- continue
- }
- }
-}
-
-func BenchmarkAppendMerge(b *testing.B) {
- s1 := []int{0, 1, 3, 6, 7}
- s2 := []int{0, 1, 3}
-
- for i := 0; i < b.N; i++ {
- appendMerge(s1, s2)
- }
-}
-
-func BenchmarkAppendMergeParallel(b *testing.B) {
- s1 := []int{0, 1, 3, 6, 7}
- s2 := []int{0, 1, 3}
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- appendMerge(s1, s2)
- }
- })
-}
-
-func BenchmarkReverse(b *testing.B) {
- for i := 0; i < b.N; i++ {
- reverseSegments([]int{1, 2, 3, 4})
- }
-}
-
-func getTable() []int {
- table := make([]int, utf8.MaxRune+1)
- for i := 0; i <= utf8.MaxRune; i++ {
- table[i] = utf8.RuneLen(rune(i))
- }
-
- return table
-}
-
-var table = getTable()
-
-const runeToLen = 'q'
-
-func BenchmarkRuneLenFromTable(b *testing.B) {
- for i := 0; i < b.N; i++ {
- _ = table[runeToLen]
- }
-}
-
-func BenchmarkRuneLenFromUTF8(b *testing.B) {
- for i := 0; i < b.N; i++ {
- _ = utf8.RuneLen(runeToLen)
- }
-}
diff --git a/vendor/github.com/gobwas/glob/match/max_test.go b/vendor/github.com/gobwas/glob/match/max_test.go
deleted file mode 100644
index 23676284..00000000
--- a/vendor/github.com/gobwas/glob/match/max_test.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestMaxIndex(t *testing.T) {
- for id, test := range []struct {
- limit int
- fixture string
- index int
- segments []int
- }{
- {
- 3,
- "abc",
- 0,
- []int{0, 1, 2, 3},
- },
- {
- 3,
- "abcdef",
- 0,
- []int{0, 1, 2, 3},
- },
- } {
- p := NewMax(test.limit)
- index, segments := p.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
-
-func BenchmarkIndexMax(b *testing.B) {
- m := NewMax(10)
-
- for i := 0; i < b.N; i++ {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
-}
-
-func BenchmarkIndexMaxParallel(b *testing.B) {
- m := NewMax(10)
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
- })
-}
diff --git a/vendor/github.com/gobwas/glob/match/min_test.go b/vendor/github.com/gobwas/glob/match/min_test.go
deleted file mode 100644
index ab854ae0..00000000
--- a/vendor/github.com/gobwas/glob/match/min_test.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestMinIndex(t *testing.T) {
- for id, test := range []struct {
- limit int
- fixture string
- index int
- segments []int
- }{
- {
- 1,
- "abc",
- 0,
- []int{1, 2, 3},
- },
- {
- 3,
- "abcd",
- 0,
- []int{3, 4},
- },
- } {
- p := NewMin(test.limit)
- index, segments := p.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
-
-func BenchmarkIndexMin(b *testing.B) {
- m := NewMin(10)
-
- for i := 0; i < b.N; i++ {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
-}
-
-func BenchmarkIndexMinParallel(b *testing.B) {
- m := NewMin(10)
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
- })
-}
diff --git a/vendor/github.com/gobwas/glob/match/nothing_test.go b/vendor/github.com/gobwas/glob/match/nothing_test.go
deleted file mode 100644
index 941c22d1..00000000
--- a/vendor/github.com/gobwas/glob/match/nothing_test.go
+++ /dev/null
@@ -1,54 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestNothingIndex(t *testing.T) {
- for id, test := range []struct {
- fixture string
- index int
- segments []int
- }{
- {
- "abc",
- 0,
- []int{0},
- },
- {
- "",
- 0,
- []int{0},
- },
- } {
- p := NewNothing()
- index, segments := p.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
-
-func BenchmarkIndexNothing(b *testing.B) {
- m := NewNothing()
-
- for i := 0; i < b.N; i++ {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
-}
-
-func BenchmarkIndexNothingParallel(b *testing.B) {
- m := NewNothing()
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
- })
-}
diff --git a/vendor/github.com/gobwas/glob/match/prefix_any_test.go b/vendor/github.com/gobwas/glob/match/prefix_any_test.go
deleted file mode 100644
index e6990e37..00000000
--- a/vendor/github.com/gobwas/glob/match/prefix_any_test.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestPrefixAnyIndex(t *testing.T) {
- for id, test := range []struct {
- prefix string
- separators []rune
- fixture string
- index int
- segments []int
- }{
- {
- "ab",
- []rune{'.'},
- "ab",
- 0,
- []int{2},
- },
- {
- "ab",
- []rune{'.'},
- "abc",
- 0,
- []int{2, 3},
- },
- {
- "ab",
- []rune{'.'},
- "qw.abcd.efg",
- 3,
- []int{2, 3, 4},
- },
- } {
- p := NewPrefixAny(test.prefix, test.separators)
- index, segments := p.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
diff --git a/vendor/github.com/gobwas/glob/match/prefix_suffix_test.go b/vendor/github.com/gobwas/glob/match/prefix_suffix_test.go
deleted file mode 100644
index 79b17b20..00000000
--- a/vendor/github.com/gobwas/glob/match/prefix_suffix_test.go
+++ /dev/null
@@ -1,67 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestPrefixSuffixIndex(t *testing.T) {
- for id, test := range []struct {
- prefix string
- suffix string
- fixture string
- index int
- segments []int
- }{
- {
- "a",
- "c",
- "abc",
- 0,
- []int{3},
- },
- {
- "f",
- "f",
- "fffabfff",
- 0,
- []int{1, 2, 3, 6, 7, 8},
- },
- {
- "ab",
- "bc",
- "abc",
- 0,
- []int{3},
- },
- } {
- p := NewPrefixSuffix(test.prefix, test.suffix)
- index, segments := p.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
-
-func BenchmarkIndexPrefixSuffix(b *testing.B) {
- m := NewPrefixSuffix("qew", "sqw")
-
- for i := 0; i < b.N; i++ {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
-}
-
-func BenchmarkIndexPrefixSuffixParallel(b *testing.B) {
- m := NewPrefixSuffix("qew", "sqw")
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
- })
-}
diff --git a/vendor/github.com/gobwas/glob/match/prefix_test.go b/vendor/github.com/gobwas/glob/match/prefix_test.go
deleted file mode 100644
index 22a296e6..00000000
--- a/vendor/github.com/gobwas/glob/match/prefix_test.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestPrefixIndex(t *testing.T) {
- for id, test := range []struct {
- prefix string
- fixture string
- index int
- segments []int
- }{
- {
- "ab",
- "abc",
- 0,
- []int{2, 3},
- },
- {
- "ab",
- "fffabfff",
- 3,
- []int{2, 3, 4, 5},
- },
- } {
- p := NewPrefix(test.prefix)
- index, segments := p.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
-
-func BenchmarkIndexPrefix(b *testing.B) {
- m := NewPrefix("qew")
-
- for i := 0; i < b.N; i++ {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
-}
-
-func BenchmarkIndexPrefixParallel(b *testing.B) {
- m := NewPrefix("qew")
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
- })
-}
diff --git a/vendor/github.com/gobwas/glob/match/range_test.go b/vendor/github.com/gobwas/glob/match/range_test.go
deleted file mode 100644
index 0dddcfdb..00000000
--- a/vendor/github.com/gobwas/glob/match/range_test.go
+++ /dev/null
@@ -1,67 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestRangeIndex(t *testing.T) {
- for id, test := range []struct {
- lo, hi rune
- not bool
- fixture string
- index int
- segments []int
- }{
- {
- 'a', 'z',
- false,
- "abc",
- 0,
- []int{1},
- },
- {
- 'a', 'c',
- false,
- "abcd",
- 0,
- []int{1},
- },
- {
- 'a', 'c',
- true,
- "abcd",
- 3,
- []int{1},
- },
- } {
- m := NewRange(test.lo, test.hi, test.not)
- index, segments := m.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
-
-func BenchmarkIndexRange(b *testing.B) {
- m := NewRange('0', '9', false)
-
- for i := 0; i < b.N; i++ {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
-}
-
-func BenchmarkIndexRangeParallel(b *testing.B) {
- m := NewRange('0', '9', false)
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
- })
-}
diff --git a/vendor/github.com/gobwas/glob/match/row_test.go b/vendor/github.com/gobwas/glob/match/row_test.go
deleted file mode 100644
index c9e65ef5..00000000
--- a/vendor/github.com/gobwas/glob/match/row_test.go
+++ /dev/null
@@ -1,82 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestRowIndex(t *testing.T) {
- for id, test := range []struct {
- matchers Matchers
- length int
- fixture string
- index int
- segments []int
- }{
- {
- Matchers{
- NewText("abc"),
- NewText("def"),
- NewSingle(nil),
- },
- 7,
- "qweabcdefghij",
- 3,
- []int{7},
- },
- {
- Matchers{
- NewText("abc"),
- NewText("def"),
- NewSingle(nil),
- },
- 7,
- "abcd",
- -1,
- nil,
- },
- } {
- p := NewRow(test.length, test.matchers...)
- index, segments := p.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
-
-func BenchmarkRowIndex(b *testing.B) {
- m := NewRow(
- 7,
- Matchers{
- NewText("abc"),
- NewText("def"),
- NewSingle(nil),
- }...,
- )
-
- for i := 0; i < b.N; i++ {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
-}
-
-func BenchmarkIndexRowParallel(b *testing.B) {
- m := NewRow(
- 7,
- Matchers{
- NewText("abc"),
- NewText("def"),
- NewSingle(nil),
- }...,
- )
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
- })
-}
diff --git a/vendor/github.com/gobwas/glob/match/segments_test.go b/vendor/github.com/gobwas/glob/match/segments_test.go
deleted file mode 100644
index 1ce1123d..00000000
--- a/vendor/github.com/gobwas/glob/match/segments_test.go
+++ /dev/null
@@ -1,83 +0,0 @@
-package match
-
-import (
- "sync"
- "testing"
-)
-
-func benchPool(i int, b *testing.B) {
- pool := sync.Pool{New: func() interface{} {
- return make([]int, 0, i)
- }}
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- s := pool.Get().([]int)[:0]
- pool.Put(s)
- }
- })
-}
-
-func benchMake(i int, b *testing.B) {
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _ = make([]int, 0, i)
- }
- })
-}
-
-func BenchmarkSegmentsPool_1(b *testing.B) {
- benchPool(1, b)
-}
-func BenchmarkSegmentsPool_2(b *testing.B) {
- benchPool(2, b)
-}
-func BenchmarkSegmentsPool_4(b *testing.B) {
- benchPool(4, b)
-}
-func BenchmarkSegmentsPool_8(b *testing.B) {
- benchPool(8, b)
-}
-func BenchmarkSegmentsPool_16(b *testing.B) {
- benchPool(16, b)
-}
-func BenchmarkSegmentsPool_32(b *testing.B) {
- benchPool(32, b)
-}
-func BenchmarkSegmentsPool_64(b *testing.B) {
- benchPool(64, b)
-}
-func BenchmarkSegmentsPool_128(b *testing.B) {
- benchPool(128, b)
-}
-func BenchmarkSegmentsPool_256(b *testing.B) {
- benchPool(256, b)
-}
-
-func BenchmarkSegmentsMake_1(b *testing.B) {
- benchMake(1, b)
-}
-func BenchmarkSegmentsMake_2(b *testing.B) {
- benchMake(2, b)
-}
-func BenchmarkSegmentsMake_4(b *testing.B) {
- benchMake(4, b)
-}
-func BenchmarkSegmentsMake_8(b *testing.B) {
- benchMake(8, b)
-}
-func BenchmarkSegmentsMake_16(b *testing.B) {
- benchMake(16, b)
-}
-func BenchmarkSegmentsMake_32(b *testing.B) {
- benchMake(32, b)
-}
-func BenchmarkSegmentsMake_64(b *testing.B) {
- benchMake(64, b)
-}
-func BenchmarkSegmentsMake_128(b *testing.B) {
- benchMake(128, b)
-}
-func BenchmarkSegmentsMake_256(b *testing.B) {
- benchMake(256, b)
-}
diff --git a/vendor/github.com/gobwas/glob/match/single_test.go b/vendor/github.com/gobwas/glob/match/single_test.go
deleted file mode 100644
index a62d7204..00000000
--- a/vendor/github.com/gobwas/glob/match/single_test.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestSingleIndex(t *testing.T) {
- for id, test := range []struct {
- separators []rune
- fixture string
- index int
- segments []int
- }{
- {
- []rune{'.'},
- ".abc",
- 1,
- []int{1},
- },
- {
- []rune{'.'},
- ".",
- -1,
- nil,
- },
- } {
- p := NewSingle(test.separators)
- index, segments := p.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
-
-func BenchmarkIndexSingle(b *testing.B) {
- m := NewSingle(bench_separators)
-
- for i := 0; i < b.N; i++ {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
-}
-
-func BenchmarkIndexSingleParallel(b *testing.B) {
- m := NewSingle(bench_separators)
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
- })
-}
diff --git a/vendor/github.com/gobwas/glob/match/suffix_any_test.go b/vendor/github.com/gobwas/glob/match/suffix_any_test.go
deleted file mode 100644
index eed6e596..00000000
--- a/vendor/github.com/gobwas/glob/match/suffix_any_test.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestSuffixAnyIndex(t *testing.T) {
- for id, test := range []struct {
- suffix string
- separators []rune
- fixture string
- index int
- segments []int
- }{
- {
- "ab",
- []rune{'.'},
- "ab",
- 0,
- []int{2},
- },
- {
- "ab",
- []rune{'.'},
- "cab",
- 0,
- []int{3},
- },
- {
- "ab",
- []rune{'.'},
- "qw.cdab.efg",
- 3,
- []int{4},
- },
- } {
- p := NewSuffixAny(test.suffix, test.separators)
- index, segments := p.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
diff --git a/vendor/github.com/gobwas/glob/match/suffix_test.go b/vendor/github.com/gobwas/glob/match/suffix_test.go
deleted file mode 100644
index 49047634..00000000
--- a/vendor/github.com/gobwas/glob/match/suffix_test.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestSuffixIndex(t *testing.T) {
- for id, test := range []struct {
- prefix string
- fixture string
- index int
- segments []int
- }{
- {
- "ab",
- "abc",
- 0,
- []int{2},
- },
- {
- "ab",
- "fffabfff",
- 0,
- []int{5},
- },
- } {
- p := NewSuffix(test.prefix)
- index, segments := p.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
-
-func BenchmarkIndexSuffix(b *testing.B) {
- m := NewSuffix("qwe")
-
- for i := 0; i < b.N; i++ {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
-}
-
-func BenchmarkIndexSuffixParallel(b *testing.B) {
- m := NewSuffix("qwe")
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
- })
-}
diff --git a/vendor/github.com/gobwas/glob/match/super_test.go b/vendor/github.com/gobwas/glob/match/super_test.go
deleted file mode 100644
index 10418dc2..00000000
--- a/vendor/github.com/gobwas/glob/match/super_test.go
+++ /dev/null
@@ -1,54 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestSuperIndex(t *testing.T) {
- for id, test := range []struct {
- fixture string
- index int
- segments []int
- }{
- {
- "abc",
- 0,
- []int{0, 1, 2, 3},
- },
- {
- "",
- 0,
- []int{0},
- },
- } {
- p := NewSuper()
- index, segments := p.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
-
-func BenchmarkIndexSuper(b *testing.B) {
- m := NewSuper()
-
- for i := 0; i < b.N; i++ {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
-}
-
-func BenchmarkIndexSuperParallel(b *testing.B) {
- m := NewSuper()
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
- })
-}
diff --git a/vendor/github.com/gobwas/glob/match/text_test.go b/vendor/github.com/gobwas/glob/match/text_test.go
deleted file mode 100644
index a3de40ea..00000000
--- a/vendor/github.com/gobwas/glob/match/text_test.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package match
-
-import (
- "reflect"
- "testing"
-)
-
-func TestTextIndex(t *testing.T) {
- for id, test := range []struct {
- text string
- fixture string
- index int
- segments []int
- }{
- {
- "b",
- "abc",
- 1,
- []int{1},
- },
- {
- "f",
- "abcd",
- -1,
- nil,
- },
- } {
- m := NewText(test.text)
- index, segments := m.Index(test.fixture)
- if index != test.index {
- t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
- }
- if !reflect.DeepEqual(segments, test.segments) {
- t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
- }
- }
-}
-
-func BenchmarkIndexText(b *testing.B) {
- m := NewText("foo")
-
- for i := 0; i < b.N; i++ {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
-}
-
-func BenchmarkIndexTextParallel(b *testing.B) {
- m := NewText("foo")
-
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- _, s := m.Index(bench_pattern)
- releaseSegments(s)
- }
- })
-}
diff --git a/vendor/github.com/gobwas/glob/syntax/ast/parser_test.go b/vendor/github.com/gobwas/glob/syntax/ast/parser_test.go
deleted file mode 100644
index a469d38c..00000000
--- a/vendor/github.com/gobwas/glob/syntax/ast/parser_test.go
+++ /dev/null
@@ -1,218 +0,0 @@
-package ast
-
-import (
- "reflect"
- "testing"
-
- "github.com/gobwas/glob/syntax/lexer"
-)
-
-type stubLexer struct {
- tokens []lexer.Token
- pos int
-}
-
-func (s *stubLexer) Next() (ret lexer.Token) {
- if s.pos == len(s.tokens) {
- return lexer.Token{lexer.EOF, ""}
- }
- ret = s.tokens[s.pos]
- s.pos++
- return
-}
-
-func TestParseString(t *testing.T) {
- for id, test := range []struct {
- tokens []lexer.Token
- tree *Node
- }{
- {
- //pattern: "abc",
- tokens: []lexer.Token{
- {lexer.Text, "abc"},
- {lexer.EOF, ""},
- },
- tree: NewNode(KindPattern, nil,
- NewNode(KindText, Text{Text: "abc"}),
- ),
- },
- {
- //pattern: "a*c",
- tokens: []lexer.Token{
- {lexer.Text, "a"},
- {lexer.Any, "*"},
- {lexer.Text, "c"},
- {lexer.EOF, ""},
- },
- tree: NewNode(KindPattern, nil,
- NewNode(KindText, Text{Text: "a"}),
- NewNode(KindAny, nil),
- NewNode(KindText, Text{Text: "c"}),
- ),
- },
- {
- //pattern: "a**c",
- tokens: []lexer.Token{
- {lexer.Text, "a"},
- {lexer.Super, "**"},
- {lexer.Text, "c"},
- {lexer.EOF, ""},
- },
- tree: NewNode(KindPattern, nil,
- NewNode(KindText, Text{Text: "a"}),
- NewNode(KindSuper, nil),
- NewNode(KindText, Text{Text: "c"}),
- ),
- },
- {
- //pattern: "a?c",
- tokens: []lexer.Token{
- {lexer.Text, "a"},
- {lexer.Single, "?"},
- {lexer.Text, "c"},
- {lexer.EOF, ""},
- },
- tree: NewNode(KindPattern, nil,
- NewNode(KindText, Text{Text: "a"}),
- NewNode(KindSingle, nil),
- NewNode(KindText, Text{Text: "c"}),
- ),
- },
- {
- //pattern: "[!a-z]",
- tokens: []lexer.Token{
- {lexer.RangeOpen, "["},
- {lexer.Not, "!"},
- {lexer.RangeLo, "a"},
- {lexer.RangeBetween, "-"},
- {lexer.RangeHi, "z"},
- {lexer.RangeClose, "]"},
- {lexer.EOF, ""},
- },
- tree: NewNode(KindPattern, nil,
- NewNode(KindRange, Range{Lo: 'a', Hi: 'z', Not: true}),
- ),
- },
- {
- //pattern: "[az]",
- tokens: []lexer.Token{
- {lexer.RangeOpen, "["},
- {lexer.Text, "az"},
- {lexer.RangeClose, "]"},
- {lexer.EOF, ""},
- },
- tree: NewNode(KindPattern, nil,
- NewNode(KindList, List{Chars: "az"}),
- ),
- },
- {
- //pattern: "{a,z}",
- tokens: []lexer.Token{
- {lexer.TermsOpen, "{"},
- {lexer.Text, "a"},
- {lexer.Separator, ","},
- {lexer.Text, "z"},
- {lexer.TermsClose, "}"},
- {lexer.EOF, ""},
- },
- tree: NewNode(KindPattern, nil,
- NewNode(KindAnyOf, nil,
- NewNode(KindPattern, nil,
- NewNode(KindText, Text{Text: "a"}),
- ),
- NewNode(KindPattern, nil,
- NewNode(KindText, Text{Text: "z"}),
- ),
- ),
- ),
- },
- {
- //pattern: "/{z,ab}*",
- tokens: []lexer.Token{
- {lexer.Text, "/"},
- {lexer.TermsOpen, "{"},
- {lexer.Text, "z"},
- {lexer.Separator, ","},
- {lexer.Text, "ab"},
- {lexer.TermsClose, "}"},
- {lexer.Any, "*"},
- {lexer.EOF, ""},
- },
- tree: NewNode(KindPattern, nil,
- NewNode(KindText, Text{Text: "/"}),
- NewNode(KindAnyOf, nil,
- NewNode(KindPattern, nil,
- NewNode(KindText, Text{Text: "z"}),
- ),
- NewNode(KindPattern, nil,
- NewNode(KindText, Text{Text: "ab"}),
- ),
- ),
- NewNode(KindAny, nil),
- ),
- },
- {
- //pattern: "{a,{x,y},?,[a-z],[!qwe]}",
- tokens: []lexer.Token{
- {lexer.TermsOpen, "{"},
- {lexer.Text, "a"},
- {lexer.Separator, ","},
- {lexer.TermsOpen, "{"},
- {lexer.Text, "x"},
- {lexer.Separator, ","},
- {lexer.Text, "y"},
- {lexer.TermsClose, "}"},
- {lexer.Separator, ","},
- {lexer.Single, "?"},
- {lexer.Separator, ","},
- {lexer.RangeOpen, "["},
- {lexer.RangeLo, "a"},
- {lexer.RangeBetween, "-"},
- {lexer.RangeHi, "z"},
- {lexer.RangeClose, "]"},
- {lexer.Separator, ","},
- {lexer.RangeOpen, "["},
- {lexer.Not, "!"},
- {lexer.Text, "qwe"},
- {lexer.RangeClose, "]"},
- {lexer.TermsClose, "}"},
- {lexer.EOF, ""},
- },
- tree: NewNode(KindPattern, nil,
- NewNode(KindAnyOf, nil,
- NewNode(KindPattern, nil,
- NewNode(KindText, Text{Text: "a"}),
- ),
- NewNode(KindPattern, nil,
- NewNode(KindAnyOf, nil,
- NewNode(KindPattern, nil,
- NewNode(KindText, Text{Text: "x"}),
- ),
- NewNode(KindPattern, nil,
- NewNode(KindText, Text{Text: "y"}),
- ),
- ),
- ),
- NewNode(KindPattern, nil,
- NewNode(KindSingle, nil),
- ),
- NewNode(KindPattern, nil,
- NewNode(KindRange, Range{Lo: 'a', Hi: 'z', Not: false}),
- ),
- NewNode(KindPattern, nil,
- NewNode(KindList, List{Chars: "qwe", Not: true}),
- ),
- ),
- ),
- },
- } {
- lexer := &stubLexer{tokens: test.tokens}
- result, err := Parse(lexer)
- if err != nil {
- t.Errorf("[%d] unexpected error: %s", id, err)
- }
- if !reflect.DeepEqual(test.tree, result) {
- t.Errorf("[%d] Parse():\nact:\t%s\nexp:\t%s\n", id, result, test.tree)
- }
- }
-}
diff --git a/vendor/github.com/gobwas/glob/syntax/lexer/lexer_test.go b/vendor/github.com/gobwas/glob/syntax/lexer/lexer_test.go
deleted file mode 100644
index ec35f813..00000000
--- a/vendor/github.com/gobwas/glob/syntax/lexer/lexer_test.go
+++ /dev/null
@@ -1,192 +0,0 @@
-package lexer
-
-import (
- "testing"
-)
-
-func TestLexGood(t *testing.T) {
- for id, test := range []struct {
- pattern string
- items []Token
- }{
- {
- pattern: "",
- items: []Token{
- {EOF, ""},
- },
- },
- {
- pattern: "hello",
- items: []Token{
- {Text, "hello"},
- {EOF, ""},
- },
- },
- {
- pattern: "/{rate,[0-9]]}*",
- items: []Token{
- {Text, "/"},
- {TermsOpen, "{"},
- {Text, "rate"},
- {Separator, ","},
- {RangeOpen, "["},
- {RangeLo, "0"},
- {RangeBetween, "-"},
- {RangeHi, "9"},
- {RangeClose, "]"},
- {Text, "]"},
- {TermsClose, "}"},
- {Any, "*"},
- {EOF, ""},
- },
- },
- {
- pattern: "hello,world",
- items: []Token{
- {Text, "hello,world"},
- {EOF, ""},
- },
- },
- {
- pattern: "hello\\,world",
- items: []Token{
- {Text, "hello,world"},
- {EOF, ""},
- },
- },
- {
- pattern: "hello\\{world",
- items: []Token{
- {Text, "hello{world"},
- {EOF, ""},
- },
- },
- {
- pattern: "hello?",
- items: []Token{
- {Text, "hello"},
- {Single, "?"},
- {EOF, ""},
- },
- },
- {
- pattern: "hellof*",
- items: []Token{
- {Text, "hellof"},
- {Any, "*"},
- {EOF, ""},
- },
- },
- {
- pattern: "hello**",
- items: []Token{
- {Text, "hello"},
- {Super, "**"},
- {EOF, ""},
- },
- },
- {
- pattern: "[日-語]",
- items: []Token{
- {RangeOpen, "["},
- {RangeLo, "æ—¥"},
- {RangeBetween, "-"},
- {RangeHi, "語"},
- {RangeClose, "]"},
- {EOF, ""},
- },
- },
- {
- pattern: "[!日-語]",
- items: []Token{
- {RangeOpen, "["},
- {Not, "!"},
- {RangeLo, "æ—¥"},
- {RangeBetween, "-"},
- {RangeHi, "語"},
- {RangeClose, "]"},
- {EOF, ""},
- },
- },
- {
- pattern: "[日本語]",
- items: []Token{
- {RangeOpen, "["},
- {Text, "日本語"},
- {RangeClose, "]"},
- {EOF, ""},
- },
- },
- {
- pattern: "[!日本語]",
- items: []Token{
- {RangeOpen, "["},
- {Not, "!"},
- {Text, "日本語"},
- {RangeClose, "]"},
- {EOF, ""},
- },
- },
- {
- pattern: "{a,b}",
- items: []Token{
- {TermsOpen, "{"},
- {Text, "a"},
- {Separator, ","},
- {Text, "b"},
- {TermsClose, "}"},
- {EOF, ""},
- },
- },
- {
- pattern: "/{z,ab}*",
- items: []Token{
- {Text, "/"},
- {TermsOpen, "{"},
- {Text, "z"},
- {Separator, ","},
- {Text, "ab"},
- {TermsClose, "}"},
- {Any, "*"},
- {EOF, ""},
- },
- },
- {
- pattern: "{[!日-語],*,?,{a,b,\\c}}",
- items: []Token{
- {TermsOpen, "{"},
- {RangeOpen, "["},
- {Not, "!"},
- {RangeLo, "æ—¥"},
- {RangeBetween, "-"},
- {RangeHi, "語"},
- {RangeClose, "]"},
- {Separator, ","},
- {Any, "*"},
- {Separator, ","},
- {Single, "?"},
- {Separator, ","},
- {TermsOpen, "{"},
- {Text, "a"},
- {Separator, ","},
- {Text, "b"},
- {Separator, ","},
- {Text, "c"},
- {TermsClose, "}"},
- {TermsClose, "}"},
- {EOF, ""},
- },
- },
- } {
- lexer := NewLexer(test.pattern)
- for i, exp := range test.items {
- act := lexer.Next()
- if act.Type != exp.Type {
- t.Errorf("#%d %q: wrong %d-th item type: exp: %q; act: %q\n\t(%s vs %s)", id, test.pattern, i, exp.Type, act.Type, exp, act)
- }
- if act.Raw != exp.Raw {
- t.Errorf("#%d %q: wrong %d-th item contents: exp: %q; act: %q\n\t(%s vs %s)", id, test.pattern, i, exp.Raw, act.Raw, exp, act)
- }
- }
- }
-}
diff --git a/vendor/github.com/gobwas/glob/util/runes/runes_test.go b/vendor/github.com/gobwas/glob/util/runes/runes_test.go
deleted file mode 100644
index 54498eb8..00000000
--- a/vendor/github.com/gobwas/glob/util/runes/runes_test.go
+++ /dev/null
@@ -1,222 +0,0 @@
-package runes
-
-import (
- "strings"
- "testing"
-)
-
-type indexTest struct {
- s []rune
- sep []rune
- out int
-}
-
-type equalTest struct {
- a []rune
- b []rune
- out bool
-}
-
-func newIndexTest(s, sep string, out int) indexTest {
- return indexTest{[]rune(s), []rune(sep), out}
-}
-func newEqualTest(s, sep string, out bool) equalTest {
- return equalTest{[]rune(s), []rune(sep), out}
-}
-
-var dots = "1....2....3....4"
-
-var indexTests = []indexTest{
- newIndexTest("", "", 0),
- newIndexTest("", "a", -1),
- newIndexTest("", "foo", -1),
- newIndexTest("fo", "foo", -1),
- newIndexTest("foo", "foo", 0),
- newIndexTest("oofofoofooo", "f", 2),
- newIndexTest("oofofoofooo", "foo", 4),
- newIndexTest("barfoobarfoo", "foo", 3),
- newIndexTest("foo", "", 0),
- newIndexTest("foo", "o", 1),
- newIndexTest("abcABCabc", "A", 3),
- // cases with one byte strings - test special case in Index()
- newIndexTest("", "a", -1),
- newIndexTest("x", "a", -1),
- newIndexTest("x", "x", 0),
- newIndexTest("abc", "a", 0),
- newIndexTest("abc", "b", 1),
- newIndexTest("abc", "c", 2),
- newIndexTest("abc", "x", -1),
-}
-
-var lastIndexTests = []indexTest{
- newIndexTest("", "", 0),
- newIndexTest("", "a", -1),
- newIndexTest("", "foo", -1),
- newIndexTest("fo", "foo", -1),
- newIndexTest("foo", "foo", 0),
- newIndexTest("foo", "f", 0),
- newIndexTest("oofofoofooo", "f", 7),
- newIndexTest("oofofoofooo", "foo", 7),
- newIndexTest("barfoobarfoo", "foo", 9),
- newIndexTest("foo", "", 3),
- newIndexTest("foo", "o", 2),
- newIndexTest("abcABCabc", "A", 3),
- newIndexTest("abcABCabc", "a", 6),
-}
-
-var indexAnyTests = []indexTest{
- newIndexTest("", "", -1),
- newIndexTest("", "a", -1),
- newIndexTest("", "abc", -1),
- newIndexTest("a", "", -1),
- newIndexTest("a", "a", 0),
- newIndexTest("aaa", "a", 0),
- newIndexTest("abc", "xyz", -1),
- newIndexTest("abc", "xcz", 2),
- newIndexTest("a☺b☻c☹d", "uvw☻xyz", 3),
- newIndexTest("aRegExp*", ".(|)*+?^$[]", 7),
- newIndexTest(dots+dots+dots, " ", -1),
-}
-
-// Execute f on each test case. funcName should be the name of f; it's used
-// in failure reports.
-func runIndexTests(t *testing.T, f func(s, sep []rune) int, funcName string, testCases []indexTest) {
- for _, test := range testCases {
- actual := f(test.s, test.sep)
- if actual != test.out {
- t.Errorf("%s(%q,%q) = %v; want %v", funcName, test.s, test.sep, actual, test.out)
- }
- }
-}
-
-func TestIndex(t *testing.T) { runIndexTests(t, Index, "Index", indexTests) }
-func TestLastIndex(t *testing.T) { runIndexTests(t, LastIndex, "LastIndex", lastIndexTests) }
-func TestIndexAny(t *testing.T) { runIndexTests(t, IndexAny, "IndexAny", indexAnyTests) }
-
-var equalTests = []equalTest{
- newEqualTest("a", "a", true),
- newEqualTest("a", "b", false),
- newEqualTest("a☺b☻c☹d", "uvw☻xyz", false),
- newEqualTest("a☺b☻c☹d", "a☺b☻c☹d", true),
-}
-
-func TestEqual(t *testing.T) {
- for _, test := range equalTests {
- actual := Equal(test.a, test.b)
- if actual != test.out {
- t.Errorf("Equal(%q,%q) = %v; want %v", test.a, test.b, actual, test.out)
- }
- }
-}
-
-func BenchmarkLastIndexRunes(b *testing.B) {
- r := []rune("abcdef")
- n := []rune("cd")
-
- for i := 0; i < b.N; i++ {
- LastIndex(r, n)
- }
-}
-func BenchmarkLastIndexStrings(b *testing.B) {
- r := "abcdef"
- n := "cd"
-
- for i := 0; i < b.N; i++ {
- strings.LastIndex(r, n)
- }
-}
-
-func BenchmarkIndexAnyRunes(b *testing.B) {
- s := []rune("...b...")
- c := []rune("abc")
-
- for i := 0; i < b.N; i++ {
- IndexAny(s, c)
- }
-}
-func BenchmarkIndexAnyStrings(b *testing.B) {
- s := "...b..."
- c := "abc"
-
- for i := 0; i < b.N; i++ {
- strings.IndexAny(s, c)
- }
-}
-
-func BenchmarkIndexRuneRunes(b *testing.B) {
- s := []rune("...b...")
- r := 'b'
-
- for i := 0; i < b.N; i++ {
- IndexRune(s, r)
- }
-}
-func BenchmarkIndexRuneStrings(b *testing.B) {
- s := "...b..."
- r := 'b'
-
- for i := 0; i < b.N; i++ {
- strings.IndexRune(s, r)
- }
-}
-
-func BenchmarkIndexRunes(b *testing.B) {
- r := []rune("abcdef")
- n := []rune("cd")
-
- for i := 0; i < b.N; i++ {
- Index(r, n)
- }
-}
-func BenchmarkIndexStrings(b *testing.B) {
- r := "abcdef"
- n := "cd"
-
- for i := 0; i < b.N; i++ {
- strings.Index(r, n)
- }
-}
-
-func BenchmarkEqualRunes(b *testing.B) {
- x := []rune("abc")
- y := []rune("abc")
-
- for i := 0; i < b.N; i++ {
- if Equal(x, y) {
- continue
- }
- }
-}
-
-func BenchmarkEqualStrings(b *testing.B) {
- x := "abc"
- y := "abc"
-
- for i := 0; i < b.N; i++ {
- if x == y {
- continue
- }
- }
-}
-
-func BenchmarkNotEqualRunes(b *testing.B) {
- x := []rune("abc")
- y := []rune("abcd")
-
- for i := 0; i < b.N; i++ {
- if Equal(x, y) {
- continue
- }
- }
-}
-
-func BenchmarkNotEqualStrings(b *testing.B) {
- x := "abc"
- y := "abcd"
-
- for i := 0; i < b.N; i++ {
- if x == y {
- continue
- }
- }
-}
diff --git a/vendor/github.com/google/go-github/.gitignore b/vendor/github.com/google/go-github/.gitignore
deleted file mode 100644
index 3515c4b9..00000000
--- a/vendor/github.com/google/go-github/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*.test
-coverage.out
diff --git a/vendor/github.com/google/go-github/.travis.yml b/vendor/github.com/google/go-github/.travis.yml
deleted file mode 100644
index f575d459..00000000
--- a/vendor/github.com/google/go-github/.travis.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-sudo: false
-language: go
-go:
- - 1.9.x
- - 1.8.x
- - 1.7.x
- - master
-matrix:
- allow_failures:
- - go: master
- fast_finish: true
-env:
- secure: "IrnPmy/rkIP6Nrbqji+u7MCAibQlA6WvPLEllmDQ2yZP/uIe3wLwwYbTu9BOkgzoLA+f8PA6u3pp/RhY/rtaM4NzHAO2nVfGIv9UHUQ3NGq0DYS6rODjVKhq7vkhELoagRewyqFVN4rE0LnExkknRMgjQfRke6/DA7u7Xm8JyhY=" # COVERALLS_TOKEN
-install:
- - go get golang.org/x/tools/cmd/cover
- - go get github.com/mattn/goveralls
- - # Do not install go-github yet, since we want it to happen inside the script step.
-script:
- - go get -t -v ./...
- - diff -u <(echo -n) <(gofmt -d -s .)
- - go generate -x ./... && git diff --exit-code; code=$?; git checkout -- .; (exit $code) # Check that go generate ./... produces a zero diff; clean up any changes afterwards.
- - go tool vet .
- - go test -v -race ./...
- - go test -v -tags=integration -run=^$ ./test/integration # Check that integration test builds successfully, but don't run any of the tests (they hit live GitHub API).
-
- # Generate test coverage report. This must be after all other tests.
- #- rm github/github-accessors.go # exclude generated code
- #- go test -v -covermode=count -coverprofile=coverage.out ./github
- #- $HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN
diff --git a/vendor/github.com/google/go-github/CONTRIBUTING.md b/vendor/github.com/google/go-github/CONTRIBUTING.md
deleted file mode 100644
index 8da635a6..00000000
--- a/vendor/github.com/google/go-github/CONTRIBUTING.md
+++ /dev/null
@@ -1,114 +0,0 @@
-# How to contribute #
-
-We'd love to accept your patches and contributions to this project. There are
-a just a few small guidelines you need to follow.
-
-
-## Contributor License Agreement ##
-
-Contributions to any Google project must be accompanied by a Contributor
-License Agreement. This is not a copyright **assignment**, it simply gives
-Google permission to use and redistribute your contributions as part of the
-project. Head over to to see your current
-agreements on file or to sign a new one.
-
-You generally only need to submit a CLA once, so if you've already submitted one
-(even if it was for a different project), you probably don't need to do it
-again.
-
-
-## Submitting a patch ##
-
- 1. It's generally best to start by opening a new issue describing the bug or
- feature you're intending to fix. Even if you think it's relatively minor,
- it's helpful to know what people are working on. Mention in the initial
- issue that you are planning to work on that bug or feature so that it can
- be assigned to you.
-
- 1. Follow the normal process of [forking][] the project, and setup a new
- branch to work in. It's important that each group of changes be done in
- separate branches in order to ensure that a pull request only includes the
- commits related to that bug or feature.
-
- 1. Go makes it very simple to ensure properly formatted code, so always run
- `go fmt` on your code before committing it. You should also run
- [golint][] over your code. As noted in the [golint readme][], it's not
- strictly necessary that your code be completely "lint-free", but this will
- help you find common style issues.
-
- 1. Any significant changes should almost always be accompanied by tests. The
- project already has good test coverage, so look at some of the existing
- tests if you're unsure how to go about it. [gocov][] and [gocov-html][]
- are invaluable tools for seeing which parts of your code aren't being
- exercised by your tests.
-
- 1. Please run:
- * `go generate github.com/google/go-github/...`
- * `go test github.com/google/go-github/...`
- * `go vet github.com/google/go-github/...`
-
- 1. Do your best to have [well-formed commit messages][] for each change.
- This provides consistency throughout the project, and ensures that commit
- messages are able to be formatted properly by various git tools.
-
- 1. Finally, push the commits to your fork and submit a [pull request][].
-
-[forking]: https://help.github.com/articles/fork-a-repo
-[golint]: https://github.com/golang/lint
-[golint readme]: https://github.com/golang/lint/blob/master/README.md
-[gocov]: https://github.com/axw/gocov
-[gocov-html]: https://github.com/matm/gocov-html
-[well-formed commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
-[squash]: http://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits
-[pull request]: https://help.github.com/articles/creating-a-pull-request
-
-
-## Other notes on code organization ##
-
-Currently, everything is defined in the main `github` package, with API methods
-broken into separate service objects. These services map directly to how
-the [GitHub API documentation][] is organized, so use that as your guide for
-where to put new methods.
-
-Code is organized in files also based pretty closely on the GitHub API
-documentation, following the format `{service}_{api}.go`. For example, methods
-defined at live in
-[repos_hooks.go][].
-
-[GitHub API documentation]: https://developer.github.com/v3/
-[repos_hooks.go]: https://github.com/google/go-github/blob/master/github/repos_hooks.go
-
-
-## Maintainer's Guide ##
-
-(These notes are mostly only for people merging in pull requests.)
-
-**Verify CLAs.** CLAs must be on file for the pull request submitter and commit
-author(s). Google's CLA verification system should handle this automatically
-and will set commit statuses as appropriate. If there's ever any question about
-a pull request, ask [willnorris](https://github.com/willnorris).
-
-**Always try to maintain a clean, linear git history.** With very few
-exceptions, running `git log` should not show a bunch of branching and merging.
-
-Never use the GitHub "merge" button, since it always creates a merge commit.
-Instead, check out the pull request locally ([these git aliases
-help][git-aliases]), then cherry-pick or rebase them onto master. If there are
-small cleanup commits, especially as a result of addressing code review
-comments, these should almost always be squashed down to a single commit. Don't
-bother squashing commits that really deserve to be separate though. If needed,
-feel free to amend additional small changes to the code or commit message that
-aren't worth going through code review for.
-
-If you made any changes like squashing commits, rebasing onto master, etc, then
-GitHub won't recognize that this is the same commit in order to mark the pull
-request as "merged". So instead, amend the commit message to include a line
-"Fixes #0", referencing the pull request number. This would be in addition to
-any other "Fixes" lines for closing related issues. If you forget to do this,
-you can also leave a comment on the pull request [like this][rebase-comment].
-If you made any other changes, it's worth noting that as well, [like
-this][modified-comment].
-
-[git-aliases]: https://github.com/willnorris/dotfiles/blob/d640d010c23b1116bdb3d4dc12088ed26120d87d/git/.gitconfig#L13-L15
-[rebase-comment]: https://github.com/google/go-github/pull/277#issuecomment-183035491
-[modified-comment]: https://github.com/google/go-github/pull/280#issuecomment-184859046
diff --git a/vendor/github.com/google/go-github/README.md b/vendor/github.com/google/go-github/README.md
deleted file mode 100644
index f416c81d..00000000
--- a/vendor/github.com/google/go-github/README.md
+++ /dev/null
@@ -1,244 +0,0 @@
-# go-github #
-
-go-github is a Go client library for accessing the [GitHub API v3][].
-
-**Documentation:** [](https://godoc.org/github.com/google/go-github/github)
-**Mailing List:** [go-github@googlegroups.com](https://groups.google.com/group/go-github)
-**Build Status:** [](https://travis-ci.org/google/go-github)
-**Test Coverage:** [](https://coveralls.io/r/google/go-github?branch=master)
-
-go-github requires Go version 1.7 or greater.
-
-If you're interested in using the [GraphQL API v4][], the recommended library is
-[shurcooL/githubql][].
-
-## Usage ##
-
-```go
-import "github.com/google/go-github/github"
-```
-
-Construct a new GitHub client, then use the various services on the client to
-access different parts of the GitHub API. For example:
-
-```go
-client := github.NewClient(nil)
-
-// list all organizations for user "willnorris"
-orgs, _, err := client.Organizations.List(ctx, "willnorris", nil)
-```
-
-Some API methods have optional parameters that can be passed. For example:
-
-```go
-client := github.NewClient(nil)
-
-// list public repositories for org "github"
-opt := &github.RepositoryListByOrgOptions{Type: "public"}
-repos, _, err := client.Repositories.ListByOrg(ctx, "github", opt)
-```
-
-The services of a client divide the API into logical chunks and correspond to
-the structure of the GitHub API documentation at
-https://developer.github.com/v3/.
-
-### Authentication ###
-
-The go-github library does not directly handle authentication. Instead, when
-creating a new client, pass an `http.Client` that can handle authentication for
-you. The easiest and recommended way to do this is using the [oauth2][]
-library, but you can always use any other library that provides an
-`http.Client`. If you have an OAuth2 access token (for example, a [personal
-API token][]), you can use it with the oauth2 library using:
-
-```go
-import "golang.org/x/oauth2"
-
-func main() {
- ctx := context.Background()
- ts := oauth2.StaticTokenSource(
- &oauth2.Token{AccessToken: "... your access token ..."},
- )
- tc := oauth2.NewClient(ctx, ts)
-
- client := github.NewClient(tc)
-
- // list all repositories for the authenticated user
- repos, _, err := client.Repositories.List(ctx, "", nil)
-}
-```
-
-Note that when using an authenticated Client, all calls made by the client will
-include the specified OAuth token. Therefore, authenticated clients should
-almost never be shared between different users.
-
-See the [oauth2 docs][] for complete instructions on using that library.
-
-For API methods that require HTTP Basic Authentication, use the
-[`BasicAuthTransport`](https://godoc.org/github.com/google/go-github/github#BasicAuthTransport).
-
-GitHub Apps authentication can be provided by the [ghinstallation](https://github.com/bradleyfalzon/ghinstallation)
-package.
-
-```go
-import "github.com/bradleyfalzon/ghinstallation"
-
-func main() {
- // Wrap the shared transport for use with the integration ID 1 authenticating with installation ID 99.
- itr, err := ghinstallation.NewKeyFromFile(http.DefaultTransport, 1, 99, "2016-10-19.private-key.pem")
- if err != nil {
- // Handle error.
- }
-
- // Use installation transport with client.
- client := github.NewClient(&http.Client{Transport: itr})
-
- // Use client...
-}
-```
-
-### Rate Limiting ###
-
-GitHub imposes a rate limit on all API clients. Unauthenticated clients are
-limited to 60 requests per hour, while authenticated clients can make up to
-5,000 requests per hour. The Search API has a custom rate limit. Unauthenticated
-clients are limited to 10 requests per minute, while authenticated clients
-can make up to 30 requests per minute. To receive the higher rate limit when
-making calls that are not issued on behalf of a user,
-use `UnauthenticatedRateLimitedTransport`.
-
-The returned `Response.Rate` value contains the rate limit information
-from the most recent API call. If a recent enough response isn't
-available, you can use `RateLimits` to fetch the most up-to-date rate
-limit data for the client.
-
-To detect an API rate limit error, you can check if its type is `*github.RateLimitError`:
-
-```go
-repos, _, err := client.Repositories.List(ctx, "", nil)
-if _, ok := err.(*github.RateLimitError); ok {
- log.Println("hit rate limit")
-}
-```
-
-Learn more about GitHub rate limiting at
-https://developer.github.com/v3/#rate-limiting.
-
-### Accepted Status ###
-
-Some endpoints may return a 202 Accepted status code, meaning that the
-information required is not yet ready and was scheduled to be gathered on
-the GitHub side. Methods known to behave like this are documented specifying
-this behavior.
-
-To detect this condition of error, you can check if its type is
-`*github.AcceptedError`:
-
-```go
-stats, _, err := client.Repositories.ListContributorsStats(ctx, org, repo)
-if _, ok := err.(*github.AcceptedError); ok {
- log.Println("scheduled on GitHub side")
-}
-```
-
-### Conditional Requests ###
-
-The GitHub API has good support for conditional requests which will help
-prevent you from burning through your rate limit, as well as help speed up your
-application. `go-github` does not handle conditional requests directly, but is
-instead designed to work with a caching `http.Transport`. We recommend using
-https://github.com/gregjones/httpcache for that.
-
-Learn more about GitHub conditional requests at
-https://developer.github.com/v3/#conditional-requests.
-
-### Creating and Updating Resources ###
-
-All structs for GitHub resources use pointer values for all non-repeated fields.
-This allows distinguishing between unset fields and those set to a zero-value.
-Helper functions have been provided to easily create these pointers for string,
-bool, and int values. For example:
-
-```go
-// create a new private repository named "foo"
-repo := &github.Repository{
- Name: github.String("foo"),
- Private: github.Bool(true),
-}
-client.Repositories.Create(ctx, "", repo)
-```
-
-Users who have worked with protocol buffers should find this pattern familiar.
-
-### Pagination ###
-
-All requests for resource collections (repos, pull requests, issues, etc.)
-support pagination. Pagination options are described in the
-`github.ListOptions` struct and passed to the list methods directly or as an
-embedded type of a more specific list options struct (for example
-`github.PullRequestListOptions`). Pages information is available via the
-`github.Response` struct.
-
-```go
-client := github.NewClient(nil)
-
-opt := &github.RepositoryListByOrgOptions{
- ListOptions: github.ListOptions{PerPage: 10},
-}
-// get all pages of results
-var allRepos []*github.Repository
-for {
- repos, resp, err := client.Repositories.ListByOrg(ctx, "github", opt)
- if err != nil {
- return err
- }
- allRepos = append(allRepos, repos...)
- if resp.NextPage == 0 {
- break
- }
- opt.Page = resp.NextPage
-}
-```
-
-For complete usage of go-github, see the full [package docs][].
-
-[GitHub API v3]: https://developer.github.com/v3/
-[oauth2]: https://github.com/golang/oauth2
-[oauth2 docs]: https://godoc.org/golang.org/x/oauth2
-[personal API token]: https://github.com/blog/1509-personal-api-tokens
-[package docs]: https://godoc.org/github.com/google/go-github/github
-[GraphQL API v4]: https://developer.github.com/v4/
-[shurcooL/githubql]: https://github.com/shurcooL/githubql
-
-### Google App Engine ###
-
-Go on App Engine Classic (which as of this writing uses Go 1.6) can not use
-the `"context"` import and still relies on `"golang.org/x/net/context"`.
-As a result, if you wish to continue to use `go-github` on App Engine Classic,
-you will need to rewrite all the `"context"` imports using the following command:
-
- gofmt -w -r '"context" -> "golang.org/x/net/context"' *.go
-
-See `with_appengine.go` for more details.
-
-### Integration Tests ###
-
-You can run integration tests from the `test` directory. See the integration tests [README](test/README.md).
-
-## Roadmap ##
-
-This library is being initially developed for an internal application at
-Google, so API methods will likely be implemented in the order that they are
-needed by that application. You can track the status of implementation in
-[this Google spreadsheet][roadmap]. Eventually, I would like to cover the entire
-GitHub API, so contributions are of course [always welcome][contributing]. The
-calling pattern is pretty well established, so adding new methods is relatively
-straightforward.
-
-[roadmap]: https://docs.google.com/spreadsheet/ccc?key=0ApoVX4GOiXr-dGNKN1pObFh6ek1DR2FKUjBNZ1FmaEE&usp=sharing
-[contributing]: CONTRIBUTING.md
-
-## License ##
-
-This library is distributed under the BSD-style license found in the [LICENSE](./LICENSE)
-file.
diff --git a/vendor/github.com/google/go-github/example/appengine/app.go b/vendor/github.com/google/go-github/example/appengine/app.go
deleted file mode 100644
index 4d6cc30c..00000000
--- a/vendor/github.com/google/go-github/example/appengine/app.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2017 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 demo provides an app that shows how to use the github package on
-// Google App Engine.
-package demo
-
-import (
- "fmt"
- "net/http"
- "os"
-
- "github.com/google/go-github/github"
- "golang.org/x/oauth2"
- "google.golang.org/appengine"
- "google.golang.org/appengine/log"
-)
-
-func init() {
- http.HandleFunc("/", handler)
-}
-
-func handler(w http.ResponseWriter, r *http.Request) {
- if r.URL.Path != "/" {
- http.NotFound(w, r)
- return
- }
-
- ctx := appengine.NewContext(r)
- ts := oauth2.StaticTokenSource(
- &oauth2.Token{AccessToken: os.Getenv("GITHUB_AUTH_TOKEN")},
- )
- tc := oauth2.NewClient(ctx, ts)
- client := github.NewClient(tc)
-
- commits, _, err := client.Repositories.ListCommits(ctx, "google", "go-github", nil)
- if err != nil {
- log.Errorf(ctx, "ListCommits: %v", err)
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
-
- w.Header().Set("Content-Type", "text/plain; charset=utf-8")
- for _, commit := range commits {
- fmt.Fprintln(w, commit.GetHTMLURL())
- }
-}
diff --git a/vendor/github.com/google/go-github/example/appengine/app.yaml b/vendor/github.com/google/go-github/example/appengine/app.yaml
deleted file mode 100644
index dca235fa..00000000
--- a/vendor/github.com/google/go-github/example/appengine/app.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2017 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.
-
-runtime: go
-api_version: go1
-
-handlers:
-- url: /.*
- script: _go_app
-
-env_variables:
- GITHUB_AUTH_TOKEN: "-your-auth-token-here-"
diff --git a/vendor/github.com/google/go-github/example/basicauth/main.go b/vendor/github.com/google/go-github/example/basicauth/main.go
deleted file mode 100644
index f67c3d66..00000000
--- a/vendor/github.com/google/go-github/example/basicauth/main.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2015 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.
-
-// The basicauth command demonstrates using the github.BasicAuthTransport,
-// including handling two-factor authentication. This won't currently work for
-// accounts that use SMS to receive one-time passwords.
-package main
-
-import (
- "bufio"
- "context"
- "fmt"
- "os"
- "strings"
- "syscall"
-
- "github.com/google/go-github/github"
- "golang.org/x/crypto/ssh/terminal"
-)
-
-func main() {
- r := bufio.NewReader(os.Stdin)
- fmt.Print("GitHub Username: ")
- username, _ := r.ReadString('\n')
-
- fmt.Print("GitHub Password: ")
- bytePassword, _ := terminal.ReadPassword(int(syscall.Stdin))
- password := string(bytePassword)
-
- tp := github.BasicAuthTransport{
- Username: strings.TrimSpace(username),
- Password: strings.TrimSpace(password),
- }
-
- client := github.NewClient(tp.Client())
- ctx := context.Background()
- user, _, err := client.Users.Get(ctx, "")
-
- // Is this a two-factor auth error? If so, prompt for OTP and try again.
- if _, ok := err.(*github.TwoFactorAuthError); ok {
- fmt.Print("\nGitHub OTP: ")
- otp, _ := r.ReadString('\n')
- tp.OTP = strings.TrimSpace(otp)
- user, _, err = client.Users.Get(ctx, "")
- }
-
- if err != nil {
- fmt.Printf("\nerror: %v\n", err)
- return
- }
-
- fmt.Printf("\n%v\n", github.Stringify(user))
-}
diff --git a/vendor/github.com/google/go-github/github/activity_events_test.go b/vendor/github.com/google/go-github/github/activity_events_test.go
deleted file mode 100644
index 0b01c4a0..00000000
--- a/vendor/github.com/google/go-github/github/activity_events_test.go
+++ /dev/null
@@ -1,349 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestActivityService_ListEvents(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/events", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":"1"},{"id":"2"}]`)
- })
-
- opt := &ListOptions{Page: 2}
- events, _, err := client.Activity.ListEvents(context.Background(), opt)
- if err != nil {
- t.Errorf("Activities.ListEvents returned error: %v", err)
- }
-
- want := []*Event{{ID: String("1")}, {ID: String("2")}}
- if !reflect.DeepEqual(events, want) {
- t.Errorf("Activities.ListEvents returned %+v, want %+v", events, want)
- }
-}
-
-func TestActivityService_ListRepositoryEvents(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/events", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":"1"},{"id":"2"}]`)
- })
-
- opt := &ListOptions{Page: 2}
- events, _, err := client.Activity.ListRepositoryEvents(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Activities.ListRepositoryEvents returned error: %v", err)
- }
-
- want := []*Event{{ID: String("1")}, {ID: String("2")}}
- if !reflect.DeepEqual(events, want) {
- t.Errorf("Activities.ListRepositoryEvents returned %+v, want %+v", events, want)
- }
-}
-
-func TestActivityService_ListRepositoryEvents_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Activity.ListRepositoryEvents(context.Background(), "%", "%", nil)
- testURLParseError(t, err)
-}
-
-func TestActivityService_ListIssueEventsForRepository(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/events", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":1},{"id":2}]`)
- })
-
- opt := &ListOptions{Page: 2}
- events, _, err := client.Activity.ListIssueEventsForRepository(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Activities.ListIssueEventsForRepository returned error: %v", err)
- }
-
- want := []*IssueEvent{{ID: Int64(1)}, {ID: Int64(2)}}
- if !reflect.DeepEqual(events, want) {
- t.Errorf("Activities.ListIssueEventsForRepository returned %+v, want %+v", events, want)
- }
-}
-
-func TestActivityService_ListIssueEventsForRepository_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Activity.ListIssueEventsForRepository(context.Background(), "%", "%", nil)
- testURLParseError(t, err)
-}
-
-func TestActivityService_ListEventsForRepoNetwork(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/networks/o/r/events", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":"1"},{"id":"2"}]`)
- })
-
- opt := &ListOptions{Page: 2}
- events, _, err := client.Activity.ListEventsForRepoNetwork(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Activities.ListEventsForRepoNetwork returned error: %v", err)
- }
-
- want := []*Event{{ID: String("1")}, {ID: String("2")}}
- if !reflect.DeepEqual(events, want) {
- t.Errorf("Activities.ListEventsForRepoNetwork returned %+v, want %+v", events, want)
- }
-}
-
-func TestActivityService_ListEventsForRepoNetwork_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Activity.ListEventsForRepoNetwork(context.Background(), "%", "%", nil)
- testURLParseError(t, err)
-}
-
-func TestActivityService_ListEventsForOrganization(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/events", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":"1"},{"id":"2"}]`)
- })
-
- opt := &ListOptions{Page: 2}
- events, _, err := client.Activity.ListEventsForOrganization(context.Background(), "o", opt)
- if err != nil {
- t.Errorf("Activities.ListEventsForOrganization returned error: %v", err)
- }
-
- want := []*Event{{ID: String("1")}, {ID: String("2")}}
- if !reflect.DeepEqual(events, want) {
- t.Errorf("Activities.ListEventsForOrganization returned %+v, want %+v", events, want)
- }
-}
-
-func TestActivityService_ListEventsForOrganization_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Activity.ListEventsForOrganization(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestActivityService_ListEventsPerformedByUser_all(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/events", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":"1"},{"id":"2"}]`)
- })
-
- opt := &ListOptions{Page: 2}
- events, _, err := client.Activity.ListEventsPerformedByUser(context.Background(), "u", false, opt)
- if err != nil {
- t.Errorf("Events.ListPerformedByUser returned error: %v", err)
- }
-
- want := []*Event{{ID: String("1")}, {ID: String("2")}}
- if !reflect.DeepEqual(events, want) {
- t.Errorf("Events.ListPerformedByUser returned %+v, want %+v", events, want)
- }
-}
-
-func TestActivityService_ListEventsPerformedByUser_publicOnly(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/events/public", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `[{"id":"1"},{"id":"2"}]`)
- })
-
- events, _, err := client.Activity.ListEventsPerformedByUser(context.Background(), "u", true, nil)
- if err != nil {
- t.Errorf("Events.ListPerformedByUser returned error: %v", err)
- }
-
- want := []*Event{{ID: String("1")}, {ID: String("2")}}
- if !reflect.DeepEqual(events, want) {
- t.Errorf("Events.ListPerformedByUser returned %+v, want %+v", events, want)
- }
-}
-
-func TestActivityService_ListEventsPerformedByUser_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Activity.ListEventsPerformedByUser(context.Background(), "%", false, nil)
- testURLParseError(t, err)
-}
-
-func TestActivityService_ListEventsReceivedByUser_all(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/received_events", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":"1"},{"id":"2"}]`)
- })
-
- opt := &ListOptions{Page: 2}
- events, _, err := client.Activity.ListEventsReceivedByUser(context.Background(), "u", false, opt)
- if err != nil {
- t.Errorf("Events.ListReceivedByUser returned error: %v", err)
- }
-
- want := []*Event{{ID: String("1")}, {ID: String("2")}}
- if !reflect.DeepEqual(events, want) {
- t.Errorf("Events.ListReceivedUser returned %+v, want %+v", events, want)
- }
-}
-
-func TestActivityService_ListEventsReceivedByUser_publicOnly(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/received_events/public", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `[{"id":"1"},{"id":"2"}]`)
- })
-
- events, _, err := client.Activity.ListEventsReceivedByUser(context.Background(), "u", true, nil)
- if err != nil {
- t.Errorf("Events.ListReceivedByUser returned error: %v", err)
- }
-
- want := []*Event{{ID: String("1")}, {ID: String("2")}}
- if !reflect.DeepEqual(events, want) {
- t.Errorf("Events.ListReceivedByUser returned %+v, want %+v", events, want)
- }
-}
-
-func TestActivityService_ListEventsReceivedByUser_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Activity.ListEventsReceivedByUser(context.Background(), "%", false, nil)
- testURLParseError(t, err)
-}
-
-func TestActivityService_ListUserEventsForOrganization(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/events/orgs/o", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":"1"},{"id":"2"}]`)
- })
-
- opt := &ListOptions{Page: 2}
- events, _, err := client.Activity.ListUserEventsForOrganization(context.Background(), "o", "u", opt)
- if err != nil {
- t.Errorf("Activities.ListUserEventsForOrganization returned error: %v", err)
- }
-
- want := []*Event{{ID: String("1")}, {ID: String("2")}}
- if !reflect.DeepEqual(events, want) {
- t.Errorf("Activities.ListUserEventsForOrganization returned %+v, want %+v", events, want)
- }
-}
-
-func TestActivityService_EventParsePayload_typed(t *testing.T) {
- raw := []byte(`{"type": "PushEvent","payload":{"push_id": 1}}`)
- var event *Event
- if err := json.Unmarshal(raw, &event); err != nil {
- t.Fatalf("Unmarshal Event returned error: %v", err)
- }
-
- want := &PushEvent{PushID: Int64(1)}
- got, err := event.ParsePayload()
- if err != nil {
- t.Fatalf("ParsePayload returned unexpected error: %v", err)
- }
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Event.ParsePayload returned %+v, want %+v", got, want)
- }
-}
-
-// TestEvent_Payload_untyped checks that unrecognized events are parsed to an
-// interface{} value (instead of being discarded or throwing an error), for
-// forward compatibility with new event types.
-func TestActivityService_EventParsePayload_untyped(t *testing.T) {
- raw := []byte(`{"type": "UnrecognizedEvent","payload":{"field": "val"}}`)
- var event *Event
- if err := json.Unmarshal(raw, &event); err != nil {
- t.Fatalf("Unmarshal Event returned error: %v", err)
- }
-
- want := map[string]interface{}{"field": "val"}
- got, err := event.ParsePayload()
- if err != nil {
- t.Fatalf("ParsePayload returned unexpected error: %v", err)
- }
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Event.ParsePayload returned %+v, want %+v", got, want)
- }
-}
-
-func TestActivityService_EventParsePayload_installation(t *testing.T) {
- raw := []byte(`{"type": "PullRequestEvent","payload":{"installation":{"id":1}}}`)
- var event *Event
- if err := json.Unmarshal(raw, &event); err != nil {
- t.Fatalf("Unmarshal Event returned error: %v", err)
- }
-
- want := &PullRequestEvent{Installation: &Installation{ID: Int64(1)}}
- got, err := event.ParsePayload()
- if err != nil {
- t.Fatalf("ParsePayload returned unexpected error: %v", err)
- }
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Event.ParsePayload returned %+v, want %+v", got, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/activity_notifications_test.go b/vendor/github.com/google/go-github/github/activity_notifications_test.go
deleted file mode 100644
index 292e3e24..00000000
--- a/vendor/github.com/google/go-github/github/activity_notifications_test.go
+++ /dev/null
@@ -1,204 +0,0 @@
-// Copyright 2014 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
- "time"
-)
-
-func TestActivityService_ListNotification(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/notifications", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "all": "true",
- "participating": "true",
- "since": "2006-01-02T15:04:05Z",
- "before": "2007-03-04T15:04:05Z",
- })
-
- fmt.Fprint(w, `[{"id":"1", "subject":{"title":"t"}}]`)
- })
-
- opt := &NotificationListOptions{
- All: true,
- Participating: true,
- Since: time.Date(2006, 01, 02, 15, 04, 05, 0, time.UTC),
- Before: time.Date(2007, 03, 04, 15, 04, 05, 0, time.UTC),
- }
- notifications, _, err := client.Activity.ListNotifications(context.Background(), opt)
- if err != nil {
- t.Errorf("Activity.ListNotifications returned error: %v", err)
- }
-
- want := []*Notification{{ID: String("1"), Subject: &NotificationSubject{Title: String("t")}}}
- if !reflect.DeepEqual(notifications, want) {
- t.Errorf("Activity.ListNotifications returned %+v, want %+v", notifications, want)
- }
-}
-
-func TestActivityService_ListRepositoryNotification(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/notifications", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `[{"id":"1"}]`)
- })
-
- notifications, _, err := client.Activity.ListRepositoryNotifications(context.Background(), "o", "r", nil)
- if err != nil {
- t.Errorf("Activity.ListRepositoryNotifications returned error: %v", err)
- }
-
- want := []*Notification{{ID: String("1")}}
- if !reflect.DeepEqual(notifications, want) {
- t.Errorf("Activity.ListRepositoryNotifications returned %+v, want %+v", notifications, want)
- }
-}
-
-func TestActivityService_MarkNotificationsRead(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/notifications", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- testHeader(t, r, "Content-Type", "application/json")
- testBody(t, r, `{"last_read_at":"2006-01-02T15:04:05Z"}`+"\n")
-
- w.WriteHeader(http.StatusResetContent)
- })
-
- _, err := client.Activity.MarkNotificationsRead(context.Background(), time.Date(2006, 01, 02, 15, 04, 05, 0, time.UTC))
- if err != nil {
- t.Errorf("Activity.MarkNotificationsRead returned error: %v", err)
- }
-}
-
-func TestActivityService_MarkRepositoryNotificationsRead(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/notifications", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- testHeader(t, r, "Content-Type", "application/json")
- testBody(t, r, `{"last_read_at":"2006-01-02T15:04:05Z"}`+"\n")
-
- w.WriteHeader(http.StatusResetContent)
- })
-
- _, err := client.Activity.MarkRepositoryNotificationsRead(context.Background(), "o", "r", time.Date(2006, 01, 02, 15, 04, 05, 0, time.UTC))
- if err != nil {
- t.Errorf("Activity.MarkRepositoryNotificationsRead returned error: %v", err)
- }
-}
-
-func TestActivityService_GetThread(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/notifications/threads/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id":"1"}`)
- })
-
- notification, _, err := client.Activity.GetThread(context.Background(), "1")
- if err != nil {
- t.Errorf("Activity.GetThread returned error: %v", err)
- }
-
- want := &Notification{ID: String("1")}
- if !reflect.DeepEqual(notification, want) {
- t.Errorf("Activity.GetThread returned %+v, want %+v", notification, want)
- }
-}
-
-func TestActivityService_MarkThreadRead(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/notifications/threads/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PATCH")
- w.WriteHeader(http.StatusResetContent)
- })
-
- _, err := client.Activity.MarkThreadRead(context.Background(), "1")
- if err != nil {
- t.Errorf("Activity.MarkThreadRead returned error: %v", err)
- }
-}
-
-func TestActivityService_GetThreadSubscription(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/notifications/threads/1/subscription", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"subscribed":true}`)
- })
-
- sub, _, err := client.Activity.GetThreadSubscription(context.Background(), "1")
- if err != nil {
- t.Errorf("Activity.GetThreadSubscription returned error: %v", err)
- }
-
- want := &Subscription{Subscribed: Bool(true)}
- if !reflect.DeepEqual(sub, want) {
- t.Errorf("Activity.GetThreadSubscription returned %+v, want %+v", sub, want)
- }
-}
-
-func TestActivityService_SetThreadSubscription(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Subscription{Subscribed: Bool(true)}
-
- mux.HandleFunc("/notifications/threads/1/subscription", func(w http.ResponseWriter, r *http.Request) {
- v := new(Subscription)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PUT")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"ignored":true}`)
- })
-
- sub, _, err := client.Activity.SetThreadSubscription(context.Background(), "1", input)
- if err != nil {
- t.Errorf("Activity.SetThreadSubscription returned error: %v", err)
- }
-
- want := &Subscription{Ignored: Bool(true)}
- if !reflect.DeepEqual(sub, want) {
- t.Errorf("Activity.SetThreadSubscription returned %+v, want %+v", sub, want)
- }
-}
-
-func TestActivityService_DeleteThreadSubscription(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/notifications/threads/1/subscription", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Activity.DeleteThreadSubscription(context.Background(), "1")
- if err != nil {
- t.Errorf("Activity.DeleteThreadSubscription returned error: %v", err)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/activity_star_test.go b/vendor/github.com/google/go-github/github/activity_star_test.go
deleted file mode 100644
index 80523f8e..00000000
--- a/vendor/github.com/google/go-github/github/activity_star_test.go
+++ /dev/null
@@ -1,184 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
- "time"
-)
-
-func TestActivityService_ListStargazers(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/stargazers", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeStarringPreview)
- testFormValues(t, r, values{
- "page": "2",
- })
-
- fmt.Fprint(w, `[{"starred_at":"2002-02-10T15:30:00Z","user":{"id":1}}]`)
- })
-
- stargazers, _, err := client.Activity.ListStargazers(context.Background(), "o", "r", &ListOptions{Page: 2})
- if err != nil {
- t.Errorf("Activity.ListStargazers returned error: %v", err)
- }
-
- want := []*Stargazer{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, User: &User{ID: Int64(1)}}}
- if !reflect.DeepEqual(stargazers, want) {
- t.Errorf("Activity.ListStargazers returned %+v, want %+v", stargazers, want)
- }
-}
-
-func TestActivityService_ListStarred_authenticatedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/starred", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeStarringPreview)
- fmt.Fprint(w, `[{"starred_at":"2002-02-10T15:30:00Z","repo":{"id":1}}]`)
- })
-
- repos, _, err := client.Activity.ListStarred(context.Background(), "", nil)
- if err != nil {
- t.Errorf("Activity.ListStarred returned error: %v", err)
- }
-
- want := []*StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Int64(1)}}}
- if !reflect.DeepEqual(repos, want) {
- t.Errorf("Activity.ListStarred returned %+v, want %+v", repos, want)
- }
-}
-
-func TestActivityService_ListStarred_specifiedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/starred", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeStarringPreview)
- testFormValues(t, r, values{
- "sort": "created",
- "direction": "asc",
- "page": "2",
- })
- fmt.Fprint(w, `[{"starred_at":"2002-02-10T15:30:00Z","repo":{"id":2}}]`)
- })
-
- opt := &ActivityListStarredOptions{"created", "asc", ListOptions{Page: 2}}
- repos, _, err := client.Activity.ListStarred(context.Background(), "u", opt)
- if err != nil {
- t.Errorf("Activity.ListStarred returned error: %v", err)
- }
-
- want := []*StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Int64(2)}}}
- if !reflect.DeepEqual(repos, want) {
- t.Errorf("Activity.ListStarred returned %+v, want %+v", repos, want)
- }
-}
-
-func TestActivityService_ListStarred_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Activity.ListStarred(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestActivityService_IsStarred_hasStar(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNoContent)
- })
-
- star, _, err := client.Activity.IsStarred(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Activity.IsStarred returned error: %v", err)
- }
- if want := true; star != want {
- t.Errorf("Activity.IsStarred returned %+v, want %+v", star, want)
- }
-}
-
-func TestActivityService_IsStarred_noStar(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNotFound)
- })
-
- star, _, err := client.Activity.IsStarred(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Activity.IsStarred returned error: %v", err)
- }
- if want := false; star != want {
- t.Errorf("Activity.IsStarred returned %+v, want %+v", star, want)
- }
-}
-
-func TestActivityService_IsStarred_invalidID(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Activity.IsStarred(context.Background(), "%", "%")
- testURLParseError(t, err)
-}
-
-func TestActivityService_Star(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- })
-
- _, err := client.Activity.Star(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Activity.Star returned error: %v", err)
- }
-}
-
-func TestActivityService_Star_invalidID(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Activity.Star(context.Background(), "%", "%")
- testURLParseError(t, err)
-}
-
-func TestActivityService_Unstar(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Activity.Unstar(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Activity.Unstar returned error: %v", err)
- }
-}
-
-func TestActivityService_Unstar_invalidID(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Activity.Unstar(context.Background(), "%", "%")
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/activity_test.go b/vendor/github.com/google/go-github/github/activity_test.go
deleted file mode 100644
index 92b42d3a..00000000
--- a/vendor/github.com/google/go-github/github/activity_test.go
+++ /dev/null
@@ -1,129 +0,0 @@
-// 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
-
-import (
- "context"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestActivityService_List(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/feeds", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
-
- w.WriteHeader(http.StatusOK)
- w.Write(feedsJSON)
- })
-
- got, _, err := client.Activity.ListFeeds(context.Background())
- if err != nil {
- t.Errorf("Activity.ListFeeds returned error: %v", err)
- }
- if want := wantFeeds; !reflect.DeepEqual(got, want) {
- t.Errorf("Activity.ListFeeds = %+v, want %+v", got, want)
- }
-}
-
-var feedsJSON = []byte(`{
- "timeline_url": "https://github.com/timeline",
- "user_url": "https://github.com/{user}",
- "current_user_public_url": "https://github.com/defunkt",
- "current_user_url": "https://github.com/defunkt.private?token=abc123",
- "current_user_actor_url": "https://github.com/defunkt.private.actor?token=abc123",
- "current_user_organization_url": "",
- "current_user_organization_urls": [
- "https://github.com/organizations/github/defunkt.private.atom?token=abc123"
- ],
- "_links": {
- "timeline": {
- "href": "https://github.com/timeline",
- "type": "application/atom+xml"
- },
- "user": {
- "href": "https://github.com/{user}",
- "type": "application/atom+xml"
- },
- "current_user_public": {
- "href": "https://github.com/defunkt",
- "type": "application/atom+xml"
- },
- "current_user": {
- "href": "https://github.com/defunkt.private?token=abc123",
- "type": "application/atom+xml"
- },
- "current_user_actor": {
- "href": "https://github.com/defunkt.private.actor?token=abc123",
- "type": "application/atom+xml"
- },
- "current_user_organization": {
- "href": "",
- "type": ""
- },
- "current_user_organizations": [
- {
- "href": "https://github.com/organizations/github/defunkt.private.atom?token=abc123",
- "type": "application/atom+xml"
- }
- ]
- }
-}`)
-
-var wantFeeds = &Feeds{
- TimelineURL: String("https://github.com/timeline"),
- UserURL: String("https://github.com/{user}"),
- CurrentUserPublicURL: String("https://github.com/defunkt"),
- CurrentUserURL: String("https://github.com/defunkt.private?token=abc123"),
- CurrentUserActorURL: String("https://github.com/defunkt.private.actor?token=abc123"),
- CurrentUserOrganizationURL: String(""),
- CurrentUserOrganizationURLs: []string{
- "https://github.com/organizations/github/defunkt.private.atom?token=abc123",
- },
- Links: &struct {
- Timeline *FeedLink `json:"timeline,omitempty"`
- User *FeedLink `json:"user,omitempty"`
- CurrentUserPublic *FeedLink `json:"current_user_public,omitempty"`
- CurrentUser *FeedLink `json:"current_user,omitempty"`
- CurrentUserActor *FeedLink `json:"current_user_actor,omitempty"`
- CurrentUserOrganization *FeedLink `json:"current_user_organization,omitempty"`
- CurrentUserOrganizations []FeedLink `json:"current_user_organizations,omitempty"`
- }{
- Timeline: &FeedLink{
- HRef: String("https://github.com/timeline"),
- Type: String("application/atom+xml"),
- },
- User: &FeedLink{
- HRef: String("https://github.com/{user}"),
- Type: String("application/atom+xml"),
- },
- CurrentUserPublic: &FeedLink{
- HRef: String("https://github.com/defunkt"),
- Type: String("application/atom+xml"),
- },
- CurrentUser: &FeedLink{
- HRef: String("https://github.com/defunkt.private?token=abc123"),
- Type: String("application/atom+xml"),
- },
- CurrentUserActor: &FeedLink{
- HRef: String("https://github.com/defunkt.private.actor?token=abc123"),
- Type: String("application/atom+xml"),
- },
- CurrentUserOrganization: &FeedLink{
- HRef: String(""),
- Type: String(""),
- },
- CurrentUserOrganizations: []FeedLink{
- {
- HRef: String("https://github.com/organizations/github/defunkt.private.atom?token=abc123"),
- Type: String("application/atom+xml"),
- },
- },
- },
-}
diff --git a/vendor/github.com/google/go-github/github/activity_watching_test.go b/vendor/github.com/google/go-github/github/activity_watching_test.go
deleted file mode 100644
index b017d8d5..00000000
--- a/vendor/github.com/google/go-github/github/activity_watching_test.go
+++ /dev/null
@@ -1,184 +0,0 @@
-// Copyright 2014 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestActivityService_ListWatchers(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/subscribers", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
-
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- watchers, _, err := client.Activity.ListWatchers(context.Background(), "o", "r", &ListOptions{Page: 2})
- if err != nil {
- t.Errorf("Activity.ListWatchers returned error: %v", err)
- }
-
- want := []*User{{ID: Int64(1)}}
- if !reflect.DeepEqual(watchers, want) {
- t.Errorf("Activity.ListWatchers returned %+v, want %+v", watchers, want)
- }
-}
-
-func TestActivityService_ListWatched_authenticatedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/subscriptions", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- watched, _, err := client.Activity.ListWatched(context.Background(), "", &ListOptions{Page: 2})
- if err != nil {
- t.Errorf("Activity.ListWatched returned error: %v", err)
- }
-
- want := []*Repository{{ID: Int64(1)}}
- if !reflect.DeepEqual(watched, want) {
- t.Errorf("Activity.ListWatched returned %+v, want %+v", watched, want)
- }
-}
-
-func TestActivityService_ListWatched_specifiedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/subscriptions", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- watched, _, err := client.Activity.ListWatched(context.Background(), "u", &ListOptions{Page: 2})
- if err != nil {
- t.Errorf("Activity.ListWatched returned error: %v", err)
- }
-
- want := []*Repository{{ID: Int64(1)}}
- if !reflect.DeepEqual(watched, want) {
- t.Errorf("Activity.ListWatched returned %+v, want %+v", watched, want)
- }
-}
-
-func TestActivityService_GetRepositorySubscription_true(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"subscribed":true}`)
- })
-
- sub, _, err := client.Activity.GetRepositorySubscription(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Activity.GetRepositorySubscription returned error: %v", err)
- }
-
- want := &Subscription{Subscribed: Bool(true)}
- if !reflect.DeepEqual(sub, want) {
- t.Errorf("Activity.GetRepositorySubscription returned %+v, want %+v", sub, want)
- }
-}
-
-func TestActivityService_GetRepositorySubscription_false(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNotFound)
- })
-
- sub, _, err := client.Activity.GetRepositorySubscription(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Activity.GetRepositorySubscription returned error: %v", err)
- }
-
- var want *Subscription
- if !reflect.DeepEqual(sub, want) {
- t.Errorf("Activity.GetRepositorySubscription returned %+v, want %+v", sub, want)
- }
-}
-
-func TestActivityService_GetRepositorySubscription_error(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusBadRequest)
- })
-
- _, _, err := client.Activity.GetRepositorySubscription(context.Background(), "o", "r")
- if err == nil {
- t.Errorf("Expected HTTP 400 response")
- }
-}
-
-func TestActivityService_SetRepositorySubscription(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Subscription{Subscribed: Bool(true)}
-
- mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) {
- v := new(Subscription)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PUT")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"ignored":true}`)
- })
-
- sub, _, err := client.Activity.SetRepositorySubscription(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("Activity.SetRepositorySubscription returned error: %v", err)
- }
-
- want := &Subscription{Ignored: Bool(true)}
- if !reflect.DeepEqual(sub, want) {
- t.Errorf("Activity.SetRepositorySubscription returned %+v, want %+v", sub, want)
- }
-}
-
-func TestActivityService_DeleteRepositorySubscription(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Activity.DeleteRepositorySubscription(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Activity.DeleteRepositorySubscription returned error: %v", err)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/admin_stats_test.go b/vendor/github.com/google/go-github/github/admin_stats_test.go
deleted file mode 100644
index 9433adc3..00000000
--- a/vendor/github.com/google/go-github/github/admin_stats_test.go
+++ /dev/null
@@ -1,142 +0,0 @@
-package github
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestAdminService_GetAdminStats(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/enterprise/stats/all", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
-
- fmt.Fprint(w, `
-{
- "repos": {
- "total_repos": 212,
- "root_repos": 194,
- "fork_repos": 18,
- "org_repos": 51,
- "total_pushes": 3082,
- "total_wikis": 15
- },
- "hooks": {
- "total_hooks": 27,
- "active_hooks": 23,
- "inactive_hooks": 4
- },
- "pages": {
- "total_pages": 36
- },
- "orgs": {
- "total_orgs": 33,
- "disabled_orgs": 0,
- "total_teams": 60,
- "total_team_members": 314
- },
- "users": {
- "total_users": 254,
- "admin_users": 45,
- "suspended_users": 21
- },
- "pulls": {
- "total_pulls": 86,
- "merged_pulls": 60,
- "mergeable_pulls": 21,
- "unmergeable_pulls": 3
- },
- "issues": {
- "total_issues": 179,
- "open_issues": 83,
- "closed_issues": 96
- },
- "milestones": {
- "total_milestones": 7,
- "open_milestones": 6,
- "closed_milestones": 1
- },
- "gists": {
- "total_gists": 178,
- "private_gists": 151,
- "public_gists": 25
- },
- "comments": {
- "total_commit_comments": 6,
- "total_gist_comments": 28,
- "total_issue_comments": 366,
- "total_pull_request_comments": 30
- }
-}
-`)
- })
-
- stats, _, err := client.Admin.GetAdminStats(context.Background())
- if err != nil {
- t.Errorf("AdminService.GetAdminStats returned error: %v", err)
- }
-
- want := &AdminStats{
- Repos: &RepoStats{
- TotalRepos: Int(212),
- RootRepos: Int(194),
- ForkRepos: Int(18),
- OrgRepos: Int(51),
- TotalPushes: Int(3082),
- TotalWikis: Int(15),
- },
- Hooks: &HookStats{
- TotalHooks: Int(27),
- ActiveHooks: Int(23),
- InactiveHooks: Int(4),
- },
- Pages: &PageStats{
- TotalPages: Int(36),
- },
- Orgs: &OrgStats{
- TotalOrgs: Int(33),
- DisabledOrgs: Int(0),
- TotalTeams: Int(60),
- TotalTeamMembers: Int(314),
- },
- Users: &UserStats{
- TotalUsers: Int(254),
- AdminUsers: Int(45),
- SuspendedUsers: Int(21),
- },
- Pulls: &PullStats{
- TotalPulls: Int(86),
- MergedPulls: Int(60),
- MergablePulls: Int(21),
- UnmergablePulls: Int(3),
- },
- Issues: &IssueStats{
- TotalIssues: Int(179),
- OpenIssues: Int(83),
- ClosedIssues: Int(96),
- },
- Milestones: &MilestoneStats{
- TotalMilestones: Int(7),
- OpenMilestones: Int(6),
- ClosedMilestones: Int(1),
- },
- Gists: &GistStats{
- TotalGists: Int(178),
- PrivateGists: Int(151),
- PublicGists: Int(25),
- },
- Comments: &CommentStats{
- TotalCommitComments: Int(6),
- TotalGistComments: Int(28),
- TotalIssueComments: Int(366),
- TotalPullRequestComments: Int(30),
- },
- }
- if !reflect.DeepEqual(stats, want) {
- t.Errorf("AdminService.GetAdminStats returned %+v, want %+v", stats, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/admin_test.go b/vendor/github.com/google/go-github/github/admin_test.go
deleted file mode 100644
index 8979686f..00000000
--- a/vendor/github.com/google/go-github/github/admin_test.go
+++ /dev/null
@@ -1,81 +0,0 @@
-// 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestAdminService_UpdateUserLDAPMapping(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &UserLDAPMapping{
- LDAPDN: String("uid=asdf,ou=users,dc=github,dc=com"),
- }
-
- mux.HandleFunc("/admin/ldap/users/u/mapping", func(w http.ResponseWriter, r *http.Request) {
- v := new(UserLDAPMapping)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
- fmt.Fprint(w, `{"id":1,"ldap_dn":"uid=asdf,ou=users,dc=github,dc=com"}`)
- })
-
- mapping, _, err := client.Admin.UpdateUserLDAPMapping(context.Background(), "u", input)
- if err != nil {
- t.Errorf("Admin.UpdateUserLDAPMapping returned error: %v", err)
- }
-
- want := &UserLDAPMapping{
- ID: Int64(1),
- LDAPDN: String("uid=asdf,ou=users,dc=github,dc=com"),
- }
- if !reflect.DeepEqual(mapping, want) {
- t.Errorf("Admin.UpdateUserLDAPMapping returned %+v, want %+v", mapping, want)
- }
-}
-
-func TestAdminService_UpdateTeamLDAPMapping(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &TeamLDAPMapping{
- LDAPDN: String("cn=Enterprise Ops,ou=teams,dc=github,dc=com"),
- }
-
- mux.HandleFunc("/admin/ldap/teams/1/mapping", func(w http.ResponseWriter, r *http.Request) {
- v := new(TeamLDAPMapping)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
- fmt.Fprint(w, `{"id":1,"ldap_dn":"cn=Enterprise Ops,ou=teams,dc=github,dc=com"}`)
- })
-
- mapping, _, err := client.Admin.UpdateTeamLDAPMapping(context.Background(), 1, input)
- if err != nil {
- t.Errorf("Admin.UpdateTeamLDAPMapping returned error: %v", err)
- }
-
- want := &TeamLDAPMapping{
- ID: Int64(1),
- LDAPDN: String("cn=Enterprise Ops,ou=teams,dc=github,dc=com"),
- }
- if !reflect.DeepEqual(mapping, want) {
- t.Errorf("Admin.UpdateTeamLDAPMapping returned %+v, want %+v", mapping, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/apps_installation_test.go b/vendor/github.com/google/go-github/github/apps_installation_test.go
deleted file mode 100644
index 01358c00..00000000
--- a/vendor/github.com/google/go-github/github/apps_installation_test.go
+++ /dev/null
@@ -1,101 +0,0 @@
-// 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestAppsService_ListRepos(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/installation/repositories", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeIntegrationPreview)
- testFormValues(t, r, values{
- "page": "1",
- "per_page": "2",
- })
- fmt.Fprint(w, `{"repositories": [{"id":1}]}`)
- })
-
- opt := &ListOptions{Page: 1, PerPage: 2}
- repositories, _, err := client.Apps.ListRepos(context.Background(), opt)
- if err != nil {
- t.Errorf("Apps.ListRepos returned error: %v", err)
- }
-
- want := []*Repository{{ID: Int64(1)}}
- if !reflect.DeepEqual(repositories, want) {
- t.Errorf("Apps.ListRepos returned %+v, want %+v", repositories, want)
- }
-}
-
-func TestAppsService_ListUserRepos(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/installations/1/repositories", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeIntegrationPreview)
- testFormValues(t, r, values{
- "page": "1",
- "per_page": "2",
- })
- fmt.Fprint(w, `{"repositories": [{"id":1}]}`)
- })
-
- opt := &ListOptions{Page: 1, PerPage: 2}
- repositories, _, err := client.Apps.ListUserRepos(context.Background(), 1, opt)
- if err != nil {
- t.Errorf("Apps.ListUserRepos returned error: %v", err)
- }
-
- want := []*Repository{{ID: Int64(1)}}
- if !reflect.DeepEqual(repositories, want) {
- t.Errorf("Apps.ListUserRepos returned %+v, want %+v", repositories, want)
- }
-}
-
-func TestAppsService_AddRepository(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/apps/installations/1/repositories/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- fmt.Fprint(w, `{"id":1,"name":"n","description":"d","owner":{"login":"l"},"license":{"key":"mit"}}`)
- })
-
- repo, _, err := client.Apps.AddRepository(context.Background(), 1, 1)
- if err != nil {
- t.Errorf("Apps.AddRepository returned error: %v", err)
- }
-
- want := &Repository{ID: Int64(1), Name: String("n"), Description: String("d"), Owner: &User{Login: String("l")}, License: &License{Key: String("mit")}}
- if !reflect.DeepEqual(repo, want) {
- t.Errorf("AddRepository returned %+v, want %+v", repo, want)
- }
-}
-
-func TestAppsService_RemoveRepository(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/apps/installations/1/repositories/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Apps.RemoveRepository(context.Background(), 1, 1)
- if err != nil {
- t.Errorf("Apps.RemoveRepository returned error: %v", err)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/apps_marketplace_test.go b/vendor/github.com/google/go-github/github/apps_marketplace_test.go
deleted file mode 100644
index 91f133a3..00000000
--- a/vendor/github.com/google/go-github/github/apps_marketplace_test.go
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright 2017 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestMarketplaceService_ListPlans(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/marketplace_listing/plans", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeMarketplacePreview)
- testFormValues(t, r, values{
- "page": "1",
- "per_page": "2",
- })
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 1, PerPage: 2}
- client.Marketplace.Stubbed = false
- plans, _, err := client.Marketplace.ListPlans(context.Background(), opt)
- if err != nil {
- t.Errorf("Marketplace.ListPlans returned error: %v", err)
- }
-
- want := []*MarketplacePlan{{ID: Int64(1)}}
- if !reflect.DeepEqual(plans, want) {
- t.Errorf("Marketplace.ListPlans returned %+v, want %+v", plans, want)
- }
-}
-
-func TestMarketplaceService_Stubbed_ListPlans(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/marketplace_listing/stubbed/plans", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeMarketplacePreview)
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 1, PerPage: 2}
- client.Marketplace.Stubbed = true
- plans, _, err := client.Marketplace.ListPlans(context.Background(), opt)
- if err != nil {
- t.Errorf("Marketplace.ListPlans (Stubbed) returned error: %v", err)
- }
-
- want := []*MarketplacePlan{{ID: Int64(1)}}
- if !reflect.DeepEqual(plans, want) {
- t.Errorf("Marketplace.ListPlans (Stubbed) returned %+v, want %+v", plans, want)
- }
-}
-
-func TestMarketplaceService_ListPlanAccountsForPlan(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/marketplace_listing/plans/1/accounts", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeMarketplacePreview)
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 1, PerPage: 2}
- client.Marketplace.Stubbed = false
- accounts, _, err := client.Marketplace.ListPlanAccountsForPlan(context.Background(), 1, opt)
- if err != nil {
- t.Errorf("Marketplace.ListPlanAccountsForPlan returned error: %v", err)
- }
-
- want := []*MarketplacePlanAccount{{ID: Int64(1)}}
- if !reflect.DeepEqual(accounts, want) {
- t.Errorf("Marketplace.ListPlanAccountsForPlan returned %+v, want %+v", accounts, want)
- }
-}
-
-func TestMarketplaceService_Stubbed_ListPlanAccountsForPlan(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/marketplace_listing/stubbed/plans/1/accounts", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeMarketplacePreview)
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 1, PerPage: 2}
- client.Marketplace.Stubbed = true
- accounts, _, err := client.Marketplace.ListPlanAccountsForPlan(context.Background(), 1, opt)
- if err != nil {
- t.Errorf("Marketplace.ListPlanAccountsForPlan (Stubbed) returned error: %v", err)
- }
-
- want := []*MarketplacePlanAccount{{ID: Int64(1)}}
- if !reflect.DeepEqual(accounts, want) {
- t.Errorf("Marketplace.ListPlanAccountsForPlan (Stubbed) returned %+v, want %+v", accounts, want)
- }
-}
-
-func TestMarketplaceService_ListPlanAccountsForAccount(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/marketplace_listing/accounts/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeMarketplacePreview)
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 1, PerPage: 2}
- client.Marketplace.Stubbed = false
- accounts, _, err := client.Marketplace.ListPlanAccountsForAccount(context.Background(), 1, opt)
- if err != nil {
- t.Errorf("Marketplace.ListPlanAccountsForAccount returned error: %v", err)
- }
-
- want := []*MarketplacePlanAccount{{ID: Int64(1)}}
- if !reflect.DeepEqual(accounts, want) {
- t.Errorf("Marketplace.ListPlanAccountsForAccount returned %+v, want %+v", accounts, want)
- }
-}
-
-func TestMarketplaceService_Stubbed_ListPlanAccountsForAccount(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/marketplace_listing/stubbed/accounts/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeMarketplacePreview)
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 1, PerPage: 2}
- client.Marketplace.Stubbed = true
- accounts, _, err := client.Marketplace.ListPlanAccountsForAccount(context.Background(), 1, opt)
- if err != nil {
- t.Errorf("Marketplace.ListPlanAccountsForAccount (Stubbed) returned error: %v", err)
- }
-
- want := []*MarketplacePlanAccount{{ID: Int64(1)}}
- if !reflect.DeepEqual(accounts, want) {
- t.Errorf("Marketplace.ListPlanAccountsForAccount (Stubbed) returned %+v, want %+v", accounts, want)
- }
-}
-
-func TestMarketplaceService_ListMarketplacePurchasesForUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/marketplace_purchases", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeMarketplacePreview)
- fmt.Fprint(w, `[{"billing_cycle":"monthly"}]`)
- })
-
- opt := &ListOptions{Page: 1, PerPage: 2}
- client.Marketplace.Stubbed = false
- purchases, _, err := client.Marketplace.ListMarketplacePurchasesForUser(context.Background(), opt)
- if err != nil {
- t.Errorf("Marketplace.ListMarketplacePurchasesForUser returned error: %v", err)
- }
-
- want := []*MarketplacePurchase{{BillingCycle: String("monthly")}}
- if !reflect.DeepEqual(purchases, want) {
- t.Errorf("Marketplace.ListMarketplacePurchasesForUser returned %+v, want %+v", purchases, want)
- }
-}
-
-func TestMarketplaceService_Stubbed_ListMarketplacePurchasesForUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/marketplace_purchases/stubbed", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeMarketplacePreview)
- fmt.Fprint(w, `[{"billing_cycle":"monthly"}]`)
- })
-
- opt := &ListOptions{Page: 1, PerPage: 2}
- client.Marketplace.Stubbed = true
- purchases, _, err := client.Marketplace.ListMarketplacePurchasesForUser(context.Background(), opt)
- if err != nil {
- t.Errorf("Marketplace.ListMarketplacePurchasesForUser returned error: %v", err)
- }
-
- want := []*MarketplacePurchase{{BillingCycle: String("monthly")}}
- if !reflect.DeepEqual(purchases, want) {
- t.Errorf("Marketplace.ListMarketplacePurchasesForUser returned %+v, want %+v", purchases, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/apps_test.go b/vendor/github.com/google/go-github/github/apps_test.go
deleted file mode 100644
index f306e1a9..00000000
--- a/vendor/github.com/google/go-github/github/apps_test.go
+++ /dev/null
@@ -1,150 +0,0 @@
-// 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestAppsService_Get_authenticatedApp(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/app", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeIntegrationPreview)
- fmt.Fprint(w, `{"id":1}`)
- })
-
- app, _, err := client.Apps.Get(context.Background(), "")
- if err != nil {
- t.Errorf("Apps.Get returned error: %v", err)
- }
-
- want := &App{ID: Int64(1)}
- if !reflect.DeepEqual(app, want) {
- t.Errorf("Apps.Get returned %+v, want %+v", app, want)
- }
-}
-
-func TestAppsService_Get_specifiedApp(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/apps/a", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeIntegrationPreview)
- fmt.Fprint(w, `{"html_url":"https://github.com/apps/a"}`)
- })
-
- app, _, err := client.Apps.Get(context.Background(), "a")
- if err != nil {
- t.Errorf("Apps.Get returned error: %v", err)
- }
-
- want := &App{HTMLURL: String("https://github.com/apps/a")}
- if !reflect.DeepEqual(app, want) {
- t.Errorf("Apps.Get returned %+v, want %+v", *app.HTMLURL, *want.HTMLURL)
- }
-}
-
-func TestAppsService_ListInstallations(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/app/installations", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeIntegrationPreview)
- testFormValues(t, r, values{
- "page": "1",
- "per_page": "2",
- })
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 1, PerPage: 2}
- installations, _, err := client.Apps.ListInstallations(context.Background(), opt)
- if err != nil {
- t.Errorf("Apps.ListInstallations returned error: %v", err)
- }
-
- want := []*Installation{{ID: Int64(1)}}
- if !reflect.DeepEqual(installations, want) {
- t.Errorf("Apps.ListInstallations returned %+v, want %+v", installations, want)
- }
-}
-
-func TestAppsService_GetInstallation(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/app/installations/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeIntegrationPreview)
- fmt.Fprint(w, `{"id":1}`)
- })
-
- installation, _, err := client.Apps.GetInstallation(context.Background(), 1)
- if err != nil {
- t.Errorf("Apps.GetInstallation returned error: %v", err)
- }
-
- want := &Installation{ID: Int64(1)}
- if !reflect.DeepEqual(installation, want) {
- t.Errorf("Apps.GetInstallation returned %+v, want %+v", installation, want)
- }
-}
-
-func TestAppsService_ListUserInstallations(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/installations", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeIntegrationPreview)
- testFormValues(t, r, values{
- "page": "1",
- "per_page": "2",
- })
- fmt.Fprint(w, `{"installations":[{"id":1}]}`)
- })
-
- opt := &ListOptions{Page: 1, PerPage: 2}
- installations, _, err := client.Apps.ListUserInstallations(context.Background(), opt)
- if err != nil {
- t.Errorf("Apps.ListUserInstallations returned error: %v", err)
- }
-
- want := []*Installation{{ID: Int64(1)}}
- if !reflect.DeepEqual(installations, want) {
- t.Errorf("Apps.ListUserInstallations returned %+v, want %+v", installations, want)
- }
-}
-
-func TestAppsService_CreateInstallationToken(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/installations/1/access_tokens", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeIntegrationPreview)
- fmt.Fprint(w, `{"token":"t"}`)
- })
-
- token, _, err := client.Apps.CreateInstallationToken(context.Background(), 1)
- if err != nil {
- t.Errorf("Apps.CreateInstallationToken returned error: %v", err)
- }
-
- want := &InstallationToken{Token: String("t")}
- if !reflect.DeepEqual(token, want) {
- t.Errorf("Apps.CreateInstallationToken returned %+v, want %+v", token, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/authorizations_test.go b/vendor/github.com/google/go-github/github/authorizations_test.go
deleted file mode 100644
index faf25749..00000000
--- a/vendor/github.com/google/go-github/github/authorizations_test.go
+++ /dev/null
@@ -1,359 +0,0 @@
-// Copyright 2015 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestAuthorizationsService_List(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/authorizations", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "1", "per_page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 1, PerPage: 2}
- got, _, err := client.Authorizations.List(context.Background(), opt)
- if err != nil {
- t.Errorf("Authorizations.List returned error: %v", err)
- }
-
- want := []*Authorization{{ID: Int64(1)}}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Authorizations.List returned %+v, want %+v", *got[0].ID, *want[0].ID)
- }
-}
-
-func TestAuthorizationsService_Get(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/authorizations/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id":1}`)
- })
-
- got, _, err := client.Authorizations.Get(context.Background(), 1)
- if err != nil {
- t.Errorf("Authorizations.Get returned error: %v", err)
- }
-
- want := &Authorization{ID: Int64(1)}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Authorizations.Get returned auth %+v, want %+v", got, want)
- }
-}
-
-func TestAuthorizationsService_Create(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &AuthorizationRequest{
- Note: String("test"),
- }
-
- mux.HandleFunc("/authorizations", func(w http.ResponseWriter, r *http.Request) {
- v := new(AuthorizationRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"ID":1}`)
- })
-
- got, _, err := client.Authorizations.Create(context.Background(), input)
- if err != nil {
- t.Errorf("Authorizations.Create returned error: %v", err)
- }
-
- want := &Authorization{ID: Int64(1)}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Authorization.Create returned %+v, want %+v", got, want)
- }
-}
-
-func TestAuthorizationsService_GetOrCreateForApp(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &AuthorizationRequest{
- Note: String("test"),
- }
-
- mux.HandleFunc("/authorizations/clients/id", func(w http.ResponseWriter, r *http.Request) {
- v := new(AuthorizationRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PUT")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"ID":1}`)
- })
-
- got, _, err := client.Authorizations.GetOrCreateForApp(context.Background(), "id", input)
- if err != nil {
- t.Errorf("Authorizations.GetOrCreateForApp returned error: %v", err)
- }
-
- want := &Authorization{ID: Int64(1)}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Authorization.GetOrCreateForApp returned %+v, want %+v", got, want)
- }
-}
-
-func TestAuthorizationsService_GetOrCreateForApp_Fingerprint(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &AuthorizationRequest{
- Note: String("test"),
- Fingerprint: String("fp"),
- }
-
- mux.HandleFunc("/authorizations/clients/id/fp", func(w http.ResponseWriter, r *http.Request) {
- v := new(AuthorizationRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PUT")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"ID":1}`)
- })
-
- got, _, err := client.Authorizations.GetOrCreateForApp(context.Background(), "id", input)
- if err != nil {
- t.Errorf("Authorizations.GetOrCreateForApp returned error: %v", err)
- }
-
- want := &Authorization{ID: Int64(1)}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Authorization.GetOrCreateForApp returned %+v, want %+v", got, want)
- }
-}
-
-func TestAuthorizationsService_Edit(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &AuthorizationUpdateRequest{
- Note: String("test"),
- }
-
- mux.HandleFunc("/authorizations/1", func(w http.ResponseWriter, r *http.Request) {
- v := new(AuthorizationUpdateRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"ID":1}`)
- })
-
- got, _, err := client.Authorizations.Edit(context.Background(), 1, input)
- if err != nil {
- t.Errorf("Authorizations.Edit returned error: %v", err)
- }
-
- want := &Authorization{ID: Int64(1)}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Authorization.Update returned %+v, want %+v", got, want)
- }
-}
-
-func TestAuthorizationsService_Delete(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/authorizations/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Authorizations.Delete(context.Background(), 1)
- if err != nil {
- t.Errorf("Authorizations.Delete returned error: %v", err)
- }
-}
-
-func TestAuthorizationsService_Check(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/applications/id/tokens/t", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id":1}`)
- })
-
- got, _, err := client.Authorizations.Check(context.Background(), "id", "t")
- if err != nil {
- t.Errorf("Authorizations.Check returned error: %v", err)
- }
-
- want := &Authorization{ID: Int64(1)}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Authorizations.Check returned auth %+v, want %+v", got, want)
- }
-}
-
-func TestAuthorizationsService_Reset(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/applications/id/tokens/t", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- fmt.Fprint(w, `{"ID":1}`)
- })
-
- got, _, err := client.Authorizations.Reset(context.Background(), "id", "t")
- if err != nil {
- t.Errorf("Authorizations.Reset returned error: %v", err)
- }
-
- want := &Authorization{ID: Int64(1)}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Authorizations.Reset returned auth %+v, want %+v", got, want)
- }
-}
-
-func TestAuthorizationsService_Revoke(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/applications/id/tokens/t", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Authorizations.Revoke(context.Background(), "id", "t")
- if err != nil {
- t.Errorf("Authorizations.Revoke returned error: %v", err)
- }
-}
-
-func TestListGrants(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/applications/grants", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `[{"id": 1}]`)
- })
-
- got, _, err := client.Authorizations.ListGrants(context.Background(), nil)
- if err != nil {
- t.Errorf("OAuthAuthorizations.ListGrants returned error: %v", err)
- }
-
- want := []*Grant{{ID: Int64(1)}}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("OAuthAuthorizations.ListGrants = %+v, want %+v", got, want)
- }
-}
-
-func TestListGrants_withOptions(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/applications/grants", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
- fmt.Fprint(w, `[{"id": 1}]`)
- })
-
- _, _, err := client.Authorizations.ListGrants(context.Background(), &ListOptions{Page: 2})
- if err != nil {
- t.Errorf("OAuthAuthorizations.ListGrants returned error: %v", err)
- }
-}
-
-func TestGetGrant(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/applications/grants/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id": 1}`)
- })
-
- got, _, err := client.Authorizations.GetGrant(context.Background(), 1)
- if err != nil {
- t.Errorf("OAuthAuthorizations.GetGrant returned error: %v", err)
- }
-
- want := &Grant{ID: Int64(1)}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("OAuthAuthorizations.GetGrant = %+v, want %+v", got, want)
- }
-}
-
-func TestDeleteGrant(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/applications/grants/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Authorizations.DeleteGrant(context.Background(), 1)
- if err != nil {
- t.Errorf("OAuthAuthorizations.DeleteGrant returned error: %v", err)
- }
-}
-
-func TestAuthorizationsService_CreateImpersonation(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/admin/users/u/authorizations", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- fmt.Fprint(w, `{"id":1}`)
- })
-
- req := &AuthorizationRequest{Scopes: []Scope{ScopePublicRepo}}
- got, _, err := client.Authorizations.CreateImpersonation(context.Background(), "u", req)
- if err != nil {
- t.Errorf("Authorizations.CreateImpersonation returned error: %+v", err)
- }
-
- want := &Authorization{ID: Int64(1)}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Authorizations.CreateImpersonation returned %+v, want %+v", *got.ID, *want.ID)
- }
-}
-
-func TestAuthorizationsService_DeleteImpersonation(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/admin/users/u/authorizations", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Authorizations.DeleteImpersonation(context.Background(), "u")
- if err != nil {
- t.Errorf("Authorizations.DeleteImpersonation returned error: %+v", err)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/examples_test.go b/vendor/github.com/google/go-github/github/examples_test.go
deleted file mode 100644
index f09d6505..00000000
--- a/vendor/github.com/google/go-github/github/examples_test.go
+++ /dev/null
@@ -1,76 +0,0 @@
-// 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 (
- "context"
- "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(context.Background(), input, opt)
- if err != nil {
- fmt.Println(err)
- }
-
- fmt.Println(output)
-}
-
-func ExampleRepositoriesService_GetReadme() {
- client := github.NewClient(nil)
-
- readme, _, err := client.Repositories.GetReadme(context.Background(), "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(context.Background(), 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(context.Background(), 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...
- }
-}
diff --git a/vendor/github.com/google/go-github/github/gists_comments_test.go b/vendor/github.com/google/go-github/github/gists_comments_test.go
deleted file mode 100644
index d2f5a953..00000000
--- a/vendor/github.com/google/go-github/github/gists_comments_test.go
+++ /dev/null
@@ -1,169 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestGistsService_ListComments(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gists/1/comments", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id": 1}]`)
- })
-
- opt := &ListOptions{Page: 2}
- comments, _, err := client.Gists.ListComments(context.Background(), "1", opt)
- if err != nil {
- t.Errorf("Gists.Comments returned error: %v", err)
- }
-
- want := []*GistComment{{ID: Int64(1)}}
- if !reflect.DeepEqual(comments, want) {
- t.Errorf("Gists.ListComments returned %+v, want %+v", comments, want)
- }
-}
-
-func TestGistsService_ListComments_invalidID(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Gists.ListComments(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestGistsService_GetComment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gists/1/comments/2", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id": 1}`)
- })
-
- comment, _, err := client.Gists.GetComment(context.Background(), "1", 2)
- if err != nil {
- t.Errorf("Gists.GetComment returned error: %v", err)
- }
-
- want := &GistComment{ID: Int64(1)}
- if !reflect.DeepEqual(comment, want) {
- t.Errorf("Gists.GetComment returned %+v, want %+v", comment, want)
- }
-}
-
-func TestGistsService_GetComment_invalidID(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Gists.GetComment(context.Background(), "%", 1)
- testURLParseError(t, err)
-}
-
-func TestGistsService_CreateComment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &GistComment{ID: Int64(1), Body: String("b")}
-
- mux.HandleFunc("/gists/1/comments", func(w http.ResponseWriter, r *http.Request) {
- v := new(GistComment)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- comment, _, err := client.Gists.CreateComment(context.Background(), "1", input)
- if err != nil {
- t.Errorf("Gists.CreateComment returned error: %v", err)
- }
-
- want := &GistComment{ID: Int64(1)}
- if !reflect.DeepEqual(comment, want) {
- t.Errorf("Gists.CreateComment returned %+v, want %+v", comment, want)
- }
-}
-
-func TestGistsService_CreateComment_invalidID(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Gists.CreateComment(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestGistsService_EditComment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &GistComment{ID: Int64(1), Body: String("b")}
-
- mux.HandleFunc("/gists/1/comments/2", func(w http.ResponseWriter, r *http.Request) {
- v := new(GistComment)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- comment, _, err := client.Gists.EditComment(context.Background(), "1", 2, input)
- if err != nil {
- t.Errorf("Gists.EditComment returned error: %v", err)
- }
-
- want := &GistComment{ID: Int64(1)}
- if !reflect.DeepEqual(comment, want) {
- t.Errorf("Gists.EditComment returned %+v, want %+v", comment, want)
- }
-}
-
-func TestGistsService_EditComment_invalidID(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Gists.EditComment(context.Background(), "%", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestGistsService_DeleteComment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gists/1/comments/2", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Gists.DeleteComment(context.Background(), "1", 2)
- if err != nil {
- t.Errorf("Gists.Delete returned error: %v", err)
- }
-}
-
-func TestGistsService_DeleteComment_invalidID(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Gists.DeleteComment(context.Background(), "%", 1)
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/gists_test.go b/vendor/github.com/google/go-github/github/gists_test.go
deleted file mode 100644
index e6519151..00000000
--- a/vendor/github.com/google/go-github/github/gists_test.go
+++ /dev/null
@@ -1,546 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
- "time"
-)
-
-func TestGistsService_List_specifiedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- since := "2013-01-01T00:00:00Z"
-
- mux.HandleFunc("/users/u/gists", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testFormValues(t, r, values{
- "since": since,
- })
- fmt.Fprint(w, `[{"id": "1"}]`)
- })
-
- opt := &GistListOptions{Since: time.Date(2013, time.January, 1, 0, 0, 0, 0, time.UTC)}
- gists, _, err := client.Gists.List(context.Background(), "u", opt)
- if err != nil {
- t.Errorf("Gists.List returned error: %v", err)
- }
-
- want := []*Gist{{ID: String("1")}}
- if !reflect.DeepEqual(gists, want) {
- t.Errorf("Gists.List returned %+v, want %+v", gists, want)
- }
-}
-
-func TestGistsService_List_authenticatedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gists", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, `[{"id": "1"}]`)
- })
-
- gists, _, err := client.Gists.List(context.Background(), "", nil)
- if err != nil {
- t.Errorf("Gists.List returned error: %v", err)
- }
-
- want := []*Gist{{ID: String("1")}}
- if !reflect.DeepEqual(gists, want) {
- t.Errorf("Gists.List returned %+v, want %+v", gists, want)
- }
-}
-
-func TestGistsService_List_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Gists.List(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestGistsService_ListAll(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- since := "2013-01-01T00:00:00Z"
-
- mux.HandleFunc("/gists/public", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testFormValues(t, r, values{
- "since": since,
- })
- fmt.Fprint(w, `[{"id": "1"}]`)
- })
-
- opt := &GistListOptions{Since: time.Date(2013, time.January, 1, 0, 0, 0, 0, time.UTC)}
- gists, _, err := client.Gists.ListAll(context.Background(), opt)
- if err != nil {
- t.Errorf("Gists.ListAll returned error: %v", err)
- }
-
- want := []*Gist{{ID: String("1")}}
- if !reflect.DeepEqual(gists, want) {
- t.Errorf("Gists.ListAll returned %+v, want %+v", gists, want)
- }
-}
-
-func TestGistsService_ListStarred(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- since := "2013-01-01T00:00:00Z"
-
- mux.HandleFunc("/gists/starred", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testFormValues(t, r, values{
- "since": since,
- })
- fmt.Fprint(w, `[{"id": "1"}]`)
- })
-
- opt := &GistListOptions{Since: time.Date(2013, time.January, 1, 0, 0, 0, 0, time.UTC)}
- gists, _, err := client.Gists.ListStarred(context.Background(), opt)
- if err != nil {
- t.Errorf("Gists.ListStarred returned error: %v", err)
- }
-
- want := []*Gist{{ID: String("1")}}
- if !reflect.DeepEqual(gists, want) {
- t.Errorf("Gists.ListStarred returned %+v, want %+v", gists, want)
- }
-}
-
-func TestGistsService_Get(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gists/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, `{"id": "1"}`)
- })
-
- gist, _, err := client.Gists.Get(context.Background(), "1")
- if err != nil {
- t.Errorf("Gists.Get returned error: %v", err)
- }
-
- want := &Gist{ID: String("1")}
- if !reflect.DeepEqual(gist, want) {
- t.Errorf("Gists.Get returned %+v, want %+v", gist, want)
- }
-}
-
-func TestGistsService_Get_invalidID(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Gists.Get(context.Background(), "%")
- testURLParseError(t, err)
-}
-
-func TestGistsService_GetRevision(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gists/1/s", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, `{"id": "1"}`)
- })
-
- gist, _, err := client.Gists.GetRevision(context.Background(), "1", "s")
- if err != nil {
- t.Errorf("Gists.Get returned error: %v", err)
- }
-
- want := &Gist{ID: String("1")}
- if !reflect.DeepEqual(gist, want) {
- t.Errorf("Gists.Get returned %+v, want %+v", gist, want)
- }
-}
-
-func TestGistsService_GetRevision_invalidID(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Gists.GetRevision(context.Background(), "%", "%")
- testURLParseError(t, err)
-}
-
-func TestGistsService_Create(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Gist{
- Description: String("Gist description"),
- Public: Bool(false),
- Files: map[GistFilename]GistFile{
- "test.txt": {Content: String("Gist file content")},
- },
- }
-
- mux.HandleFunc("/gists", func(w http.ResponseWriter, r *http.Request) {
- v := new(Gist)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w,
- `
- {
- "id": "1",
- "description": "Gist description",
- "public": false,
- "files": {
- "test.txt": {
- "filename": "test.txt"
- }
- }
- }`)
- })
-
- gist, _, err := client.Gists.Create(context.Background(), input)
- if err != nil {
- t.Errorf("Gists.Create returned error: %v", err)
- }
-
- want := &Gist{
- ID: String("1"),
- Description: String("Gist description"),
- Public: Bool(false),
- Files: map[GistFilename]GistFile{
- "test.txt": {Filename: String("test.txt")},
- },
- }
- if !reflect.DeepEqual(gist, want) {
- t.Errorf("Gists.Create returned %+v, want %+v", gist, want)
- }
-}
-
-func TestGistsService_Edit(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Gist{
- Description: String("New description"),
- Files: map[GistFilename]GistFile{
- "new.txt": {Content: String("new file content")},
- },
- }
-
- mux.HandleFunc("/gists/1", func(w http.ResponseWriter, r *http.Request) {
- v := new(Gist)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w,
- `
- {
- "id": "1",
- "description": "new description",
- "public": false,
- "files": {
- "test.txt": {
- "filename": "test.txt"
- },
- "new.txt": {
- "filename": "new.txt"
- }
- }
- }`)
- })
-
- gist, _, err := client.Gists.Edit(context.Background(), "1", input)
- if err != nil {
- t.Errorf("Gists.Edit returned error: %v", err)
- }
-
- want := &Gist{
- ID: String("1"),
- Description: String("new description"),
- Public: Bool(false),
- Files: map[GistFilename]GistFile{
- "test.txt": {Filename: String("test.txt")},
- "new.txt": {Filename: String("new.txt")},
- },
- }
- if !reflect.DeepEqual(gist, want) {
- t.Errorf("Gists.Edit returned %+v, want %+v", gist, want)
- }
-}
-
-func TestGistsService_Edit_invalidID(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Gists.Edit(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestGistsService_ListCommits(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gists/1/commits", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testFormValues(t, r, nil)
- fmt.Fprint(w, `
- [
- {
- "url": "https://api.github.com/gists/1/1",
- "version": "1",
- "user": {
- "id": 1
- },
- "change_status": {
- "deletions": 0,
- "additions": 180,
- "total": 180
- },
- "committed_at": "2010-01-01T00:00:00Z"
- }
- ]
- `)
- })
-
- gistCommits, _, err := client.Gists.ListCommits(context.Background(), "1", nil)
- if err != nil {
- t.Errorf("Gists.ListCommits returned error: %v", err)
- }
-
- want := []*GistCommit{{
- URL: String("https://api.github.com/gists/1/1"),
- Version: String("1"),
- User: &User{ID: Int64(1)},
- CommittedAt: &Timestamp{time.Date(2010, 1, 1, 00, 00, 00, 0, time.UTC)},
- ChangeStatus: &CommitStats{
- Additions: Int(180),
- Deletions: Int(0),
- Total: Int(180),
- }}}
-
- if !reflect.DeepEqual(gistCommits, want) {
- t.Errorf("Gists.ListCommits returned %+v, want %+v", gistCommits, want)
- }
-}
-
-func TestGistsService_ListCommits_withOptions(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gists/1/commits", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testFormValues(t, r, values{
- "page": "2",
- })
- fmt.Fprint(w, `[]`)
- })
-
- _, _, err := client.Gists.ListCommits(context.Background(), "1", &ListOptions{Page: 2})
- if err != nil {
- t.Errorf("Gists.ListCommits returned error: %v", err)
- }
-}
-
-func TestGistsService_Delete(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gists/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Gists.Delete(context.Background(), "1")
- if err != nil {
- t.Errorf("Gists.Delete returned error: %v", err)
- }
-}
-
-func TestGistsService_Delete_invalidID(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Gists.Delete(context.Background(), "%")
- testURLParseError(t, err)
-}
-
-func TestGistsService_Star(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- })
-
- _, err := client.Gists.Star(context.Background(), "1")
- if err != nil {
- t.Errorf("Gists.Star returned error: %v", err)
- }
-}
-
-func TestGistsService_Star_invalidID(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Gists.Star(context.Background(), "%")
- testURLParseError(t, err)
-}
-
-func TestGistsService_Unstar(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Gists.Unstar(context.Background(), "1")
- if err != nil {
- t.Errorf("Gists.Unstar returned error: %v", err)
- }
-}
-
-func TestGistsService_Unstar_invalidID(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Gists.Unstar(context.Background(), "%")
- testURLParseError(t, err)
-}
-
-func TestGistsService_IsStarred_hasStar(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNoContent)
- })
-
- star, _, err := client.Gists.IsStarred(context.Background(), "1")
- if err != nil {
- t.Errorf("Gists.Starred returned error: %v", err)
- }
- if want := true; star != want {
- t.Errorf("Gists.Starred returned %+v, want %+v", star, want)
- }
-}
-
-func TestGistsService_IsStarred_noStar(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNotFound)
- })
-
- star, _, err := client.Gists.IsStarred(context.Background(), "1")
- if err != nil {
- t.Errorf("Gists.Starred returned error: %v", err)
- }
- if want := false; star != want {
- t.Errorf("Gists.Starred returned %+v, want %+v", star, want)
- }
-}
-
-func TestGistsService_IsStarred_invalidID(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Gists.IsStarred(context.Background(), "%")
- testURLParseError(t, err)
-}
-
-func TestGistsService_Fork(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gists/1/forks", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, `{"id": "2"}`)
- })
-
- gist, _, err := client.Gists.Fork(context.Background(), "1")
- if err != nil {
- t.Errorf("Gists.Fork returned error: %v", err)
- }
-
- want := &Gist{ID: String("2")}
- if !reflect.DeepEqual(gist, want) {
- t.Errorf("Gists.Fork returned %+v, want %+v", gist, want)
- }
-}
-
-func TestGistsService_ListForks(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gists/1/forks", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testFormValues(t, r, nil)
- fmt.Fprint(w, `
- [
- {"url": "https://api.github.com/gists/1",
- "user": {"id": 1},
- "id": "1",
- "created_at": "2010-01-01T00:00:00Z",
- "updated_at": "2013-01-01T00:00:00Z"
- }
- ]
- `)
- })
-
- gistForks, _, err := client.Gists.ListForks(context.Background(), "1")
- if err != nil {
- t.Errorf("Gists.ListForks returned error: %v", err)
- }
-
- want := []*GistFork{{
- URL: String("https://api.github.com/gists/1"),
- ID: String("1"),
- User: &User{ID: Int64(1)},
- CreatedAt: &Timestamp{time.Date(2010, 1, 1, 00, 00, 00, 0, time.UTC)},
- UpdatedAt: &Timestamp{time.Date(2013, 1, 1, 00, 00, 00, 0, time.UTC)}}}
-
- if !reflect.DeepEqual(gistForks, want) {
- t.Errorf("Gists.ListForks returned %+v, want %+v", gistForks, want)
- }
-}
-
-func TestGistsService_Fork_invalidID(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Gists.Fork(context.Background(), "%")
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/git_blobs_test.go b/vendor/github.com/google/go-github/github/git_blobs_test.go
deleted file mode 100644
index d4ae22be..00000000
--- a/vendor/github.com/google/go-github/github/git_blobs_test.go
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright 2014 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestGitService_GetBlob(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/git/blobs/s", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
-
- fmt.Fprint(w, `{
- "sha": "s",
- "content": "blob content"
- }`)
- })
-
- blob, _, err := client.Git.GetBlob(context.Background(), "o", "r", "s")
- if err != nil {
- t.Errorf("Git.GetBlob returned error: %v", err)
- }
-
- want := Blob{
- SHA: String("s"),
- Content: String("blob content"),
- }
-
- if !reflect.DeepEqual(*blob, want) {
- t.Errorf("Blob.Get returned %+v, want %+v", *blob, want)
- }
-}
-
-func TestGitService_GetBlob_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Git.GetBlob(context.Background(), "%", "%", "%")
- testURLParseError(t, err)
-}
-
-func TestGitService_CreateBlob(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Blob{
- SHA: String("s"),
- Content: String("blob content"),
- Encoding: String("utf-8"),
- Size: Int(12),
- }
-
- mux.HandleFunc("/repos/o/r/git/blobs", func(w http.ResponseWriter, r *http.Request) {
- v := new(Blob)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
-
- want := input
- if !reflect.DeepEqual(v, want) {
- t.Errorf("Git.CreateBlob request body: %+v, want %+v", v, want)
- }
-
- fmt.Fprint(w, `{
- "sha": "s",
- "content": "blob content",
- "encoding": "utf-8",
- "size": 12
- }`)
- })
-
- blob, _, err := client.Git.CreateBlob(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("Git.CreateBlob returned error: %v", err)
- }
-
- want := input
-
- if !reflect.DeepEqual(*blob, *want) {
- t.Errorf("Git.CreateBlob returned %+v, want %+v", *blob, *want)
- }
-}
-
-func TestGitService_CreateBlob_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Git.CreateBlob(context.Background(), "%", "%", &Blob{})
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/git_commits_test.go b/vendor/github.com/google/go-github/github/git_commits_test.go
deleted file mode 100644
index 695e0551..00000000
--- a/vendor/github.com/google/go-github/github/git_commits_test.go
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "strings"
- "testing"
-)
-
-func TestGitService_GetCommit(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- acceptHeaders := []string{mediaTypeGitSigningPreview, mediaTypeGraphQLNodeIDPreview}
- mux.HandleFunc("/repos/o/r/git/commits/s", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
- fmt.Fprint(w, `{"sha":"s","message":"m","author":{"name":"n"}}`)
- })
-
- commit, _, err := client.Git.GetCommit(context.Background(), "o", "r", "s")
- if err != nil {
- t.Errorf("Git.GetCommit returned error: %v", err)
- }
-
- want := &Commit{SHA: String("s"), Message: String("m"), Author: &CommitAuthor{Name: String("n")}}
- if !reflect.DeepEqual(commit, want) {
- t.Errorf("Git.GetCommit returned %+v, want %+v", commit, want)
- }
-}
-
-func TestGitService_GetCommit_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Git.GetCommit(context.Background(), "%", "%", "%")
- testURLParseError(t, err)
-}
-
-func TestGitService_CreateCommit(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Commit{
- Message: String("m"),
- Tree: &Tree{SHA: String("t")},
- Parents: []Commit{{SHA: String("p")}},
- }
-
- mux.HandleFunc("/repos/o/r/git/commits", func(w http.ResponseWriter, r *http.Request) {
- v := new(createCommit)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
-
- want := &createCommit{
- Message: input.Message,
- Tree: String("t"),
- Parents: []string{"p"},
- }
- if !reflect.DeepEqual(v, want) {
- t.Errorf("Request body = %+v, want %+v", v, want)
- }
- fmt.Fprint(w, `{"sha":"s"}`)
- })
-
- commit, _, err := client.Git.CreateCommit(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("Git.CreateCommit returned error: %v", err)
- }
-
- want := &Commit{SHA: String("s")}
- if !reflect.DeepEqual(commit, want) {
- t.Errorf("Git.CreateCommit returned %+v, want %+v", commit, want)
- }
-}
-
-func TestGitService_CreateCommit_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Git.CreateCommit(context.Background(), "%", "%", &Commit{})
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/git_refs_test.go b/vendor/github.com/google/go-github/github/git_refs_test.go
deleted file mode 100644
index b0f5db56..00000000
--- a/vendor/github.com/google/go-github/github/git_refs_test.go
+++ /dev/null
@@ -1,438 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestGitService_GetRef_singleRef(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, `
- {
- "ref": "refs/heads/b",
- "url": "https://api.github.com/repos/o/r/git/refs/heads/b",
- "object": {
- "type": "commit",
- "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
- "url": "https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
- }
- }`)
- })
-
- ref, _, err := client.Git.GetRef(context.Background(), "o", "r", "refs/heads/b")
- if err != nil {
- t.Fatalf("Git.GetRef returned error: %v", err)
- }
-
- want := &Reference{
- Ref: String("refs/heads/b"),
- URL: String("https://api.github.com/repos/o/r/git/refs/heads/b"),
- Object: &GitObject{
- Type: String("commit"),
- SHA: String("aa218f56b14c9653891f9e74264a383fa43fefbd"),
- URL: String("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"),
- },
- }
- if !reflect.DeepEqual(ref, want) {
- t.Errorf("Git.GetRef returned %+v, want %+v", ref, want)
- }
-
- // without 'refs/' prefix
- if _, _, err := client.Git.GetRef(context.Background(), "o", "r", "heads/b"); err != nil {
- t.Errorf("Git.GetRef returned error: %v", err)
- }
-}
-
-func TestGitService_GetRef_multipleRefs(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, `
- [
- {
- "ref": "refs/heads/booger",
- "url": "https://api.github.com/repos/o/r/git/refs/heads/booger",
- "object": {
- "type": "commit",
- "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
- "url": "https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
- }
- },
- {
- "ref": "refs/heads/bandsaw",
- "url": "https://api.github.com/repos/o/r/git/refs/heads/bandsaw",
- "object": {
- "type": "commit",
- "sha": "612077ae6dffb4d2fbd8ce0cccaa58893b07b5ac",
- "url": "https://api.github.com/repos/o/r/git/commits/612077ae6dffb4d2fbd8ce0cccaa58893b07b5ac"
- }
- }
- ]
- `)
- })
-
- _, _, err := client.Git.GetRef(context.Background(), "o", "r", "refs/heads/b")
- want := "no exact match found for this ref"
- if err.Error() != want {
- t.Errorf("Git.GetRef returned %+v, want %+v", err, want)
- }
-
-}
-
-func TestGitService_GetRefs_singleRef(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, `
- {
- "ref": "refs/heads/b",
- "url": "https://api.github.com/repos/o/r/git/refs/heads/b",
- "object": {
- "type": "commit",
- "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
- "url": "https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
- }
- }`)
- })
-
- refs, _, err := client.Git.GetRefs(context.Background(), "o", "r", "refs/heads/b")
- if err != nil {
- t.Fatalf("Git.GetRefs returned error: %v", err)
- }
-
- ref := refs[0]
- want := &Reference{
- Ref: String("refs/heads/b"),
- URL: String("https://api.github.com/repos/o/r/git/refs/heads/b"),
- Object: &GitObject{
- Type: String("commit"),
- SHA: String("aa218f56b14c9653891f9e74264a383fa43fefbd"),
- URL: String("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"),
- },
- }
- if !reflect.DeepEqual(ref, want) {
- t.Errorf("Git.GetRefs returned %+v, want %+v", ref, want)
- }
-
- // without 'refs/' prefix
- if _, _, err := client.Git.GetRefs(context.Background(), "o", "r", "heads/b"); err != nil {
- t.Errorf("Git.GetRefs returned error: %v", err)
- }
-}
-
-func TestGitService_GetRefs_multipleRefs(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, `
- [
- {
- "ref": "refs/heads/booger",
- "url": "https://api.github.com/repos/o/r/git/refs/heads/booger",
- "object": {
- "type": "commit",
- "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
- "url": "https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
- }
- },
- {
- "ref": "refs/heads/bandsaw",
- "url": "https://api.github.com/repos/o/r/git/refs/heads/bandsaw",
- "object": {
- "type": "commit",
- "sha": "612077ae6dffb4d2fbd8ce0cccaa58893b07b5ac",
- "url": "https://api.github.com/repos/o/r/git/commits/612077ae6dffb4d2fbd8ce0cccaa58893b07b5ac"
- }
- }
- ]
- `)
- })
-
- refs, _, err := client.Git.GetRefs(context.Background(), "o", "r", "refs/heads/b")
- if err != nil {
- t.Errorf("Git.GetRefs returned error: %v", err)
- }
-
- want := &Reference{
- Ref: String("refs/heads/booger"),
- URL: String("https://api.github.com/repos/o/r/git/refs/heads/booger"),
- Object: &GitObject{
- Type: String("commit"),
- SHA: String("aa218f56b14c9653891f9e74264a383fa43fefbd"),
- URL: String("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"),
- },
- }
- if !reflect.DeepEqual(refs[0], want) {
- t.Errorf("Git.GetRefs returned %+v, want %+v", refs[0], want)
- }
-}
-
-// TestGitService_GetRefs_noRefs tests for behaviour resulting from an unexpected GH response. This should never actually happen.
-func TestGitService_GetRefs_noRefs(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, "[]")
- })
-
- _, _, err := client.Git.GetRefs(context.Background(), "o", "r", "refs/heads/b")
- want := "unexpected response from GitHub API: an array of refs with length 0"
- if err.Error() != want {
- t.Errorf("Git.GetRefs returned %+v, want %+v", err, want)
- }
-
-}
-
-func TestGitService_ListRefs(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/git/refs", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, `
- [
- {
- "ref": "refs/heads/branchA",
- "url": "https://api.github.com/repos/o/r/git/refs/heads/branchA",
- "object": {
- "type": "commit",
- "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
- "url": "https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
- }
- },
- {
- "ref": "refs/heads/branchB",
- "url": "https://api.github.com/repos/o/r/git/refs/heads/branchB",
- "object": {
- "type": "commit",
- "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
- "url": "https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
- }
- }
- ]`)
- })
-
- refs, _, err := client.Git.ListRefs(context.Background(), "o", "r", nil)
- if err != nil {
- t.Errorf("Git.ListRefs returned error: %v", err)
- }
-
- want := []*Reference{
- {
- Ref: String("refs/heads/branchA"),
- URL: String("https://api.github.com/repos/o/r/git/refs/heads/branchA"),
- Object: &GitObject{
- Type: String("commit"),
- SHA: String("aa218f56b14c9653891f9e74264a383fa43fefbd"),
- URL: String("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"),
- },
- },
- {
- Ref: String("refs/heads/branchB"),
- URL: String("https://api.github.com/repos/o/r/git/refs/heads/branchB"),
- Object: &GitObject{
- Type: String("commit"),
- SHA: String("aa218f56b14c9653891f9e74264a383fa43fefbd"),
- URL: String("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"),
- },
- },
- }
- if !reflect.DeepEqual(refs, want) {
- t.Errorf("Git.ListRefs returned %+v, want %+v", refs, want)
- }
-}
-
-func TestGitService_ListRefs_options(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/git/refs/t", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"ref": "r"}]`)
- })
-
- opt := &ReferenceListOptions{Type: "t", ListOptions: ListOptions{Page: 2}}
- refs, _, err := client.Git.ListRefs(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Git.ListRefs returned error: %v", err)
- }
-
- want := []*Reference{{Ref: String("r")}}
- if !reflect.DeepEqual(refs, want) {
- t.Errorf("Git.ListRefs returned %+v, want %+v", refs, want)
- }
-}
-
-func TestGitService_CreateRef(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- args := &createRefRequest{
- Ref: String("refs/heads/b"),
- SHA: String("aa218f56b14c9653891f9e74264a383fa43fefbd"),
- }
-
- mux.HandleFunc("/repos/o/r/git/refs", func(w http.ResponseWriter, r *http.Request) {
- v := new(createRefRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- if !reflect.DeepEqual(v, args) {
- t.Errorf("Request body = %+v, want %+v", v, args)
- }
- fmt.Fprint(w, `
- {
- "ref": "refs/heads/b",
- "url": "https://api.github.com/repos/o/r/git/refs/heads/b",
- "object": {
- "type": "commit",
- "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
- "url": "https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
- }
- }`)
- })
-
- ref, _, err := client.Git.CreateRef(context.Background(), "o", "r", &Reference{
- Ref: String("refs/heads/b"),
- Object: &GitObject{
- SHA: String("aa218f56b14c9653891f9e74264a383fa43fefbd"),
- },
- })
- if err != nil {
- t.Errorf("Git.CreateRef returned error: %v", err)
- }
-
- want := &Reference{
- Ref: String("refs/heads/b"),
- URL: String("https://api.github.com/repos/o/r/git/refs/heads/b"),
- Object: &GitObject{
- Type: String("commit"),
- SHA: String("aa218f56b14c9653891f9e74264a383fa43fefbd"),
- URL: String("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"),
- },
- }
- if !reflect.DeepEqual(ref, want) {
- t.Errorf("Git.CreateRef returned %+v, want %+v", ref, want)
- }
-
- // without 'refs/' prefix
- _, _, err = client.Git.CreateRef(context.Background(), "o", "r", &Reference{
- Ref: String("heads/b"),
- Object: &GitObject{
- SHA: String("aa218f56b14c9653891f9e74264a383fa43fefbd"),
- },
- })
- if err != nil {
- t.Errorf("Git.CreateRef returned error: %v", err)
- }
-}
-
-func TestGitService_UpdateRef(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- args := &updateRefRequest{
- SHA: String("aa218f56b14c9653891f9e74264a383fa43fefbd"),
- Force: Bool(true),
- }
-
- mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) {
- v := new(updateRefRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- if !reflect.DeepEqual(v, args) {
- t.Errorf("Request body = %+v, want %+v", v, args)
- }
- fmt.Fprint(w, `
- {
- "ref": "refs/heads/b",
- "url": "https://api.github.com/repos/o/r/git/refs/heads/b",
- "object": {
- "type": "commit",
- "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
- "url": "https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
- }
- }`)
- })
-
- ref, _, err := client.Git.UpdateRef(context.Background(), "o", "r", &Reference{
- Ref: String("refs/heads/b"),
- Object: &GitObject{SHA: String("aa218f56b14c9653891f9e74264a383fa43fefbd")},
- }, true)
- if err != nil {
- t.Errorf("Git.UpdateRef returned error: %v", err)
- }
-
- want := &Reference{
- Ref: String("refs/heads/b"),
- URL: String("https://api.github.com/repos/o/r/git/refs/heads/b"),
- Object: &GitObject{
- Type: String("commit"),
- SHA: String("aa218f56b14c9653891f9e74264a383fa43fefbd"),
- URL: String("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"),
- },
- }
- if !reflect.DeepEqual(ref, want) {
- t.Errorf("Git.UpdateRef returned %+v, want %+v", ref, want)
- }
-
- // without 'refs/' prefix
- _, _, err = client.Git.UpdateRef(context.Background(), "o", "r", &Reference{
- Ref: String("heads/b"),
- Object: &GitObject{SHA: String("aa218f56b14c9653891f9e74264a383fa43fefbd")},
- }, true)
- if err != nil {
- t.Errorf("Git.UpdateRef returned error: %v", err)
- }
-}
-
-func TestGitService_DeleteRef(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Git.DeleteRef(context.Background(), "o", "r", "refs/heads/b")
- if err != nil {
- t.Errorf("Git.DeleteRef returned error: %v", err)
- }
-
- // without 'refs/' prefix
- if _, err := client.Git.DeleteRef(context.Background(), "o", "r", "heads/b"); err != nil {
- t.Errorf("Git.DeleteRef returned error: %v", err)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/git_tags_test.go b/vendor/github.com/google/go-github/github/git_tags_test.go
deleted file mode 100644
index 728ea0b7..00000000
--- a/vendor/github.com/google/go-github/github/git_tags_test.go
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "strings"
- "testing"
-)
-
-func TestGitService_GetTag(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- acceptHeaders := []string{mediaTypeGitSigningPreview, mediaTypeGraphQLNodeIDPreview}
- mux.HandleFunc("/repos/o/r/git/tags/s", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
-
- fmt.Fprint(w, `{"tag": "t"}`)
- })
-
- tag, _, err := client.Git.GetTag(context.Background(), "o", "r", "s")
- if err != nil {
- t.Errorf("Git.GetTag returned error: %v", err)
- }
-
- want := &Tag{Tag: String("t")}
- if !reflect.DeepEqual(tag, want) {
- t.Errorf("Git.GetTag returned %+v, want %+v", tag, want)
- }
-}
-
-func TestGitService_CreateTag(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &createTagRequest{Tag: String("t"), Object: String("s")}
-
- mux.HandleFunc("/repos/o/r/git/tags", func(w http.ResponseWriter, r *http.Request) {
- v := new(createTagRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"tag": "t"}`)
- })
-
- tag, _, err := client.Git.CreateTag(context.Background(), "o", "r", &Tag{
- Tag: input.Tag,
- Object: &GitObject{SHA: input.Object},
- })
- if err != nil {
- t.Errorf("Git.CreateTag returned error: %v", err)
- }
-
- want := &Tag{Tag: String("t")}
- if !reflect.DeepEqual(tag, want) {
- t.Errorf("Git.GetTag returned %+v, want %+v", tag, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/git_trees_test.go b/vendor/github.com/google/go-github/github/git_trees_test.go
deleted file mode 100644
index e2a20efa..00000000
--- a/vendor/github.com/google/go-github/github/git_trees_test.go
+++ /dev/null
@@ -1,191 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestGitService_GetTree(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/git/trees/s", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{
- "sha": "s",
- "tree": [ { "type": "blob" } ]
- }`)
- })
-
- tree, _, err := client.Git.GetTree(context.Background(), "o", "r", "s", true)
- if err != nil {
- t.Errorf("Git.GetTree returned error: %v", err)
- }
-
- want := Tree{
- SHA: String("s"),
- Entries: []TreeEntry{
- {
- Type: String("blob"),
- },
- },
- }
- if !reflect.DeepEqual(*tree, want) {
- t.Errorf("Tree.Get returned %+v, want %+v", *tree, want)
- }
-}
-
-func TestGitService_GetTree_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Git.GetTree(context.Background(), "%", "%", "%", false)
- testURLParseError(t, err)
-}
-
-func TestGitService_CreateTree(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := []TreeEntry{
- {
- Path: String("file.rb"),
- Mode: String("100644"),
- Type: String("blob"),
- SHA: String("7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b"),
- },
- }
-
- mux.HandleFunc("/repos/o/r/git/trees", func(w http.ResponseWriter, r *http.Request) {
- v := new(createTree)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
-
- want := &createTree{
- BaseTree: "b",
- Entries: input,
- }
- if !reflect.DeepEqual(v, want) {
- t.Errorf("Git.CreateTree request body: %+v, want %+v", v, want)
- }
-
- fmt.Fprint(w, `{
- "sha": "cd8274d15fa3ae2ab983129fb037999f264ba9a7",
- "tree": [
- {
- "path": "file.rb",
- "mode": "100644",
- "type": "blob",
- "size": 132,
- "sha": "7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b"
- }
- ]
- }`)
- })
-
- tree, _, err := client.Git.CreateTree(context.Background(), "o", "r", "b", input)
- if err != nil {
- t.Errorf("Git.CreateTree returned error: %v", err)
- }
-
- want := Tree{
- String("cd8274d15fa3ae2ab983129fb037999f264ba9a7"),
- []TreeEntry{
- {
- Path: String("file.rb"),
- Mode: String("100644"),
- Type: String("blob"),
- Size: Int(132),
- SHA: String("7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b"),
- },
- },
- }
-
- if !reflect.DeepEqual(*tree, want) {
- t.Errorf("Git.CreateTree returned %+v, want %+v", *tree, want)
- }
-}
-
-func TestGitService_CreateTree_Content(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := []TreeEntry{
- {
- Path: String("content.md"),
- Mode: String("100644"),
- Content: String("file content"),
- },
- }
-
- mux.HandleFunc("/repos/o/r/git/trees", func(w http.ResponseWriter, r *http.Request) {
- v := new(createTree)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
-
- want := &createTree{
- BaseTree: "b",
- Entries: input,
- }
- if !reflect.DeepEqual(v, want) {
- t.Errorf("Git.CreateTree request body: %+v, want %+v", v, want)
- }
-
- fmt.Fprint(w, `{
- "sha": "5c6780ad2c68743383b740fd1dab6f6a33202b11",
- "url": "https://api.github.com/repos/o/r/git/trees/5c6780ad2c68743383b740fd1dab6f6a33202b11",
- "tree": [
- {
- "mode": "100644",
- "type": "blob",
- "sha": "aad8feacf6f8063150476a7b2bd9770f2794c08b",
- "path": "content.md",
- "size": 12,
- "url": "https://api.github.com/repos/o/r/git/blobs/aad8feacf6f8063150476a7b2bd9770f2794c08b"
- }
- ]
- }`)
- })
-
- tree, _, err := client.Git.CreateTree(context.Background(), "o", "r", "b", input)
- if err != nil {
- t.Errorf("Git.CreateTree returned error: %v", err)
- }
-
- want := Tree{
- String("5c6780ad2c68743383b740fd1dab6f6a33202b11"),
- []TreeEntry{
- {
- Path: String("content.md"),
- Mode: String("100644"),
- Type: String("blob"),
- Size: Int(12),
- SHA: String("aad8feacf6f8063150476a7b2bd9770f2794c08b"),
- URL: String("https://api.github.com/repos/o/r/git/blobs/aad8feacf6f8063150476a7b2bd9770f2794c08b"),
- },
- },
- }
-
- if !reflect.DeepEqual(*tree, want) {
- t.Errorf("Git.CreateTree returned %+v, want %+v", *tree, want)
- }
-}
-
-func TestGitService_CreateTree_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Git.CreateTree(context.Background(), "%", "%", "", nil)
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/github_test.go b/vendor/github.com/google/go-github/github/github_test.go
deleted file mode 100644
index cb4b002a..00000000
--- a/vendor/github.com/google/go-github/github/github_test.go
+++ /dev/null
@@ -1,1049 +0,0 @@
-// Copyright 2013 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
-
-import (
- "bytes"
- "context"
- "encoding/json"
- "fmt"
- "io/ioutil"
- "net/http"
- "net/http/httptest"
- "net/url"
- "os"
- "path"
- "reflect"
- "strings"
- "testing"
- "time"
-)
-
-const (
- // baseURLPath is a non-empty Client.BaseURL path to use during tests,
- // to ensure relative URLs are used for all endpoints. See issue #752.
- baseURLPath = "/api-v3"
-)
-
-// setup sets up a test HTTP server along with a github.Client that is
-// configured to talk to that test server. Tests should register handlers on
-// mux which provide mock responses for the API method being tested.
-func setup() (client *Client, mux *http.ServeMux, serverURL string, teardown func()) {
- // mux is the HTTP request multiplexer used with the test server.
- mux = http.NewServeMux()
-
- // We want to ensure that tests catch mistakes where the endpoint URL is
- // specified as absolute rather than relative. It only makes a difference
- // when there's a non-empty base URL path. So, use that. See issue #752.
- apiHandler := http.NewServeMux()
- apiHandler.Handle(baseURLPath+"/", http.StripPrefix(baseURLPath, mux))
- apiHandler.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
- fmt.Fprintln(os.Stderr, "FAIL: Client.BaseURL path prefix is not preserved in the request URL:")
- fmt.Fprintln(os.Stderr)
- fmt.Fprintln(os.Stderr, "\t"+req.URL.String())
- fmt.Fprintln(os.Stderr)
- fmt.Fprintln(os.Stderr, "\tDid you accidentally use an absolute endpoint URL rather than relative?")
- fmt.Fprintln(os.Stderr, "\tSee https://github.com/google/go-github/issues/752 for information.")
- http.Error(w, "Client.BaseURL path prefix is not preserved in the request URL.", http.StatusInternalServerError)
- })
-
- // server is a test HTTP server used to provide mock API responses.
- server := httptest.NewServer(apiHandler)
-
- // client is the GitHub client being tested and is
- // configured to use test server.
- client = NewClient(nil)
- url, _ := url.Parse(server.URL + baseURLPath + "/")
- client.BaseURL = url
- client.UploadURL = url
-
- return client, mux, server.URL, server.Close
-}
-
-// openTestFile creates a new file with the given name and content for testing.
-// In order to ensure the exact file name, this function will create a new temp
-// directory, and create the file in that directory. It is the caller's
-// responsibility to remove the directory and its contents when no longer needed.
-func openTestFile(name, content string) (file *os.File, dir string, err error) {
- dir, err = ioutil.TempDir("", "go-github")
- if err != nil {
- return nil, dir, err
- }
-
- file, err = os.OpenFile(path.Join(dir, name), os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600)
- if err != nil {
- return nil, dir, err
- }
-
- fmt.Fprint(file, content)
-
- // close and re-open the file to keep file.Stat() happy
- file.Close()
- file, err = os.Open(file.Name())
- if err != nil {
- return nil, dir, err
- }
-
- return file, dir, err
-}
-
-func testMethod(t *testing.T, r *http.Request, want string) {
- if got := r.Method; got != want {
- t.Errorf("Request method: %v, want %v", got, want)
- }
-}
-
-type values map[string]string
-
-func testFormValues(t *testing.T, r *http.Request, values values) {
- want := url.Values{}
- for k, v := range values {
- want.Set(k, v)
- }
-
- r.ParseForm()
- if got := r.Form; !reflect.DeepEqual(got, want) {
- t.Errorf("Request parameters: %v, want %v", got, want)
- }
-}
-
-func testHeader(t *testing.T, r *http.Request, header string, want string) {
- if got := r.Header.Get(header); got != want {
- t.Errorf("Header.Get(%q) returned %q, want %q", header, got, want)
- }
-}
-
-func testURLParseError(t *testing.T, err error) {
- if err == nil {
- t.Errorf("Expected error to be returned")
- }
- if err, ok := err.(*url.Error); !ok || err.Op != "parse" {
- t.Errorf("Expected URL parse error, got %+v", err)
- }
-}
-
-func testBody(t *testing.T, r *http.Request, want string) {
- b, err := ioutil.ReadAll(r.Body)
- if err != nil {
- t.Errorf("Error reading request body: %v", err)
- }
- if got := string(b); got != want {
- t.Errorf("request Body is %s, want %s", got, want)
- }
-}
-
-// Helper function to test that a value is marshalled to JSON as expected.
-func testJSONMarshal(t *testing.T, v interface{}, want string) {
- j, err := json.Marshal(v)
- if err != nil {
- t.Errorf("Unable to marshal JSON for %v", v)
- }
-
- w := new(bytes.Buffer)
- err = json.Compact(w, []byte(want))
- if err != nil {
- t.Errorf("String is not valid json: %s", want)
- }
-
- if w.String() != string(j) {
- t.Errorf("json.Marshal(%q) returned %s, want %s", v, j, w)
- }
-
- // now go the other direction and make sure things unmarshal as expected
- u := reflect.ValueOf(v).Interface()
- if err := json.Unmarshal([]byte(want), u); err != nil {
- t.Errorf("Unable to unmarshal JSON for %v", want)
- }
-
- if !reflect.DeepEqual(v, u) {
- t.Errorf("json.Unmarshal(%q) returned %s, want %s", want, u, v)
- }
-}
-
-func TestNewClient(t *testing.T) {
- c := NewClient(nil)
-
- if got, want := c.BaseURL.String(), defaultBaseURL; got != want {
- t.Errorf("NewClient BaseURL is %v, want %v", got, want)
- }
- if got, want := c.UserAgent, userAgent; got != want {
- t.Errorf("NewClient UserAgent is %v, want %v", got, want)
- }
-}
-
-func TestNewEnterpriseClient(t *testing.T) {
- baseURL := "https://custom-url/"
- uploadURL := "https://custom-upload-url/"
- c, err := NewEnterpriseClient(baseURL, uploadURL, nil)
- if err != nil {
- t.Fatalf("NewEnterpriseClient returned unexpected error: %v", err)
- }
-
- if got, want := c.BaseURL.String(), baseURL; got != want {
- t.Errorf("NewClient BaseURL is %v, want %v", got, want)
- }
- if got, want := c.UploadURL.String(), uploadURL; got != want {
- t.Errorf("NewClient UploadURL is %v, want %v", got, want)
- }
-}
-
-func TestNewEnterpriseClient_addsTrailingSlashToURLs(t *testing.T) {
- baseURL := "https://custom-url"
- uploadURL := "https://custom-upload-url"
- formattedBaseURL := baseURL + "/"
- formattedUploadURL := uploadURL + "/"
-
- c, err := NewEnterpriseClient(baseURL, uploadURL, nil)
- if err != nil {
- t.Fatalf("NewEnterpriseClient returned unexpected error: %v", err)
- }
-
- if got, want := c.BaseURL.String(), formattedBaseURL; got != want {
- t.Errorf("NewClient BaseURL is %v, want %v", got, want)
- }
- if got, want := c.UploadURL.String(), formattedUploadURL; got != want {
- t.Errorf("NewClient UploadURL is %v, want %v", got, want)
- }
-}
-
-// Ensure that length of Client.rateLimits is the same as number of fields in RateLimits struct.
-func TestClient_rateLimits(t *testing.T) {
- if got, want := len(Client{}.rateLimits), reflect.TypeOf(RateLimits{}).NumField(); got != want {
- t.Errorf("len(Client{}.rateLimits) is %v, want %v", got, want)
- }
-}
-
-func TestNewRequest(t *testing.T) {
- c := NewClient(nil)
-
- inURL, outURL := "/foo", defaultBaseURL+"foo"
- inBody, outBody := &User{Login: String("l")}, `{"login":"l"}`+"\n"
- req, _ := c.NewRequest("GET", inURL, inBody)
-
- // test that relative URL was expanded
- if got, want := req.URL.String(), outURL; got != want {
- t.Errorf("NewRequest(%q) URL is %v, want %v", inURL, got, want)
- }
-
- // test that body was JSON encoded
- body, _ := ioutil.ReadAll(req.Body)
- if got, want := string(body), outBody; got != want {
- t.Errorf("NewRequest(%q) Body is %v, want %v", inBody, got, want)
- }
-
- // test that default user-agent is attached to the request
- if got, want := req.Header.Get("User-Agent"), c.UserAgent; got != want {
- t.Errorf("NewRequest() User-Agent is %v, want %v", got, want)
- }
-}
-
-func TestNewRequest_invalidJSON(t *testing.T) {
- c := NewClient(nil)
-
- type T struct {
- A map[interface{}]interface{}
- }
- _, err := c.NewRequest("GET", ".", &T{})
-
- if err == nil {
- t.Error("Expected error to be returned.")
- }
- if err, ok := err.(*json.UnsupportedTypeError); !ok {
- t.Errorf("Expected a JSON error; got %#v.", err)
- }
-}
-
-func TestNewRequest_badURL(t *testing.T) {
- c := NewClient(nil)
- _, err := c.NewRequest("GET", ":", nil)
- testURLParseError(t, err)
-}
-
-// ensure that no User-Agent header is set if the client's UserAgent is empty.
-// This caused a problem with Google's internal http client.
-func TestNewRequest_emptyUserAgent(t *testing.T) {
- c := NewClient(nil)
- c.UserAgent = ""
- req, err := c.NewRequest("GET", ".", nil)
- if err != nil {
- t.Fatalf("NewRequest returned unexpected error: %v", err)
- }
- if _, ok := req.Header["User-Agent"]; ok {
- t.Fatal("constructed request contains unexpected User-Agent header")
- }
-}
-
-// If a nil body is passed to github.NewRequest, make sure that nil is also
-// passed to http.NewRequest. In most cases, passing an io.Reader that returns
-// no content is fine, since there is no difference between an HTTP request
-// body that is an empty string versus one that is not set at all. However in
-// certain cases, intermediate systems may treat these differently resulting in
-// subtle errors.
-func TestNewRequest_emptyBody(t *testing.T) {
- c := NewClient(nil)
- req, err := c.NewRequest("GET", ".", nil)
- if err != nil {
- t.Fatalf("NewRequest returned unexpected error: %v", err)
- }
- if req.Body != nil {
- t.Fatalf("constructed request contains a non-nil Body")
- }
-}
-
-func TestNewRequest_errorForNoTrailingSlash(t *testing.T) {
- tests := []struct {
- rawurl string
- wantError bool
- }{
- {rawurl: "https://example.com/api/v3", wantError: true},
- {rawurl: "https://example.com/api/v3/", wantError: false},
- }
- c := NewClient(nil)
- for _, test := range tests {
- u, err := url.Parse(test.rawurl)
- if err != nil {
- t.Fatalf("url.Parse returned unexpected error: %v.", err)
- }
- c.BaseURL = u
- if _, err := c.NewRequest(http.MethodGet, "test", nil); test.wantError && err == nil {
- t.Fatalf("Expected error to be returned.")
- } else if !test.wantError && err != nil {
- t.Fatalf("NewRequest returned unexpected error: %v.", err)
- }
- }
-}
-
-func TestNewUploadRequest_errorForNoTrailingSlash(t *testing.T) {
- tests := []struct {
- rawurl string
- wantError bool
- }{
- {rawurl: "https://example.com/api/uploads", wantError: true},
- {rawurl: "https://example.com/api/uploads/", wantError: false},
- }
- c := NewClient(nil)
- for _, test := range tests {
- u, err := url.Parse(test.rawurl)
- if err != nil {
- t.Fatalf("url.Parse returned unexpected error: %v.", err)
- }
- c.UploadURL = u
- if _, err = c.NewUploadRequest("test", nil, 0, ""); test.wantError && err == nil {
- t.Fatalf("Expected error to be returned.")
- } else if !test.wantError && err != nil {
- t.Fatalf("NewUploadRequest returned unexpected error: %v.", err)
- }
- }
-}
-
-func TestResponse_populatePageValues(t *testing.T) {
- r := http.Response{
- Header: http.Header{
- "Link": {`; rel="first",` +
- ` ; rel="prev",` +
- ` ; rel="next",` +
- ` ; rel="last"`,
- },
- },
- }
-
- response := newResponse(&r)
- if got, want := response.FirstPage, 1; got != want {
- t.Errorf("response.FirstPage: %v, want %v", got, want)
- }
- if got, want := response.PrevPage, 2; want != got {
- t.Errorf("response.PrevPage: %v, want %v", got, want)
- }
- if got, want := response.NextPage, 4; want != got {
- t.Errorf("response.NextPage: %v, want %v", got, want)
- }
- if got, want := response.LastPage, 5; want != got {
- t.Errorf("response.LastPage: %v, want %v", got, want)
- }
-}
-
-func TestResponse_populatePageValues_invalid(t *testing.T) {
- r := http.Response{
- Header: http.Header{
- "Link": {`,` +
- `; rel="first",` +
- `https://api.github.com/?page=2; rel="prev",` +
- `; rel="next",` +
- `; rel="last"`,
- },
- },
- }
-
- response := newResponse(&r)
- if got, want := response.FirstPage, 0; got != want {
- t.Errorf("response.FirstPage: %v, want %v", got, want)
- }
- if got, want := response.PrevPage, 0; got != want {
- t.Errorf("response.PrevPage: %v, want %v", got, want)
- }
- if got, want := response.NextPage, 0; got != want {
- t.Errorf("response.NextPage: %v, want %v", got, want)
- }
- if got, want := response.LastPage, 0; got != want {
- t.Errorf("response.LastPage: %v, want %v", got, want)
- }
-
- // more invalid URLs
- r = http.Response{
- Header: http.Header{
- "Link": {`; rel="first"`},
- },
- }
-
- response = newResponse(&r)
- if got, want := response.FirstPage, 0; got != want {
- t.Errorf("response.FirstPage: %v, want %v", got, want)
- }
-}
-
-func TestDo(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- type foo struct {
- A string
- }
-
- mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"A":"a"}`)
- })
-
- req, _ := client.NewRequest("GET", ".", nil)
- body := new(foo)
- client.Do(context.Background(), req, body)
-
- want := &foo{"a"}
- if !reflect.DeepEqual(body, want) {
- t.Errorf("Response body = %v, want %v", body, want)
- }
-}
-
-func TestDo_httpError(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- http.Error(w, "Bad Request", 400)
- })
-
- req, _ := client.NewRequest("GET", ".", nil)
- resp, err := client.Do(context.Background(), req, nil)
-
- if err == nil {
- t.Fatal("Expected HTTP 400 error, got no error.")
- }
- if resp.StatusCode != 400 {
- t.Errorf("Expected HTTP 400 error, got %d status code.", resp.StatusCode)
- }
-}
-
-// Test handling of an error caused by the internal http client's Do()
-// function. A redirect loop is pretty unlikely to occur within the GitHub
-// API, but does allow us to exercise the right code path.
-func TestDo_redirectLoop(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- http.Redirect(w, r, baseURLPath, http.StatusFound)
- })
-
- req, _ := client.NewRequest("GET", ".", nil)
- _, err := client.Do(context.Background(), req, nil)
-
- if err == nil {
- t.Error("Expected error to be returned.")
- }
- if err, ok := err.(*url.Error); !ok {
- t.Errorf("Expected a URL error; got %#v.", err)
- }
-}
-
-// Test that an error caused by the internal http client's Do() function
-// does not leak the client secret.
-func TestDo_sanitizeURL(t *testing.T) {
- tp := &UnauthenticatedRateLimitedTransport{
- ClientID: "id",
- ClientSecret: "secret",
- }
- unauthedClient := NewClient(tp.Client())
- unauthedClient.BaseURL = &url.URL{Scheme: "http", Host: "127.0.0.1:0", Path: "/"} // Use port 0 on purpose to trigger a dial TCP error, expect to get "dial tcp 127.0.0.1:0: connect: can't assign requested address".
- req, err := unauthedClient.NewRequest("GET", ".", nil)
- if err != nil {
- t.Fatalf("NewRequest returned unexpected error: %v", err)
- }
- _, err = unauthedClient.Do(context.Background(), req, nil)
- if err == nil {
- t.Fatal("Expected error to be returned.")
- }
- if strings.Contains(err.Error(), "client_secret=secret") {
- t.Errorf("Do error contains secret, should be redacted:\n%q", err)
- }
-}
-
-func TestDo_rateLimit(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- w.Header().Set(headerRateLimit, "60")
- w.Header().Set(headerRateRemaining, "59")
- w.Header().Set(headerRateReset, "1372700873")
- })
-
- req, _ := client.NewRequest("GET", ".", nil)
- resp, err := client.Do(context.Background(), req, nil)
- if err != nil {
- t.Errorf("Do returned unexpected error: %v", err)
- }
- if got, want := resp.Rate.Limit, 60; got != want {
- t.Errorf("Client rate limit = %v, want %v", got, want)
- }
- if got, want := resp.Rate.Remaining, 59; got != want {
- t.Errorf("Client rate remaining = %v, want %v", got, want)
- }
- reset := time.Date(2013, 7, 1, 17, 47, 53, 0, time.UTC)
- if resp.Rate.Reset.UTC() != reset {
- t.Errorf("Client rate reset = %v, want %v", resp.Rate.Reset, reset)
- }
-}
-
-// ensure rate limit is still parsed, even for error responses
-func TestDo_rateLimit_errorResponse(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- w.Header().Set(headerRateLimit, "60")
- w.Header().Set(headerRateRemaining, "59")
- w.Header().Set(headerRateReset, "1372700873")
- http.Error(w, "Bad Request", 400)
- })
-
- req, _ := client.NewRequest("GET", ".", nil)
- resp, err := client.Do(context.Background(), req, nil)
- if err == nil {
- t.Error("Expected error to be returned.")
- }
- if _, ok := err.(*RateLimitError); ok {
- t.Errorf("Did not expect a *RateLimitError error; got %#v.", err)
- }
- if got, want := resp.Rate.Limit, 60; got != want {
- t.Errorf("Client rate limit = %v, want %v", got, want)
- }
- if got, want := resp.Rate.Remaining, 59; got != want {
- t.Errorf("Client rate remaining = %v, want %v", got, want)
- }
- reset := time.Date(2013, 7, 1, 17, 47, 53, 0, time.UTC)
- if resp.Rate.Reset.UTC() != reset {
- t.Errorf("Client rate reset = %v, want %v", resp.Rate.Reset, reset)
- }
-}
-
-// Ensure *RateLimitError is returned when API rate limit is exceeded.
-func TestDo_rateLimit_rateLimitError(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- w.Header().Set(headerRateLimit, "60")
- w.Header().Set(headerRateRemaining, "0")
- w.Header().Set(headerRateReset, "1372700873")
- w.Header().Set("Content-Type", "application/json; charset=utf-8")
- w.WriteHeader(http.StatusForbidden)
- fmt.Fprintln(w, `{
- "message": "API rate limit exceeded for xxx.xxx.xxx.xxx. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
- "documentation_url": "https://developer.github.com/v3/#rate-limiting"
-}`)
- })
-
- req, _ := client.NewRequest("GET", ".", nil)
- _, err := client.Do(context.Background(), req, nil)
-
- if err == nil {
- t.Error("Expected error to be returned.")
- }
- rateLimitErr, ok := err.(*RateLimitError)
- if !ok {
- t.Fatalf("Expected a *RateLimitError error; got %#v.", err)
- }
- if got, want := rateLimitErr.Rate.Limit, 60; got != want {
- t.Errorf("rateLimitErr rate limit = %v, want %v", got, want)
- }
- if got, want := rateLimitErr.Rate.Remaining, 0; got != want {
- t.Errorf("rateLimitErr rate remaining = %v, want %v", got, want)
- }
- reset := time.Date(2013, 7, 1, 17, 47, 53, 0, time.UTC)
- if rateLimitErr.Rate.Reset.UTC() != reset {
- t.Errorf("rateLimitErr rate reset = %v, want %v", rateLimitErr.Rate.Reset.UTC(), reset)
- }
-}
-
-// Ensure a network call is not made when it's known that API rate limit is still exceeded.
-func TestDo_rateLimit_noNetworkCall(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- reset := time.Now().UTC().Add(time.Minute).Round(time.Second) // Rate reset is a minute from now, with 1 second precision.
-
- mux.HandleFunc("/first", func(w http.ResponseWriter, r *http.Request) {
- w.Header().Set(headerRateLimit, "60")
- w.Header().Set(headerRateRemaining, "0")
- w.Header().Set(headerRateReset, fmt.Sprint(reset.Unix()))
- w.Header().Set("Content-Type", "application/json; charset=utf-8")
- w.WriteHeader(http.StatusForbidden)
- fmt.Fprintln(w, `{
- "message": "API rate limit exceeded for xxx.xxx.xxx.xxx. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
- "documentation_url": "https://developer.github.com/v3/#rate-limiting"
-}`)
- })
-
- madeNetworkCall := false
- mux.HandleFunc("/second", func(w http.ResponseWriter, r *http.Request) {
- madeNetworkCall = true
- })
-
- // First request is made, and it makes the client aware of rate reset time being in the future.
- req, _ := client.NewRequest("GET", "first", nil)
- client.Do(context.Background(), req, nil)
-
- // Second request should not cause a network call to be made, since client can predict a rate limit error.
- req, _ = client.NewRequest("GET", "second", nil)
- _, err := client.Do(context.Background(), req, nil)
-
- if madeNetworkCall {
- t.Fatal("Network call was made, even though rate limit is known to still be exceeded.")
- }
-
- if err == nil {
- t.Error("Expected error to be returned.")
- }
- rateLimitErr, ok := err.(*RateLimitError)
- if !ok {
- t.Fatalf("Expected a *RateLimitError error; got %#v.", err)
- }
- if got, want := rateLimitErr.Rate.Limit, 60; got != want {
- t.Errorf("rateLimitErr rate limit = %v, want %v", got, want)
- }
- if got, want := rateLimitErr.Rate.Remaining, 0; got != want {
- t.Errorf("rateLimitErr rate remaining = %v, want %v", got, want)
- }
- if rateLimitErr.Rate.Reset.UTC() != reset {
- t.Errorf("rateLimitErr rate reset = %v, want %v", rateLimitErr.Rate.Reset.UTC(), reset)
- }
-}
-
-// Ensure *AbuseRateLimitError is returned when the response indicates that
-// the client has triggered an abuse detection mechanism.
-func TestDo_rateLimit_abuseRateLimitError(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- w.Header().Set("Content-Type", "application/json; charset=utf-8")
- w.WriteHeader(http.StatusForbidden)
- // When the abuse rate limit error is of the "temporarily blocked from content creation" type,
- // there is no "Retry-After" header.
- fmt.Fprintln(w, `{
- "message": "You have triggered an abuse detection mechanism and have been temporarily blocked from content creation. Please retry your request again later.",
- "documentation_url": "https://developer.github.com/v3/#abuse-rate-limits"
-}`)
- })
-
- req, _ := client.NewRequest("GET", ".", nil)
- _, err := client.Do(context.Background(), req, nil)
-
- if err == nil {
- t.Error("Expected error to be returned.")
- }
- abuseRateLimitErr, ok := err.(*AbuseRateLimitError)
- if !ok {
- t.Fatalf("Expected a *AbuseRateLimitError error; got %#v.", err)
- }
- if got, want := abuseRateLimitErr.RetryAfter, (*time.Duration)(nil); got != want {
- t.Errorf("abuseRateLimitErr RetryAfter = %v, want %v", got, want)
- }
-}
-
-// Ensure *AbuseRateLimitError.RetryAfter is parsed correctly.
-func TestDo_rateLimit_abuseRateLimitError_retryAfter(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- w.Header().Set("Content-Type", "application/json; charset=utf-8")
- w.Header().Set("Retry-After", "123") // Retry after value of 123 seconds.
- w.WriteHeader(http.StatusForbidden)
- fmt.Fprintln(w, `{
- "message": "You have triggered an abuse detection mechanism ...",
- "documentation_url": "https://developer.github.com/v3/#abuse-rate-limits"
-}`)
- })
-
- req, _ := client.NewRequest("GET", ".", nil)
- _, err := client.Do(context.Background(), req, nil)
-
- if err == nil {
- t.Error("Expected error to be returned.")
- }
- abuseRateLimitErr, ok := err.(*AbuseRateLimitError)
- if !ok {
- t.Fatalf("Expected a *AbuseRateLimitError error; got %#v.", err)
- }
- if abuseRateLimitErr.RetryAfter == nil {
- t.Fatalf("abuseRateLimitErr RetryAfter is nil, expected not-nil")
- }
- if got, want := *abuseRateLimitErr.RetryAfter, 123*time.Second; got != want {
- t.Errorf("abuseRateLimitErr RetryAfter = %v, want %v", got, want)
- }
-}
-
-func TestDo_noContent(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- w.WriteHeader(http.StatusNoContent)
- })
-
- var body json.RawMessage
-
- req, _ := client.NewRequest("GET", ".", nil)
- _, err := client.Do(context.Background(), req, &body)
- if err != nil {
- t.Fatalf("Do returned unexpected error: %v", err)
- }
-}
-
-func TestSanitizeURL(t *testing.T) {
- tests := []struct {
- in, want string
- }{
- {"/?a=b", "/?a=b"},
- {"/?a=b&client_secret=secret", "/?a=b&client_secret=REDACTED"},
- {"/?a=b&client_id=id&client_secret=secret", "/?a=b&client_id=id&client_secret=REDACTED"},
- }
-
- for _, tt := range tests {
- inURL, _ := url.Parse(tt.in)
- want, _ := url.Parse(tt.want)
-
- if got := sanitizeURL(inURL); !reflect.DeepEqual(got, want) {
- t.Errorf("sanitizeURL(%v) returned %v, want %v", tt.in, got, want)
- }
- }
-}
-
-func TestCheckResponse(t *testing.T) {
- res := &http.Response{
- Request: &http.Request{},
- StatusCode: http.StatusBadRequest,
- Body: ioutil.NopCloser(strings.NewReader(`{"message":"m",
- "errors": [{"resource": "r", "field": "f", "code": "c"}],
- "block": {"reason": "dmca", "created_at": "2016-03-17T15:39:46Z"}}`)),
- }
- err := CheckResponse(res).(*ErrorResponse)
-
- if err == nil {
- t.Errorf("Expected error response.")
- }
-
- want := &ErrorResponse{
- Response: res,
- Message: "m",
- Errors: []Error{{Resource: "r", Field: "f", Code: "c"}},
- Block: &struct {
- Reason string `json:"reason,omitempty"`
- CreatedAt *Timestamp `json:"created_at,omitempty"`
- }{
- Reason: "dmca",
- CreatedAt: &Timestamp{time.Date(2016, 3, 17, 15, 39, 46, 0, time.UTC)},
- },
- }
- if !reflect.DeepEqual(err, want) {
- t.Errorf("Error = %#v, want %#v", err, want)
- }
-}
-
-// ensure that we properly handle API errors that do not contain a response body
-func TestCheckResponse_noBody(t *testing.T) {
- res := &http.Response{
- Request: &http.Request{},
- StatusCode: http.StatusBadRequest,
- Body: ioutil.NopCloser(strings.NewReader("")),
- }
- err := CheckResponse(res).(*ErrorResponse)
-
- if err == nil {
- t.Errorf("Expected error response.")
- }
-
- want := &ErrorResponse{
- Response: res,
- }
- if !reflect.DeepEqual(err, want) {
- t.Errorf("Error = %#v, want %#v", err, want)
- }
-}
-
-func TestParseBooleanResponse_true(t *testing.T) {
- result, err := parseBoolResponse(nil)
- if err != nil {
- t.Errorf("parseBoolResponse returned error: %+v", err)
- }
-
- if want := true; result != want {
- t.Errorf("parseBoolResponse returned %+v, want: %+v", result, want)
- }
-}
-
-func TestParseBooleanResponse_false(t *testing.T) {
- v := &ErrorResponse{Response: &http.Response{StatusCode: http.StatusNotFound}}
- result, err := parseBoolResponse(v)
- if err != nil {
- t.Errorf("parseBoolResponse returned error: %+v", err)
- }
-
- if want := false; result != want {
- t.Errorf("parseBoolResponse returned %+v, want: %+v", result, want)
- }
-}
-
-func TestParseBooleanResponse_error(t *testing.T) {
- v := &ErrorResponse{Response: &http.Response{StatusCode: http.StatusBadRequest}}
- result, err := parseBoolResponse(v)
-
- if err == nil {
- t.Errorf("Expected error to be returned.")
- }
-
- if want := false; result != want {
- t.Errorf("parseBoolResponse returned %+v, want: %+v", result, want)
- }
-}
-
-func TestErrorResponse_Error(t *testing.T) {
- res := &http.Response{Request: &http.Request{}}
- err := ErrorResponse{Message: "m", Response: res}
- if err.Error() == "" {
- t.Errorf("Expected non-empty ErrorResponse.Error()")
- }
-}
-
-func TestError_Error(t *testing.T) {
- err := Error{}
- if err.Error() == "" {
- t.Errorf("Expected non-empty Error.Error()")
- }
-}
-
-func TestRateLimits(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/rate_limit", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"resources":{
- "core": {"limit":2,"remaining":1,"reset":1372700873},
- "search": {"limit":3,"remaining":2,"reset":1372700874}
- }}`)
- })
-
- rate, _, err := client.RateLimits(context.Background())
- if err != nil {
- t.Errorf("RateLimits returned error: %v", err)
- }
-
- want := &RateLimits{
- Core: &Rate{
- Limit: 2,
- Remaining: 1,
- Reset: Timestamp{time.Date(2013, 7, 1, 17, 47, 53, 0, time.UTC).Local()},
- },
- Search: &Rate{
- Limit: 3,
- Remaining: 2,
- Reset: Timestamp{time.Date(2013, 7, 1, 17, 47, 54, 0, time.UTC).Local()},
- },
- }
- if !reflect.DeepEqual(rate, want) {
- t.Errorf("RateLimits returned %+v, want %+v", rate, want)
- }
-
- if got, want := client.rateLimits[coreCategory], *want.Core; got != want {
- t.Errorf("client.rateLimits[coreCategory] is %+v, want %+v", got, want)
- }
- if got, want := client.rateLimits[searchCategory], *want.Search; got != want {
- t.Errorf("client.rateLimits[searchCategory] is %+v, want %+v", got, want)
- }
-}
-
-func TestUnauthenticatedRateLimitedTransport(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- var v, want string
- q := r.URL.Query()
- if v, want = q.Get("client_id"), "id"; v != want {
- t.Errorf("OAuth Client ID = %v, want %v", v, want)
- }
- if v, want = q.Get("client_secret"), "secret"; v != want {
- t.Errorf("OAuth Client Secret = %v, want %v", v, want)
- }
- })
-
- tp := &UnauthenticatedRateLimitedTransport{
- ClientID: "id",
- ClientSecret: "secret",
- }
- unauthedClient := NewClient(tp.Client())
- unauthedClient.BaseURL = client.BaseURL
- req, _ := unauthedClient.NewRequest("GET", ".", nil)
- unauthedClient.Do(context.Background(), req, nil)
-}
-
-func TestUnauthenticatedRateLimitedTransport_missingFields(t *testing.T) {
- // missing ClientID
- tp := &UnauthenticatedRateLimitedTransport{
- ClientSecret: "secret",
- }
- _, err := tp.RoundTrip(nil)
- if err == nil {
- t.Errorf("Expected error to be returned")
- }
-
- // missing ClientSecret
- tp = &UnauthenticatedRateLimitedTransport{
- ClientID: "id",
- }
- _, err = tp.RoundTrip(nil)
- if err == nil {
- t.Errorf("Expected error to be returned")
- }
-}
-
-func TestUnauthenticatedRateLimitedTransport_transport(t *testing.T) {
- // default transport
- tp := &UnauthenticatedRateLimitedTransport{
- ClientID: "id",
- ClientSecret: "secret",
- }
- if tp.transport() != http.DefaultTransport {
- t.Errorf("Expected http.DefaultTransport to be used.")
- }
-
- // custom transport
- tp = &UnauthenticatedRateLimitedTransport{
- ClientID: "id",
- ClientSecret: "secret",
- Transport: &http.Transport{},
- }
- if tp.transport() == http.DefaultTransport {
- t.Errorf("Expected custom transport to be used.")
- }
-}
-
-func TestBasicAuthTransport(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- username, password, otp := "u", "p", "123456"
-
- mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- u, p, ok := r.BasicAuth()
- if !ok {
- t.Errorf("request does not contain basic auth credentials")
- }
- if u != username {
- t.Errorf("request contained basic auth username %q, want %q", u, username)
- }
- if p != password {
- t.Errorf("request contained basic auth password %q, want %q", p, password)
- }
- if got, want := r.Header.Get(headerOTP), otp; got != want {
- t.Errorf("request contained OTP %q, want %q", got, want)
- }
- })
-
- tp := &BasicAuthTransport{
- Username: username,
- Password: password,
- OTP: otp,
- }
- basicAuthClient := NewClient(tp.Client())
- basicAuthClient.BaseURL = client.BaseURL
- req, _ := basicAuthClient.NewRequest("GET", ".", nil)
- basicAuthClient.Do(context.Background(), req, nil)
-}
-
-func TestBasicAuthTransport_transport(t *testing.T) {
- // default transport
- tp := &BasicAuthTransport{}
- if tp.transport() != http.DefaultTransport {
- t.Errorf("Expected http.DefaultTransport to be used.")
- }
-
- // custom transport
- tp = &BasicAuthTransport{
- Transport: &http.Transport{},
- }
- if tp.transport() == http.DefaultTransport {
- t.Errorf("Expected custom transport to be used.")
- }
-}
-
-func TestFormatRateReset(t *testing.T) {
- d := 120*time.Minute + 12*time.Second
- got := formatRateReset(d)
- want := "[rate reset in 120m12s]"
- if got != want {
- t.Errorf("Format is wrong. got: %v, want: %v", got, want)
- }
-
- d = 14*time.Minute + 2*time.Second
- got = formatRateReset(d)
- want = "[rate reset in 14m02s]"
- if got != want {
- t.Errorf("Format is wrong. got: %v, want: %v", got, want)
- }
-
- d = 2*time.Minute + 2*time.Second
- got = formatRateReset(d)
- want = "[rate reset in 2m02s]"
- if got != want {
- t.Errorf("Format is wrong. got: %v, want: %v", got, want)
- }
-
- d = 12 * time.Second
- got = formatRateReset(d)
- want = "[rate reset in 12s]"
- if got != want {
- t.Errorf("Format is wrong. got: %v, want: %v", got, want)
- }
-
- d = -1 * (2*time.Hour + 2*time.Second)
- got = formatRateReset(d)
- want = "[rate limit was reset 120m02s ago]"
- if got != want {
- t.Errorf("Format is wrong. got: %v, want: %v", got, want)
- }
-}
-
-func TestNestedStructAccessorNoPanic(t *testing.T) {
- issue := &Issue{User: nil}
- got := issue.GetUser().GetPlan().GetName()
- want := ""
- if got != want {
- t.Errorf("Issues.Get.GetUser().GetPlan().GetName() returned %+v, want %+v", got, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/gitignore_test.go b/vendor/github.com/google/go-github/github/gitignore_test.go
deleted file mode 100644
index cdb82237..00000000
--- a/vendor/github.com/google/go-github/github/gitignore_test.go
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestGitignoresService_List(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gitignore/templates", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `["C", "Go"]`)
- })
-
- available, _, err := client.Gitignores.List(context.Background())
- if err != nil {
- t.Errorf("Gitignores.List returned error: %v", err)
- }
-
- want := []string{"C", "Go"}
- if !reflect.DeepEqual(available, want) {
- t.Errorf("Gitignores.List returned %+v, want %+v", available, want)
- }
-}
-
-func TestGitignoresService_Get(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/gitignore/templates/name", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"name":"Name","source":"template source"}`)
- })
-
- gitignore, _, err := client.Gitignores.Get(context.Background(), "name")
- if err != nil {
- t.Errorf("Gitignores.List returned error: %v", err)
- }
-
- want := &Gitignore{Name: String("Name"), Source: String("template source")}
- if !reflect.DeepEqual(gitignore, want) {
- t.Errorf("Gitignores.Get returned %+v, want %+v", gitignore, want)
- }
-}
-
-func TestGitignoresService_Get_invalidTemplate(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Gitignores.Get(context.Background(), "%")
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/issues_assignees_test.go b/vendor/github.com/google/go-github/github/issues_assignees_test.go
deleted file mode 100644
index bb2bf4ff..00000000
--- a/vendor/github.com/google/go-github/github/issues_assignees_test.go
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestIssuesService_ListAssignees(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/assignees", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 2}
- assignees, _, err := client.Issues.ListAssignees(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Issues.ListAssignees returned error: %v", err)
- }
-
- want := []*User{{ID: Int64(1)}}
- if !reflect.DeepEqual(assignees, want) {
- t.Errorf("Issues.ListAssignees returned %+v, want %+v", assignees, want)
- }
-}
-
-func TestIssuesService_ListAssignees_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.ListAssignees(context.Background(), "%", "r", nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_IsAssignee_true(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/assignees/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- })
-
- assignee, _, err := client.Issues.IsAssignee(context.Background(), "o", "r", "u")
- if err != nil {
- t.Errorf("Issues.IsAssignee returned error: %v", err)
- }
- if want := true; assignee != want {
- t.Errorf("Issues.IsAssignee returned %+v, want %+v", assignee, want)
- }
-}
-
-func TestIssuesService_IsAssignee_false(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/assignees/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNotFound)
- })
-
- assignee, _, err := client.Issues.IsAssignee(context.Background(), "o", "r", "u")
- if err != nil {
- t.Errorf("Issues.IsAssignee returned error: %v", err)
- }
- if want := false; assignee != want {
- t.Errorf("Issues.IsAssignee returned %+v, want %+v", assignee, want)
- }
-}
-
-func TestIssuesService_IsAssignee_error(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/assignees/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- http.Error(w, "BadRequest", http.StatusBadRequest)
- })
-
- assignee, _, err := client.Issues.IsAssignee(context.Background(), "o", "r", "u")
- if err == nil {
- t.Errorf("Expected HTTP 400 response")
- }
- if want := false; assignee != want {
- t.Errorf("Issues.IsAssignee returned %+v, want %+v", assignee, want)
- }
-}
-
-func TestIssuesService_IsAssignee_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.IsAssignee(context.Background(), "%", "r", "u")
- testURLParseError(t, err)
-}
-
-func TestIssuesService_AddAssignees(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/1/assignees", func(w http.ResponseWriter, r *http.Request) {
- var assignees struct {
- Assignees []string `json:"assignees,omitempty"`
- }
- json.NewDecoder(r.Body).Decode(&assignees)
-
- testMethod(t, r, "POST")
- want := []string{"user1", "user2"}
- if !reflect.DeepEqual(assignees.Assignees, want) {
- t.Errorf("assignees = %+v, want %+v", assignees, want)
- }
- fmt.Fprint(w, `{"number":1,"assignees":[{"login":"user1"},{"login":"user2"}]}`)
- })
-
- got, _, err := client.Issues.AddAssignees(context.Background(), "o", "r", 1, []string{"user1", "user2"})
- if err != nil {
- t.Errorf("Issues.AddAssignees returned error: %v", err)
- }
-
- want := &Issue{Number: Int(1), Assignees: []*User{{Login: String("user1")}, {Login: String("user2")}}}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Issues.AddAssignees = %+v, want %+v", got, want)
- }
-}
-
-func TestIssuesService_RemoveAssignees(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/1/assignees", func(w http.ResponseWriter, r *http.Request) {
- var assignees struct {
- Assignees []string `json:"assignees,omitempty"`
- }
- json.NewDecoder(r.Body).Decode(&assignees)
-
- testMethod(t, r, "DELETE")
- want := []string{"user1", "user2"}
- if !reflect.DeepEqual(assignees.Assignees, want) {
- t.Errorf("assignees = %+v, want %+v", assignees, want)
- }
- fmt.Fprint(w, `{"number":1,"assignees":[]}`)
- })
-
- got, _, err := client.Issues.RemoveAssignees(context.Background(), "o", "r", 1, []string{"user1", "user2"})
- if err != nil {
- t.Errorf("Issues.RemoveAssignees returned error: %v", err)
- }
-
- want := &Issue{Number: Int(1), Assignees: []*User{}}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Issues.RemoveAssignees = %+v, want %+v", got, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/issues_comments_test.go b/vendor/github.com/google/go-github/github/issues_comments_test.go
deleted file mode 100644
index 6911a798..00000000
--- a/vendor/github.com/google/go-github/github/issues_comments_test.go
+++ /dev/null
@@ -1,203 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
- "time"
-)
-
-func TestIssuesService_ListComments_allIssues(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/comments", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
- testFormValues(t, r, values{
- "sort": "updated",
- "direction": "desc",
- "since": "2002-02-10T15:30:00Z",
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &IssueListCommentsOptions{
- Sort: "updated",
- Direction: "desc",
- Since: time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC),
- ListOptions: ListOptions{Page: 2},
- }
- comments, _, err := client.Issues.ListComments(context.Background(), "o", "r", 0, opt)
- if err != nil {
- t.Errorf("Issues.ListComments returned error: %v", err)
- }
-
- want := []*IssueComment{{ID: Int64(1)}}
- if !reflect.DeepEqual(comments, want) {
- t.Errorf("Issues.ListComments returned %+v, want %+v", comments, want)
- }
-}
-
-func TestIssuesService_ListComments_specificIssue(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/1/comments", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- comments, _, err := client.Issues.ListComments(context.Background(), "o", "r", 1, nil)
- if err != nil {
- t.Errorf("Issues.ListComments returned error: %v", err)
- }
-
- want := []*IssueComment{{ID: Int64(1)}}
- if !reflect.DeepEqual(comments, want) {
- t.Errorf("Issues.ListComments returned %+v, want %+v", comments, want)
- }
-}
-
-func TestIssuesService_ListComments_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.ListComments(context.Background(), "%", "r", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_GetComment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/comments/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
- fmt.Fprint(w, `{"id":1}`)
- })
-
- comment, _, err := client.Issues.GetComment(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Issues.GetComment returned error: %v", err)
- }
-
- want := &IssueComment{ID: Int64(1)}
- if !reflect.DeepEqual(comment, want) {
- t.Errorf("Issues.GetComment returned %+v, want %+v", comment, want)
- }
-}
-
-func TestIssuesService_GetComment_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.GetComment(context.Background(), "%", "r", 1)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_CreateComment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &IssueComment{Body: String("b")}
-
- mux.HandleFunc("/repos/o/r/issues/1/comments", func(w http.ResponseWriter, r *http.Request) {
- v := new(IssueComment)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- comment, _, err := client.Issues.CreateComment(context.Background(), "o", "r", 1, input)
- if err != nil {
- t.Errorf("Issues.CreateComment returned error: %v", err)
- }
-
- want := &IssueComment{ID: Int64(1)}
- if !reflect.DeepEqual(comment, want) {
- t.Errorf("Issues.CreateComment returned %+v, want %+v", comment, want)
- }
-}
-
-func TestIssuesService_CreateComment_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.CreateComment(context.Background(), "%", "r", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_EditComment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &IssueComment{Body: String("b")}
-
- mux.HandleFunc("/repos/o/r/issues/comments/1", func(w http.ResponseWriter, r *http.Request) {
- v := new(IssueComment)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- comment, _, err := client.Issues.EditComment(context.Background(), "o", "r", 1, input)
- if err != nil {
- t.Errorf("Issues.EditComment returned error: %v", err)
- }
-
- want := &IssueComment{ID: Int64(1)}
- if !reflect.DeepEqual(comment, want) {
- t.Errorf("Issues.EditComment returned %+v, want %+v", comment, want)
- }
-}
-
-func TestIssuesService_EditComment_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.EditComment(context.Background(), "%", "r", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_DeleteComment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/comments/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Issues.DeleteComment(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Issues.DeleteComments returned error: %v", err)
- }
-}
-
-func TestIssuesService_DeleteComment_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Issues.DeleteComment(context.Background(), "%", "r", 1)
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/issues_events_test.go b/vendor/github.com/google/go-github/github/issues_events_test.go
deleted file mode 100644
index fe21ecbe..00000000
--- a/vendor/github.com/google/go-github/github/issues_events_test.go
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2014 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestIssuesService_ListIssueEvents(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/1/events", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "1",
- "per_page": "2",
- })
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 1, PerPage: 2}
- events, _, err := client.Issues.ListIssueEvents(context.Background(), "o", "r", 1, opt)
- if err != nil {
- t.Errorf("Issues.ListIssueEvents returned error: %v", err)
- }
-
- want := []*IssueEvent{{ID: Int64(1)}}
- if !reflect.DeepEqual(events, want) {
- t.Errorf("Issues.ListIssueEvents returned %+v, want %+v", events, want)
- }
-}
-
-func TestIssuesService_ListRepositoryEvents(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/events", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "1",
- "per_page": "2",
- })
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 1, PerPage: 2}
- events, _, err := client.Issues.ListRepositoryEvents(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Issues.ListRepositoryEvents returned error: %v", err)
- }
-
- want := []*IssueEvent{{ID: Int64(1)}}
- if !reflect.DeepEqual(events, want) {
- t.Errorf("Issues.ListRepositoryEvents returned %+v, want %+v", events, want)
- }
-}
-
-func TestIssuesService_GetEvent(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/events/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id":1}`)
- })
-
- event, _, err := client.Issues.GetEvent(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Issues.GetEvent returned error: %v", err)
- }
-
- want := &IssueEvent{ID: Int64(1)}
- if !reflect.DeepEqual(event, want) {
- t.Errorf("Issues.GetEvent returned %+v, want %+v", event, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/issues_labels_test.go b/vendor/github.com/google/go-github/github/issues_labels_test.go
deleted file mode 100644
index 02ac9041..00000000
--- a/vendor/github.com/google/go-github/github/issues_labels_test.go
+++ /dev/null
@@ -1,358 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestIssuesService_ListLabels(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/labels", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"name": "a"},{"name": "b"}]`)
- })
-
- opt := &ListOptions{Page: 2}
- labels, _, err := client.Issues.ListLabels(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Issues.ListLabels returned error: %v", err)
- }
-
- want := []*Label{{Name: String("a")}, {Name: String("b")}}
- if !reflect.DeepEqual(labels, want) {
- t.Errorf("Issues.ListLabels returned %+v, want %+v", labels, want)
- }
-}
-
-func TestIssuesService_ListLabels_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.ListLabels(context.Background(), "%", "%", nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_GetLabel(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/labels/n", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, `{"url":"u", "name": "n", "color": "c"}`)
- })
-
- label, _, err := client.Issues.GetLabel(context.Background(), "o", "r", "n")
- if err != nil {
- t.Errorf("Issues.GetLabel returned error: %v", err)
- }
-
- want := &Label{URL: String("u"), Name: String("n"), Color: String("c")}
- if !reflect.DeepEqual(label, want) {
- t.Errorf("Issues.GetLabel returned %+v, want %+v", label, want)
- }
-}
-
-func TestIssuesService_GetLabel_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.GetLabel(context.Background(), "%", "%", "%")
- testURLParseError(t, err)
-}
-
-func TestIssuesService_CreateLabel(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Label{Name: String("n")}
-
- mux.HandleFunc("/repos/o/r/labels", func(w http.ResponseWriter, r *http.Request) {
- v := new(Label)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"url":"u"}`)
- })
-
- label, _, err := client.Issues.CreateLabel(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("Issues.CreateLabel returned error: %v", err)
- }
-
- want := &Label{URL: String("u")}
- if !reflect.DeepEqual(label, want) {
- t.Errorf("Issues.CreateLabel returned %+v, want %+v", label, want)
- }
-}
-
-func TestIssuesService_CreateLabel_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.CreateLabel(context.Background(), "%", "%", nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_EditLabel(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Label{Name: String("z")}
-
- mux.HandleFunc("/repos/o/r/labels/n", func(w http.ResponseWriter, r *http.Request) {
- v := new(Label)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"url":"u"}`)
- })
-
- label, _, err := client.Issues.EditLabel(context.Background(), "o", "r", "n", input)
- if err != nil {
- t.Errorf("Issues.EditLabel returned error: %v", err)
- }
-
- want := &Label{URL: String("u")}
- if !reflect.DeepEqual(label, want) {
- t.Errorf("Issues.EditLabel returned %+v, want %+v", label, want)
- }
-}
-
-func TestIssuesService_EditLabel_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.EditLabel(context.Background(), "%", "%", "%", nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_DeleteLabel(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/labels/n", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Issues.DeleteLabel(context.Background(), "o", "r", "n")
- if err != nil {
- t.Errorf("Issues.DeleteLabel returned error: %v", err)
- }
-}
-
-func TestIssuesService_DeleteLabel_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Issues.DeleteLabel(context.Background(), "%", "%", "%")
- testURLParseError(t, err)
-}
-
-func TestIssuesService_ListLabelsByIssue(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/1/labels", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"name":"a","id":1},{"name":"b","id":2}]`)
- })
-
- opt := &ListOptions{Page: 2}
- labels, _, err := client.Issues.ListLabelsByIssue(context.Background(), "o", "r", 1, opt)
- if err != nil {
- t.Errorf("Issues.ListLabelsByIssue returned error: %v", err)
- }
-
- want := []*Label{
- {Name: String("a"), ID: Int64(1)},
- {Name: String("b"), ID: Int64(2)},
- }
- if !reflect.DeepEqual(labels, want) {
- t.Errorf("Issues.ListLabelsByIssue returned %+v, want %+v", labels, want)
- }
-}
-
-func TestIssuesService_ListLabelsByIssue_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.ListLabelsByIssue(context.Background(), "%", "%", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_AddLabelsToIssue(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := []string{"a", "b"}
-
- mux.HandleFunc("/repos/o/r/issues/1/labels", func(w http.ResponseWriter, r *http.Request) {
- var v []string
- json.NewDecoder(r.Body).Decode(&v)
-
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `[{"url":"u"}]`)
- })
-
- labels, _, err := client.Issues.AddLabelsToIssue(context.Background(), "o", "r", 1, input)
- if err != nil {
- t.Errorf("Issues.AddLabelsToIssue returned error: %v", err)
- }
-
- want := []*Label{{URL: String("u")}}
- if !reflect.DeepEqual(labels, want) {
- t.Errorf("Issues.AddLabelsToIssue returned %+v, want %+v", labels, want)
- }
-}
-
-func TestIssuesService_AddLabelsToIssue_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.AddLabelsToIssue(context.Background(), "%", "%", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_RemoveLabelForIssue(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/1/labels/l", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Issues.RemoveLabelForIssue(context.Background(), "o", "r", 1, "l")
- if err != nil {
- t.Errorf("Issues.RemoveLabelForIssue returned error: %v", err)
- }
-}
-
-func TestIssuesService_RemoveLabelForIssue_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Issues.RemoveLabelForIssue(context.Background(), "%", "%", 1, "%")
- testURLParseError(t, err)
-}
-
-func TestIssuesService_ReplaceLabelsForIssue(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := []string{"a", "b"}
-
- mux.HandleFunc("/repos/o/r/issues/1/labels", func(w http.ResponseWriter, r *http.Request) {
- var v []string
- json.NewDecoder(r.Body).Decode(&v)
-
- testMethod(t, r, "PUT")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `[{"url":"u"}]`)
- })
-
- labels, _, err := client.Issues.ReplaceLabelsForIssue(context.Background(), "o", "r", 1, input)
- if err != nil {
- t.Errorf("Issues.ReplaceLabelsForIssue returned error: %v", err)
- }
-
- want := []*Label{{URL: String("u")}}
- if !reflect.DeepEqual(labels, want) {
- t.Errorf("Issues.ReplaceLabelsForIssue returned %+v, want %+v", labels, want)
- }
-}
-
-func TestIssuesService_ReplaceLabelsForIssue_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.ReplaceLabelsForIssue(context.Background(), "%", "%", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_RemoveLabelsForIssue(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/1/labels", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Issues.RemoveLabelsForIssue(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Issues.RemoveLabelsForIssue returned error: %v", err)
- }
-}
-
-func TestIssuesService_RemoveLabelsForIssue_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Issues.RemoveLabelsForIssue(context.Background(), "%", "%", 1)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_ListLabelsForMilestone(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/milestones/1/labels", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"name": "a"},{"name": "b"}]`)
- })
-
- opt := &ListOptions{Page: 2}
- labels, _, err := client.Issues.ListLabelsForMilestone(context.Background(), "o", "r", 1, opt)
- if err != nil {
- t.Errorf("Issues.ListLabelsForMilestone returned error: %v", err)
- }
-
- want := []*Label{{Name: String("a")}, {Name: String("b")}}
- if !reflect.DeepEqual(labels, want) {
- t.Errorf("Issues.ListLabelsForMilestone returned %+v, want %+v", labels, want)
- }
-}
-
-func TestIssuesService_ListLabelsForMilestone_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.ListLabelsForMilestone(context.Background(), "%", "%", 1, nil)
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/issues_milestones_test.go b/vendor/github.com/google/go-github/github/issues_milestones_test.go
deleted file mode 100644
index 006e4817..00000000
--- a/vendor/github.com/google/go-github/github/issues_milestones_test.go
+++ /dev/null
@@ -1,178 +0,0 @@
-// Copyright 2014 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestIssuesService_ListMilestones(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/milestones", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testFormValues(t, r, values{
- "state": "closed",
- "sort": "due_date",
- "direction": "asc",
- "page": "2",
- })
- fmt.Fprint(w, `[{"number":1}]`)
- })
-
- opt := &MilestoneListOptions{"closed", "due_date", "asc", ListOptions{Page: 2}}
- milestones, _, err := client.Issues.ListMilestones(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("IssuesService.ListMilestones returned error: %v", err)
- }
-
- want := []*Milestone{{Number: Int(1)}}
- if !reflect.DeepEqual(milestones, want) {
- t.Errorf("IssuesService.ListMilestones returned %+v, want %+v", milestones, want)
- }
-}
-
-func TestIssuesService_ListMilestones_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.ListMilestones(context.Background(), "%", "r", nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_GetMilestone(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/milestones/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, `{"number":1}`)
- })
-
- milestone, _, err := client.Issues.GetMilestone(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("IssuesService.GetMilestone returned error: %v", err)
- }
-
- want := &Milestone{Number: Int(1)}
- if !reflect.DeepEqual(milestone, want) {
- t.Errorf("IssuesService.GetMilestone returned %+v, want %+v", milestone, want)
- }
-}
-
-func TestIssuesService_GetMilestone_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.GetMilestone(context.Background(), "%", "r", 1)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_CreateMilestone(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Milestone{Title: String("t")}
-
- mux.HandleFunc("/repos/o/r/milestones", func(w http.ResponseWriter, r *http.Request) {
- v := new(Milestone)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"number":1}`)
- })
-
- milestone, _, err := client.Issues.CreateMilestone(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("IssuesService.CreateMilestone returned error: %v", err)
- }
-
- want := &Milestone{Number: Int(1)}
- if !reflect.DeepEqual(milestone, want) {
- t.Errorf("IssuesService.CreateMilestone returned %+v, want %+v", milestone, want)
- }
-}
-
-func TestIssuesService_CreateMilestone_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.CreateMilestone(context.Background(), "%", "r", nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_EditMilestone(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Milestone{Title: String("t")}
-
- mux.HandleFunc("/repos/o/r/milestones/1", func(w http.ResponseWriter, r *http.Request) {
- v := new(Milestone)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"number":1}`)
- })
-
- milestone, _, err := client.Issues.EditMilestone(context.Background(), "o", "r", 1, input)
- if err != nil {
- t.Errorf("IssuesService.EditMilestone returned error: %v", err)
- }
-
- want := &Milestone{Number: Int(1)}
- if !reflect.DeepEqual(milestone, want) {
- t.Errorf("IssuesService.EditMilestone returned %+v, want %+v", milestone, want)
- }
-}
-
-func TestIssuesService_EditMilestone_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.EditMilestone(context.Background(), "%", "r", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_DeleteMilestone(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/milestones/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Issues.DeleteMilestone(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("IssuesService.DeleteMilestone returned error: %v", err)
- }
-}
-
-func TestIssuesService_DeleteMilestone_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Issues.DeleteMilestone(context.Background(), "%", "r", 1)
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/issues_test.go b/vendor/github.com/google/go-github/github/issues_test.go
deleted file mode 100644
index aeca2469..00000000
--- a/vendor/github.com/google/go-github/github/issues_test.go
+++ /dev/null
@@ -1,311 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "strings"
- "testing"
- "time"
-)
-
-func TestIssuesService_List_all(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeGraphQLNodeIDPreview}
- mux.HandleFunc("/issues", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
- testFormValues(t, r, values{
- "filter": "all",
- "state": "closed",
- "labels": "a,b",
- "sort": "updated",
- "direction": "asc",
- "since": "2002-02-10T15:30:00Z",
- "page": "1",
- "per_page": "2",
- })
- fmt.Fprint(w, `[{"number":1}]`)
- })
-
- opt := &IssueListOptions{
- "all", "closed", []string{"a", "b"}, "updated", "asc",
- time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC),
- ListOptions{Page: 1, PerPage: 2},
- }
- issues, _, err := client.Issues.List(context.Background(), true, opt)
- if err != nil {
- t.Errorf("Issues.List returned error: %v", err)
- }
-
- want := []*Issue{{Number: Int(1)}}
- if !reflect.DeepEqual(issues, want) {
- t.Errorf("Issues.List returned %+v, want %+v", issues, want)
- }
-}
-
-func TestIssuesService_List_owned(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeGraphQLNodeIDPreview}
- mux.HandleFunc("/user/issues", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
- fmt.Fprint(w, `[{"number":1}]`)
- })
-
- issues, _, err := client.Issues.List(context.Background(), false, nil)
- if err != nil {
- t.Errorf("Issues.List returned error: %v", err)
- }
-
- want := []*Issue{{Number: Int(1)}}
- if !reflect.DeepEqual(issues, want) {
- t.Errorf("Issues.List returned %+v, want %+v", issues, want)
- }
-}
-
-func TestIssuesService_ListByOrg(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeGraphQLNodeIDPreview}
- mux.HandleFunc("/orgs/o/issues", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
- fmt.Fprint(w, `[{"number":1}]`)
- })
-
- issues, _, err := client.Issues.ListByOrg(context.Background(), "o", nil)
- if err != nil {
- t.Errorf("Issues.ListByOrg returned error: %v", err)
- }
-
- want := []*Issue{{Number: Int(1)}}
- if !reflect.DeepEqual(issues, want) {
- t.Errorf("Issues.List returned %+v, want %+v", issues, want)
- }
-}
-
-func TestIssuesService_ListByOrg_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.ListByOrg(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_ListByRepo(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeGraphQLNodeIDPreview}
- mux.HandleFunc("/repos/o/r/issues", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
- testFormValues(t, r, values{
- "milestone": "*",
- "state": "closed",
- "assignee": "a",
- "creator": "c",
- "mentioned": "m",
- "labels": "a,b",
- "sort": "updated",
- "direction": "asc",
- "since": "2002-02-10T15:30:00Z",
- })
- fmt.Fprint(w, `[{"number":1}]`)
- })
-
- opt := &IssueListByRepoOptions{
- "*", "closed", "a", "c", "m", []string{"a", "b"}, "updated", "asc",
- time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC),
- ListOptions{0, 0},
- }
- issues, _, err := client.Issues.ListByRepo(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Issues.ListByOrg returned error: %v", err)
- }
-
- want := []*Issue{{Number: Int(1)}}
- if !reflect.DeepEqual(issues, want) {
- t.Errorf("Issues.List returned %+v, want %+v", issues, want)
- }
-}
-
-func TestIssuesService_ListByRepo_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.ListByRepo(context.Background(), "%", "r", nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_Get(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeGraphQLNodeIDPreview}
- mux.HandleFunc("/repos/o/r/issues/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
- fmt.Fprint(w, `{"number":1, "labels": [{"url": "u", "name": "n", "color": "c"}]}`)
- })
-
- issue, _, err := client.Issues.Get(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Issues.Get returned error: %v", err)
- }
-
- want := &Issue{
- Number: Int(1),
- Labels: []Label{{
- URL: String("u"),
- Name: String("n"),
- Color: String("c"),
- }},
- }
- if !reflect.DeepEqual(issue, want) {
- t.Errorf("Issues.Get returned %+v, want %+v", issue, want)
- }
-}
-
-func TestIssuesService_Get_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.Get(context.Background(), "%", "r", 1)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_Create(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &IssueRequest{
- Title: String("t"),
- Body: String("b"),
- Assignee: String("a"),
- Labels: &[]string{"l1", "l2"},
- }
-
- mux.HandleFunc("/repos/o/r/issues", func(w http.ResponseWriter, r *http.Request) {
- v := new(IssueRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"number":1}`)
- })
-
- issue, _, err := client.Issues.Create(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("Issues.Create returned error: %v", err)
- }
-
- want := &Issue{Number: Int(1)}
- if !reflect.DeepEqual(issue, want) {
- t.Errorf("Issues.Create returned %+v, want %+v", issue, want)
- }
-}
-
-func TestIssuesService_Create_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.Create(context.Background(), "%", "r", nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_Edit(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &IssueRequest{Title: String("t")}
-
- mux.HandleFunc("/repos/o/r/issues/1", func(w http.ResponseWriter, r *http.Request) {
- v := new(IssueRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"number":1}`)
- })
-
- issue, _, err := client.Issues.Edit(context.Background(), "o", "r", 1, input)
- if err != nil {
- t.Errorf("Issues.Edit returned error: %v", err)
- }
-
- want := &Issue{Number: Int(1)}
- if !reflect.DeepEqual(issue, want) {
- t.Errorf("Issues.Edit returned %+v, want %+v", issue, want)
- }
-}
-
-func TestIssuesService_Edit_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Issues.Edit(context.Background(), "%", "r", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestIssuesService_Lock(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/1/lock", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
-
- w.WriteHeader(http.StatusNoContent)
- })
-
- if _, err := client.Issues.Lock(context.Background(), "o", "r", 1); err != nil {
- t.Errorf("Issues.Lock returned error: %v", err)
- }
-}
-
-func TestIssuesService_Unlock(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/1/lock", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
-
- w.WriteHeader(http.StatusNoContent)
- })
-
- if _, err := client.Issues.Unlock(context.Background(), "o", "r", 1); err != nil {
- t.Errorf("Issues.Unlock returned error: %v", err)
- }
-}
-
-func TestIsPullRequest(t *testing.T) {
- i := new(Issue)
- if i.IsPullRequest() == true {
- t.Errorf("expected i.IsPullRequest (%v) to return false, got true", i)
- }
- i.PullRequestLinks = &PullRequestLinks{URL: String("http://example.com")}
- if i.IsPullRequest() == false {
- t.Errorf("expected i.IsPullRequest (%v) to return true, got false", i)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/issues_timeline_test.go b/vendor/github.com/google/go-github/github/issues_timeline_test.go
deleted file mode 100644
index 93f62368..00000000
--- a/vendor/github.com/google/go-github/github/issues_timeline_test.go
+++ /dev/null
@@ -1,40 +0,0 @@
-// 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestIssuesService_ListIssueTimeline(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/1/timeline", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeTimelinePreview)
- testFormValues(t, r, values{
- "page": "1",
- "per_page": "2",
- })
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 1, PerPage: 2}
- events, _, err := client.Issues.ListIssueTimeline(context.Background(), "o", "r", 1, opt)
- if err != nil {
- t.Errorf("Issues.ListIssueTimeline returned error: %v", err)
- }
-
- want := []*Timeline{{ID: Int64(1)}}
- if !reflect.DeepEqual(events, want) {
- t.Errorf("Issues.ListIssueTimeline = %+v, want %+v", events, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/licenses_test.go b/vendor/github.com/google/go-github/github/licenses_test.go
deleted file mode 100644
index 6ab917dc..00000000
--- a/vendor/github.com/google/go-github/github/licenses_test.go
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestLicensesService_List(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/licenses", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeLicensesPreview)
- fmt.Fprint(w, `[{"key":"mit","name":"MIT","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","featured":true}]`)
- })
-
- licenses, _, err := client.Licenses.List(context.Background())
- if err != nil {
- t.Errorf("Licenses.List returned error: %v", err)
- }
-
- want := []*License{{
- Key: String("mit"),
- Name: String("MIT"),
- SPDXID: String("MIT"),
- URL: String("https://api.github.com/licenses/mit"),
- Featured: Bool(true),
- }}
- if !reflect.DeepEqual(licenses, want) {
- t.Errorf("Licenses.List returned %+v, want %+v", licenses, want)
- }
-}
-
-func TestLicensesService_Get(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/licenses/mit", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeLicensesPreview)
- fmt.Fprint(w, `{"key":"mit","name":"MIT"}`)
- })
-
- license, _, err := client.Licenses.Get(context.Background(), "mit")
- if err != nil {
- t.Errorf("Licenses.Get returned error: %v", err)
- }
-
- want := &License{Key: String("mit"), Name: String("MIT")}
- if !reflect.DeepEqual(license, want) {
- t.Errorf("Licenses.Get returned %+v, want %+v", license, want)
- }
-}
-
-func TestLicensesService_Get_invalidTemplate(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Licenses.Get(context.Background(), "%")
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/messages_test.go b/vendor/github.com/google/go-github/github/messages_test.go
deleted file mode 100644
index bb7cbabe..00000000
--- a/vendor/github.com/google/go-github/github/messages_test.go
+++ /dev/null
@@ -1,330 +0,0 @@
-// 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
-
-import (
- "bytes"
- "encoding/json"
- "net/http"
- "net/url"
- "reflect"
- "strings"
- "testing"
-)
-
-func TestValidatePayload(t *testing.T) {
- const defaultBody = `{"yo":true}` // All tests below use the default request body and signature.
- const defaultSignature = "sha1=126f2c800419c60137ce748d7672e77b65cf16d6"
- secretKey := []byte("0123456789abcdef")
- tests := []struct {
- signature string
- eventID string
- event string
- wantEventID string
- wantEvent string
- wantPayload string
- }{
- // The following tests generate expected errors:
- {}, // Missing signature
- {signature: "yo"}, // Missing signature prefix
- {signature: "sha1=yo"}, // Signature not hex string
- {signature: "sha1=012345"}, // Invalid signature
- // The following tests expect err=nil:
- {
- signature: defaultSignature,
- eventID: "dead-beef",
- event: "ping",
- wantEventID: "dead-beef",
- wantEvent: "ping",
- wantPayload: defaultBody,
- },
- {
- signature: defaultSignature,
- event: "ping",
- wantEvent: "ping",
- wantPayload: defaultBody,
- },
- {
- signature: "sha256=b1f8020f5b4cd42042f807dd939015c4a418bc1ff7f604dd55b0a19b5d953d9b",
- event: "ping",
- wantEvent: "ping",
- wantPayload: defaultBody,
- },
- {
- signature: "sha512=8456767023c1195682e182a23b3f5d19150ecea598fde8cb85918f7281b16079471b1329f92b912c4d8bd7455cb159777db8f29608b20c7c87323ba65ae62e1f",
- event: "ping",
- wantEvent: "ping",
- wantPayload: defaultBody,
- },
- }
-
- for _, test := range tests {
- buf := bytes.NewBufferString(defaultBody)
- req, err := http.NewRequest("GET", "http://localhost/event", buf)
- if err != nil {
- t.Fatalf("NewRequest: %v", err)
- }
- if test.signature != "" {
- req.Header.Set(signatureHeader, test.signature)
- }
- req.Header.Set("Content-Type", "application/json")
-
- got, err := ValidatePayload(req, secretKey)
- if err != nil {
- if test.wantPayload != "" {
- t.Errorf("ValidatePayload(%#v): err = %v, want nil", test, err)
- }
- continue
- }
- if string(got) != test.wantPayload {
- t.Errorf("ValidatePayload = %q, want %q", got, test.wantPayload)
- }
- }
-}
-
-func TestValidatePayload_FormGet(t *testing.T) {
- payload := `{"yo":true}`
- signature := "sha1=3374ef144403e8035423b23b02e2c9d7a4c50368"
- secretKey := []byte("0123456789abcdef")
-
- form := url.Values{}
- form.Add("payload", payload)
- req, err := http.NewRequest("POST", "http://localhost/event", strings.NewReader(form.Encode()))
- if err != nil {
- t.Fatalf("NewRequest: %v", err)
- }
- req.PostForm = form
- req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
- req.Header.Set(signatureHeader, signature)
-
- got, err := ValidatePayload(req, secretKey)
- if err != nil {
- t.Errorf("ValidatePayload(%#v): err = %v, want nil", payload, err)
- }
- if string(got) != payload {
- t.Errorf("ValidatePayload = %q, want %q", got, payload)
- }
-
- // check that if payload is invalid we get error
- req.Header.Set(signatureHeader, "invalid signature")
- if _, err = ValidatePayload(req, nil); err == nil {
- t.Error("ValidatePayload = nil, want err")
- }
-}
-
-func TestValidatePayload_FormPost(t *testing.T) {
- payload := `{"yo":true}`
- signature := "sha1=3374ef144403e8035423b23b02e2c9d7a4c50368"
- secretKey := []byte("0123456789abcdef")
-
- form := url.Values{}
- form.Set("payload", payload)
- buf := bytes.NewBufferString(form.Encode())
- req, err := http.NewRequest("POST", "http://localhost/event", buf)
- if err != nil {
- t.Fatalf("NewRequest: %v", err)
- }
- req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
- req.Header.Set(signatureHeader, signature)
-
- got, err := ValidatePayload(req, secretKey)
- if err != nil {
- t.Errorf("ValidatePayload(%#v): err = %v, want nil", payload, err)
- }
- if string(got) != payload {
- t.Errorf("ValidatePayload = %q, want %q", got, payload)
- }
-
- // check that if payload is invalid we get error
- req.Header.Set(signatureHeader, "invalid signature")
- if _, err = ValidatePayload(req, nil); err == nil {
- t.Error("ValidatePayload = nil, want err")
- }
-}
-
-func TestValidatePayload_InvalidContentType(t *testing.T) {
- req, err := http.NewRequest("POST", "http://localhost/event", nil)
- if err != nil {
- t.Fatalf("NewRequest: %v", err)
- }
- req.Header.Set("Content-Type", "invalid content type")
- if _, err = ValidatePayload(req, nil); err == nil {
- t.Error("ValidatePayload = nil, want err")
- }
-}
-
-func TestParseWebHook(t *testing.T) {
- tests := []struct {
- payload interface{}
- messageType string
- }{
- {
- payload: &CommitCommentEvent{},
- messageType: "commit_comment",
- },
- {
- payload: &CreateEvent{},
- messageType: "create",
- },
- {
- payload: &DeleteEvent{},
- messageType: "delete",
- },
- {
- payload: &DeploymentEvent{},
- messageType: "deployment",
- },
-
- {
- payload: &DeploymentStatusEvent{},
- messageType: "deployment_status",
- },
- {
- payload: &ForkEvent{},
- messageType: "fork",
- },
- {
- payload: &GollumEvent{},
- messageType: "gollum",
- },
- {
- payload: &InstallationEvent{},
- messageType: "installation",
- },
- {
- payload: &InstallationRepositoriesEvent{},
- messageType: "installation_repositories",
- },
- {
- payload: &IssueCommentEvent{},
- messageType: "issue_comment",
- },
- {
- payload: &IssuesEvent{},
- messageType: "issues",
- },
- {
- payload: &LabelEvent{},
- messageType: "label",
- },
- {
- payload: &MarketplacePurchaseEvent{},
- messageType: "marketplace_purchase",
- },
- {
- payload: &MemberEvent{},
- messageType: "member",
- },
- {
- payload: &MembershipEvent{},
- messageType: "membership",
- },
- {
- payload: &MilestoneEvent{},
- messageType: "milestone",
- },
- {
- payload: &OrganizationEvent{},
- messageType: "organization",
- },
- {
- payload: &OrgBlockEvent{},
- messageType: "org_block",
- },
- {
- payload: &PageBuildEvent{},
- messageType: "page_build",
- },
- {
- payload: &PingEvent{},
- messageType: "ping",
- },
- {
- payload: &ProjectEvent{},
- messageType: "project",
- },
- {
- payload: &ProjectCardEvent{},
- messageType: "project_card",
- },
- {
- payload: &ProjectColumnEvent{},
- messageType: "project_column",
- },
- {
- payload: &PublicEvent{},
- messageType: "public",
- },
- {
- payload: &PullRequestEvent{},
- messageType: "pull_request",
- },
- {
- payload: &PullRequestReviewEvent{},
- messageType: "pull_request_review",
- },
- {
- payload: &PullRequestReviewCommentEvent{},
- messageType: "pull_request_review_comment",
- },
- {
- payload: &PushEvent{},
- messageType: "push",
- },
- {
- payload: &ReleaseEvent{},
- messageType: "release",
- },
- {
- payload: &RepositoryEvent{},
- messageType: "repository",
- },
- {
- payload: &StatusEvent{},
- messageType: "status",
- },
- {
- payload: &TeamEvent{},
- messageType: "team",
- },
- {
- payload: &TeamAddEvent{},
- messageType: "team_add",
- },
- {
- payload: &WatchEvent{},
- messageType: "watch",
- },
- }
-
- for _, test := range tests {
- p, err := json.Marshal(test.payload)
- if err != nil {
- t.Fatalf("Marshal(%#v): %v", test.payload, err)
- }
- got, err := ParseWebHook(test.messageType, p)
- if err != nil {
- t.Fatalf("ParseWebHook: %v", err)
- }
- if want := test.payload; !reflect.DeepEqual(got, want) {
- t.Errorf("ParseWebHook(%#v, %#v) = %#v, want %#v", test.messageType, p, got, want)
- }
- }
-}
-
-func TestDeliveryID(t *testing.T) {
- id := "8970a780-244e-11e7-91ca-da3aabcb9793"
- req, err := http.NewRequest("POST", "http://localhost", nil)
- if err != nil {
- t.Fatalf("DeliveryID: %v", err)
- }
- req.Header.Set("X-Github-Delivery", id)
-
- got := DeliveryID(req)
- if got != id {
- t.Errorf("DeliveryID(%#v) = %q, want %q", req, got, id)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/migrations_source_import_test.go b/vendor/github.com/google/go-github/github/migrations_source_import_test.go
deleted file mode 100644
index e9e9be06..00000000
--- a/vendor/github.com/google/go-github/github/migrations_source_import_test.go
+++ /dev/null
@@ -1,226 +0,0 @@
-// 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestMigrationService_StartImport(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Import{
- VCS: String("git"),
- VCSURL: String("url"),
- VCSUsername: String("u"),
- VCSPassword: String("p"),
- }
-
- mux.HandleFunc("/repos/o/r/import", func(w http.ResponseWriter, r *http.Request) {
- v := new(Import)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PUT")
- testHeader(t, r, "Accept", mediaTypeImportPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- w.WriteHeader(http.StatusCreated)
- fmt.Fprint(w, `{"status":"importing"}`)
- })
-
- got, _, err := client.Migrations.StartImport(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("StartImport returned error: %v", err)
- }
- want := &Import{Status: String("importing")}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("StartImport = %+v, want %+v", got, want)
- }
-}
-
-func TestMigrationService_ImportProgress(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/import", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeImportPreview)
- fmt.Fprint(w, `{"status":"complete"}`)
- })
-
- got, _, err := client.Migrations.ImportProgress(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("ImportProgress returned error: %v", err)
- }
- want := &Import{Status: String("complete")}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("ImportProgress = %+v, want %+v", got, want)
- }
-}
-
-func TestMigrationService_UpdateImport(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Import{
- VCS: String("git"),
- VCSURL: String("url"),
- VCSUsername: String("u"),
- VCSPassword: String("p"),
- }
-
- mux.HandleFunc("/repos/o/r/import", func(w http.ResponseWriter, r *http.Request) {
- v := new(Import)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- testHeader(t, r, "Accept", mediaTypeImportPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- w.WriteHeader(http.StatusCreated)
- fmt.Fprint(w, `{"status":"importing"}`)
- })
-
- got, _, err := client.Migrations.UpdateImport(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("UpdateImport returned error: %v", err)
- }
- want := &Import{Status: String("importing")}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("UpdateImport = %+v, want %+v", got, want)
- }
-}
-
-func TestMigrationService_CommitAuthors(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/import/authors", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeImportPreview)
- fmt.Fprint(w, `[{"id":1,"name":"a"},{"id":2,"name":"b"}]`)
- })
-
- got, _, err := client.Migrations.CommitAuthors(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("CommitAuthors returned error: %v", err)
- }
- want := []*SourceImportAuthor{
- {ID: Int64(1), Name: String("a")},
- {ID: Int64(2), Name: String("b")},
- }
- if !reflect.DeepEqual(got, want) {
- t.Errorf("CommitAuthors = %+v, want %+v", got, want)
- }
-}
-
-func TestMigrationService_MapCommitAuthor(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &SourceImportAuthor{Name: String("n"), Email: String("e")}
-
- mux.HandleFunc("/repos/o/r/import/authors/1", func(w http.ResponseWriter, r *http.Request) {
- v := new(SourceImportAuthor)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- testHeader(t, r, "Accept", mediaTypeImportPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id": 1}`)
- })
-
- got, _, err := client.Migrations.MapCommitAuthor(context.Background(), "o", "r", 1, input)
- if err != nil {
- t.Errorf("MapCommitAuthor returned error: %v", err)
- }
- want := &SourceImportAuthor{ID: Int64(1)}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("MapCommitAuthor = %+v, want %+v", got, want)
- }
-}
-
-func TestMigrationService_SetLFSPreference(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Import{UseLFS: String("opt_in")}
-
- mux.HandleFunc("/repos/o/r/import/lfs", func(w http.ResponseWriter, r *http.Request) {
- v := new(Import)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- testHeader(t, r, "Accept", mediaTypeImportPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- w.WriteHeader(http.StatusCreated)
- fmt.Fprint(w, `{"status":"importing"}`)
- })
-
- got, _, err := client.Migrations.SetLFSPreference(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("SetLFSPreference returned error: %v", err)
- }
- want := &Import{Status: String("importing")}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("SetLFSPreference = %+v, want %+v", got, want)
- }
-}
-
-func TestMigrationService_LargeFiles(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/import/large_files", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeImportPreview)
- fmt.Fprint(w, `[{"oid":"a"},{"oid":"b"}]`)
- })
-
- got, _, err := client.Migrations.LargeFiles(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("LargeFiles returned error: %v", err)
- }
- want := []*LargeFile{
- {OID: String("a")},
- {OID: String("b")},
- }
- if !reflect.DeepEqual(got, want) {
- t.Errorf("LargeFiles = %+v, want %+v", got, want)
- }
-}
-
-func TestMigrationService_CancelImport(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/import", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeImportPreview)
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Migrations.CancelImport(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("CancelImport returned error: %v", err)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/migrations_test.go b/vendor/github.com/google/go-github/github/migrations_test.go
deleted file mode 100644
index 687f89a3..00000000
--- a/vendor/github.com/google/go-github/github/migrations_test.go
+++ /dev/null
@@ -1,178 +0,0 @@
-// 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "strings"
- "testing"
-)
-
-func TestMigrationService_StartMigration(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/migrations", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeMigrationsPreview)
-
- w.WriteHeader(http.StatusCreated)
- w.Write(migrationJSON)
- })
-
- opt := &MigrationOptions{
- LockRepositories: true,
- ExcludeAttachments: false,
- }
- got, _, err := client.Migrations.StartMigration(context.Background(), "o", []string{"r"}, opt)
- if err != nil {
- t.Errorf("StartMigration returned error: %v", err)
- }
- if want := wantMigration; !reflect.DeepEqual(got, want) {
- t.Errorf("StartMigration = %+v, want %+v", got, want)
- }
-}
-
-func TestMigrationService_ListMigrations(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/migrations", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeMigrationsPreview)
-
- w.WriteHeader(http.StatusOK)
- w.Write([]byte(fmt.Sprintf("[%s]", migrationJSON)))
- })
-
- got, _, err := client.Migrations.ListMigrations(context.Background(), "o")
- if err != nil {
- t.Errorf("ListMigrations returned error: %v", err)
- }
- if want := []*Migration{wantMigration}; !reflect.DeepEqual(got, want) {
- t.Errorf("ListMigrations = %+v, want %+v", got, want)
- }
-}
-
-func TestMigrationService_MigrationStatus(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/migrations/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeMigrationsPreview)
-
- w.WriteHeader(http.StatusOK)
- w.Write(migrationJSON)
- })
-
- got, _, err := client.Migrations.MigrationStatus(context.Background(), "o", 1)
- if err != nil {
- t.Errorf("MigrationStatus returned error: %v", err)
- }
- if want := wantMigration; !reflect.DeepEqual(got, want) {
- t.Errorf("MigrationStatus = %+v, want %+v", got, want)
- }
-}
-
-func TestMigrationService_MigrationArchiveURL(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/migrations/1/archive", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeMigrationsPreview)
-
- http.Redirect(w, r, "/yo", http.StatusFound)
- })
- mux.HandleFunc("/yo", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
-
- w.WriteHeader(http.StatusOK)
- w.Write([]byte("0123456789abcdef"))
- })
-
- got, err := client.Migrations.MigrationArchiveURL(context.Background(), "o", 1)
- if err != nil {
- t.Errorf("MigrationStatus returned error: %v", err)
- }
- if want := "/yo"; !strings.HasSuffix(got, want) {
- t.Errorf("MigrationArchiveURL = %+v, want %+v", got, want)
- }
-}
-
-func TestMigrationService_DeleteMigration(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/migrations/1/archive", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeMigrationsPreview)
-
- w.WriteHeader(http.StatusNoContent)
- })
-
- if _, err := client.Migrations.DeleteMigration(context.Background(), "o", 1); err != nil {
- t.Errorf("DeleteMigration returned error: %v", err)
- }
-}
-
-func TestMigrationService_UnlockRepo(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/migrations/1/repos/r/lock", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeMigrationsPreview)
-
- w.WriteHeader(http.StatusNoContent)
- })
-
- if _, err := client.Migrations.UnlockRepo(context.Background(), "o", 1, "r"); err != nil {
- t.Errorf("UnlockRepo returned error: %v", err)
- }
-}
-
-var migrationJSON = []byte(`{
- "id": 79,
- "guid": "0b989ba4-242f-11e5-81e1-c7b6966d2516",
- "state": "pending",
- "lock_repositories": true,
- "exclude_attachments": false,
- "url": "https://api.github.com/orgs/octo-org/migrations/79",
- "created_at": "2015-07-06T15:33:38-07:00",
- "updated_at": "2015-07-06T15:33:38-07:00",
- "repositories": [
- {
- "id": 1296269,
- "name": "Hello-World",
- "full_name": "octocat/Hello-World",
- "description": "This your first repo!"
- }
- ]
-}`)
-
-var wantMigration = &Migration{
- ID: Int64(79),
- GUID: String("0b989ba4-242f-11e5-81e1-c7b6966d2516"),
- State: String("pending"),
- LockRepositories: Bool(true),
- ExcludeAttachments: Bool(false),
- URL: String("https://api.github.com/orgs/octo-org/migrations/79"),
- CreatedAt: String("2015-07-06T15:33:38-07:00"),
- UpdatedAt: String("2015-07-06T15:33:38-07:00"),
- Repositories: []*Repository{
- {
- ID: Int64(1296269),
- Name: String("Hello-World"),
- FullName: String("octocat/Hello-World"),
- Description: String("This your first repo!"),
- },
- },
-}
diff --git a/vendor/github.com/google/go-github/github/misc_test.go b/vendor/github.com/google/go-github/github/misc_test.go
deleted file mode 100644
index 924e7b46..00000000
--- a/vendor/github.com/google/go-github/github/misc_test.go
+++ /dev/null
@@ -1,232 +0,0 @@
-// Copyright 2014 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestMarkdown(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &markdownRequest{
- Text: String("# text #"),
- Mode: String("gfm"),
- Context: String("google/go-github"),
- }
- mux.HandleFunc("/markdown", func(w http.ResponseWriter, r *http.Request) {
- v := new(markdownRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
- fmt.Fprint(w, `text
`)
- })
-
- md, _, err := client.Markdown(context.Background(), "# text #", &MarkdownOptions{
- Mode: "gfm",
- Context: "google/go-github",
- })
- if err != nil {
- t.Errorf("Markdown returned error: %v", err)
- }
-
- if want := "text
"; want != md {
- t.Errorf("Markdown returned %+v, want %+v", md, want)
- }
-}
-
-func TestListEmojis(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/emojis", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"+1": "+1.png"}`)
- })
-
- emoji, _, err := client.ListEmojis(context.Background())
- if err != nil {
- t.Errorf("ListEmojis returned error: %v", err)
- }
-
- want := map[string]string{"+1": "+1.png"}
- if !reflect.DeepEqual(want, emoji) {
- t.Errorf("ListEmojis returned %+v, want %+v", emoji, want)
- }
-}
-
-func TestListCodesOfConduct(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/codes_of_conduct", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeCodesOfConductPreview)
- fmt.Fprint(w, `[{
- "key": "key",
- "name": "name",
- "url": "url"}
- ]`)
- })
-
- cs, _, err := client.ListCodesOfConduct(context.Background())
- if err != nil {
- t.Errorf("ListCodesOfConduct returned error: %v", err)
- }
-
- want := []*CodeOfConduct{
- {
- Key: String("key"),
- Name: String("name"),
- URL: String("url"),
- }}
- if !reflect.DeepEqual(want, cs) {
- t.Errorf("ListCodesOfConduct returned %+v, want %+v", cs, want)
- }
-}
-
-func TestGetCodeOfConduct(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/codes_of_conduct/k", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeCodesOfConductPreview)
- fmt.Fprint(w, `{
- "key": "key",
- "name": "name",
- "url": "url",
- "body": "body"}`,
- )
- })
-
- coc, _, err := client.GetCodeOfConduct(context.Background(), "k")
- if err != nil {
- t.Errorf("ListCodesOfConduct returned error: %v", err)
- }
-
- want := &CodeOfConduct{
- Key: String("key"),
- Name: String("name"),
- URL: String("url"),
- Body: String("body"),
- }
- if !reflect.DeepEqual(want, coc) {
- t.Errorf("GetCodeOfConductByKey returned %+v, want %+v", coc, want)
- }
-}
-
-func TestAPIMeta(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/meta", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"hooks":["h"], "git":["g"], "pages":["p"], "verifiable_password_authentication": true}`)
- })
-
- meta, _, err := client.APIMeta(context.Background())
- if err != nil {
- t.Errorf("APIMeta returned error: %v", err)
- }
-
- want := &APIMeta{
- Hooks: []string{"h"},
- Git: []string{"g"},
- Pages: []string{"p"},
- VerifiablePasswordAuthentication: Bool(true),
- }
- if !reflect.DeepEqual(want, meta) {
- t.Errorf("APIMeta returned %+v, want %+v", meta, want)
- }
-}
-
-func TestOctocat(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := "input"
- output := "sample text"
-
- mux.HandleFunc("/octocat", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"s": input})
- w.Header().Set("Content-Type", "application/octocat-stream")
- fmt.Fprint(w, output)
- })
-
- got, _, err := client.Octocat(context.Background(), input)
- if err != nil {
- t.Errorf("Octocat returned error: %v", err)
- }
-
- if want := output; got != want {
- t.Errorf("Octocat returned %+v, want %+v", got, want)
- }
-}
-
-func TestZen(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- output := "sample text"
-
- mux.HandleFunc("/zen", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.Header().Set("Content-Type", "text/plain;charset=utf-8")
- fmt.Fprint(w, output)
- })
-
- got, _, err := client.Zen(context.Background())
- if err != nil {
- t.Errorf("Zen returned error: %v", err)
- }
-
- if want := output; got != want {
- t.Errorf("Zen returned %+v, want %+v", got, want)
- }
-}
-
-func TestListServiceHooks(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/hooks", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `[{
- "name":"n",
- "events":["e"],
- "supported_events":["s"],
- "schema":[
- ["a", "b"]
- ]
- }]`)
- })
-
- hooks, _, err := client.ListServiceHooks(context.Background())
- if err != nil {
- t.Errorf("ListServiceHooks returned error: %v", err)
- }
-
- want := []*ServiceHook{{
- Name: String("n"),
- Events: []string{"e"},
- SupportedEvents: []string{"s"},
- Schema: [][]string{{"a", "b"}},
- }}
- if !reflect.DeepEqual(hooks, want) {
- t.Errorf("ListServiceHooks returned %+v, want %+v", hooks, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/orgs_hooks_test.go b/vendor/github.com/google/go-github/github/orgs_hooks_test.go
deleted file mode 100644
index 1adfef2b..00000000
--- a/vendor/github.com/google/go-github/github/orgs_hooks_test.go
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright 2015 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestOrganizationsService_ListHooks(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/hooks", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}, {"id":2}]`)
- })
-
- opt := &ListOptions{Page: 2}
-
- hooks, _, err := client.Organizations.ListHooks(context.Background(), "o", opt)
- if err != nil {
- t.Errorf("Organizations.ListHooks returned error: %v", err)
- }
-
- want := []*Hook{{ID: Int64(1)}, {ID: Int64(2)}}
- if !reflect.DeepEqual(hooks, want) {
- t.Errorf("Organizations.ListHooks returned %+v, want %+v", hooks, want)
- }
-}
-
-func TestOrganizationsService_ListHooks_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Organizations.ListHooks(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_GetHook(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/hooks/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id":1}`)
- })
-
- hook, _, err := client.Organizations.GetHook(context.Background(), "o", 1)
- if err != nil {
- t.Errorf("Organizations.GetHook returned error: %v", err)
- }
-
- want := &Hook{ID: Int64(1)}
- if !reflect.DeepEqual(hook, want) {
- t.Errorf("Organizations.GetHook returned %+v, want %+v", hook, want)
- }
-}
-
-func TestOrganizationsService_GetHook_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Organizations.GetHook(context.Background(), "%", 1)
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_EditHook(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Hook{Name: String("t")}
-
- mux.HandleFunc("/orgs/o/hooks/1", func(w http.ResponseWriter, r *http.Request) {
- v := new(Hook)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- hook, _, err := client.Organizations.EditHook(context.Background(), "o", 1, input)
- if err != nil {
- t.Errorf("Organizations.EditHook returned error: %v", err)
- }
-
- want := &Hook{ID: Int64(1)}
- if !reflect.DeepEqual(hook, want) {
- t.Errorf("Organizations.EditHook returned %+v, want %+v", hook, want)
- }
-}
-
-func TestOrganizationsService_EditHook_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Organizations.EditHook(context.Background(), "%", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_PingHook(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/hooks/1/pings", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- })
-
- _, err := client.Organizations.PingHook(context.Background(), "o", 1)
- if err != nil {
- t.Errorf("Organizations.PingHook returned error: %v", err)
- }
-}
-
-func TestOrganizationsService_DeleteHook(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/hooks/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Organizations.DeleteHook(context.Background(), "o", 1)
- if err != nil {
- t.Errorf("Organizations.DeleteHook returned error: %v", err)
- }
-}
-
-func TestOrganizationsService_DeleteHook_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Organizations.DeleteHook(context.Background(), "%", 1)
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/orgs_members_test.go b/vendor/github.com/google/go-github/github/orgs_members_test.go
deleted file mode 100644
index 7b5cba85..00000000
--- a/vendor/github.com/google/go-github/github/orgs_members_test.go
+++ /dev/null
@@ -1,446 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
- "time"
-)
-
-func TestOrganizationsService_ListMembers(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/members", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "filter": "2fa_disabled",
- "role": "admin",
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListMembersOptions{
- PublicOnly: false,
- Filter: "2fa_disabled",
- Role: "admin",
- ListOptions: ListOptions{Page: 2},
- }
- members, _, err := client.Organizations.ListMembers(context.Background(), "o", opt)
- if err != nil {
- t.Errorf("Organizations.ListMembers returned error: %v", err)
- }
-
- want := []*User{{ID: Int64(1)}}
- if !reflect.DeepEqual(members, want) {
- t.Errorf("Organizations.ListMembers returned %+v, want %+v", members, want)
- }
-}
-
-func TestOrganizationsService_ListMembers_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Organizations.ListMembers(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_ListMembers_public(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/public_members", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListMembersOptions{PublicOnly: true}
- members, _, err := client.Organizations.ListMembers(context.Background(), "o", opt)
- if err != nil {
- t.Errorf("Organizations.ListMembers returned error: %v", err)
- }
-
- want := []*User{{ID: Int64(1)}}
- if !reflect.DeepEqual(members, want) {
- t.Errorf("Organizations.ListMembers returned %+v, want %+v", members, want)
- }
-}
-
-func TestOrganizationsService_IsMember(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNoContent)
- })
-
- member, _, err := client.Organizations.IsMember(context.Background(), "o", "u")
- if err != nil {
- t.Errorf("Organizations.IsMember returned error: %v", err)
- }
- if want := true; member != want {
- t.Errorf("Organizations.IsMember returned %+v, want %+v", member, want)
- }
-}
-
-// ensure that a 404 response is interpreted as "false" and not an error
-func TestOrganizationsService_IsMember_notMember(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNotFound)
- })
-
- member, _, err := client.Organizations.IsMember(context.Background(), "o", "u")
- if err != nil {
- t.Errorf("Organizations.IsMember returned error: %+v", err)
- }
- if want := false; member != want {
- t.Errorf("Organizations.IsMember returned %+v, want %+v", member, want)
- }
-}
-
-// ensure that a 400 response is interpreted as an actual error, and not simply
-// as "false" like the above case of a 404
-func TestOrganizationsService_IsMember_error(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- http.Error(w, "BadRequest", http.StatusBadRequest)
- })
-
- member, _, err := client.Organizations.IsMember(context.Background(), "o", "u")
- if err == nil {
- t.Errorf("Expected HTTP 400 response")
- }
- if want := false; member != want {
- t.Errorf("Organizations.IsMember returned %+v, want %+v", member, want)
- }
-}
-
-func TestOrganizationsService_IsMember_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Organizations.IsMember(context.Background(), "%", "u")
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_IsPublicMember(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNoContent)
- })
-
- member, _, err := client.Organizations.IsPublicMember(context.Background(), "o", "u")
- if err != nil {
- t.Errorf("Organizations.IsPublicMember returned error: %v", err)
- }
- if want := true; member != want {
- t.Errorf("Organizations.IsPublicMember returned %+v, want %+v", member, want)
- }
-}
-
-// ensure that a 404 response is interpreted as "false" and not an error
-func TestOrganizationsService_IsPublicMember_notMember(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNotFound)
- })
-
- member, _, err := client.Organizations.IsPublicMember(context.Background(), "o", "u")
- if err != nil {
- t.Errorf("Organizations.IsPublicMember returned error: %v", err)
- }
- if want := false; member != want {
- t.Errorf("Organizations.IsPublicMember returned %+v, want %+v", member, want)
- }
-}
-
-// ensure that a 400 response is interpreted as an actual error, and not simply
-// as "false" like the above case of a 404
-func TestOrganizationsService_IsPublicMember_error(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- http.Error(w, "BadRequest", http.StatusBadRequest)
- })
-
- member, _, err := client.Organizations.IsPublicMember(context.Background(), "o", "u")
- if err == nil {
- t.Errorf("Expected HTTP 400 response")
- }
- if want := false; member != want {
- t.Errorf("Organizations.IsPublicMember returned %+v, want %+v", member, want)
- }
-}
-
-func TestOrganizationsService_IsPublicMember_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Organizations.IsPublicMember(context.Background(), "%", "u")
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_RemoveMember(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Organizations.RemoveMember(context.Background(), "o", "u")
- if err != nil {
- t.Errorf("Organizations.RemoveMember returned error: %v", err)
- }
-}
-
-func TestOrganizationsService_RemoveMember_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Organizations.RemoveMember(context.Background(), "%", "u")
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_ListOrgMemberships(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/memberships/orgs", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "state": "active",
- "page": "2",
- })
- fmt.Fprint(w, `[{"url":"u"}]`)
- })
-
- opt := &ListOrgMembershipsOptions{
- State: "active",
- ListOptions: ListOptions{Page: 2},
- }
- memberships, _, err := client.Organizations.ListOrgMemberships(context.Background(), opt)
- if err != nil {
- t.Errorf("Organizations.ListOrgMemberships returned error: %v", err)
- }
-
- want := []*Membership{{URL: String("u")}}
- if !reflect.DeepEqual(memberships, want) {
- t.Errorf("Organizations.ListOrgMemberships returned %+v, want %+v", memberships, want)
- }
-}
-
-func TestOrganizationsService_GetOrgMembership_AuthenticatedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/memberships/orgs/o", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"url":"u"}`)
- })
-
- membership, _, err := client.Organizations.GetOrgMembership(context.Background(), "", "o")
- if err != nil {
- t.Errorf("Organizations.GetOrgMembership returned error: %v", err)
- }
-
- want := &Membership{URL: String("u")}
- if !reflect.DeepEqual(membership, want) {
- t.Errorf("Organizations.GetOrgMembership returned %+v, want %+v", membership, want)
- }
-}
-
-func TestOrganizationsService_GetOrgMembership_SpecifiedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/memberships/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"url":"u"}`)
- })
-
- membership, _, err := client.Organizations.GetOrgMembership(context.Background(), "u", "o")
- if err != nil {
- t.Errorf("Organizations.GetOrgMembership returned error: %v", err)
- }
-
- want := &Membership{URL: String("u")}
- if !reflect.DeepEqual(membership, want) {
- t.Errorf("Organizations.GetOrgMembership returned %+v, want %+v", membership, want)
- }
-}
-
-func TestOrganizationsService_EditOrgMembership_AuthenticatedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Membership{State: String("active")}
-
- mux.HandleFunc("/user/memberships/orgs/o", func(w http.ResponseWriter, r *http.Request) {
- v := new(Membership)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"url":"u"}`)
- })
-
- membership, _, err := client.Organizations.EditOrgMembership(context.Background(), "", "o", input)
- if err != nil {
- t.Errorf("Organizations.EditOrgMembership returned error: %v", err)
- }
-
- want := &Membership{URL: String("u")}
- if !reflect.DeepEqual(membership, want) {
- t.Errorf("Organizations.EditOrgMembership returned %+v, want %+v", membership, want)
- }
-}
-
-func TestOrganizationsService_EditOrgMembership_SpecifiedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Membership{State: String("active")}
-
- mux.HandleFunc("/orgs/o/memberships/u", func(w http.ResponseWriter, r *http.Request) {
- v := new(Membership)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PUT")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"url":"u"}`)
- })
-
- membership, _, err := client.Organizations.EditOrgMembership(context.Background(), "u", "o", input)
- if err != nil {
- t.Errorf("Organizations.EditOrgMembership returned error: %v", err)
- }
-
- want := &Membership{URL: String("u")}
- if !reflect.DeepEqual(membership, want) {
- t.Errorf("Organizations.EditOrgMembership returned %+v, want %+v", membership, want)
- }
-}
-
-func TestOrganizationsService_RemoveOrgMembership(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/memberships/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Organizations.RemoveOrgMembership(context.Background(), "u", "o")
- if err != nil {
- t.Errorf("Organizations.RemoveOrgMembership returned error: %v", err)
- }
-}
-
-func TestOrganizationsService_ListPendingOrgInvitations(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/invitations", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "1"})
- fmt.Fprint(w, `[
- {
- "id": 1,
- "login": "monalisa",
- "email": "octocat@github.com",
- "role": "direct_member",
- "created_at": "2017-01-21T00:00:00Z",
- "inviter": {
- "login": "other_user",
- "id": 1,
- "avatar_url": "https://github.com/images/error/other_user_happy.gif",
- "gravatar_id": "",
- "url": "https://api.github.com/users/other_user",
- "html_url": "https://github.com/other_user",
- "followers_url": "https://api.github.com/users/other_user/followers",
- "following_url": "https://api.github.com/users/other_user/following/other_user",
- "gists_url": "https://api.github.com/users/other_user/gists/gist_id",
- "starred_url": "https://api.github.com/users/other_user/starred/owner/repo",
- "subscriptions_url": "https://api.github.com/users/other_user/subscriptions",
- "organizations_url": "https://api.github.com/users/other_user/orgs",
- "repos_url": "https://api.github.com/users/other_user/repos",
- "events_url": "https://api.github.com/users/other_user/events/privacy",
- "received_events_url": "https://api.github.com/users/other_user/received_events/privacy",
- "type": "User",
- "site_admin": false
- }
- }
- ]`)
- })
-
- opt := &ListOptions{Page: 1}
- invitations, _, err := client.Organizations.ListPendingOrgInvitations(context.Background(), "o", opt)
- if err != nil {
- t.Errorf("Organizations.ListPendingOrgInvitations returned error: %v", err)
- }
-
- createdAt := time.Date(2017, 01, 21, 0, 0, 0, 0, time.UTC)
- want := []*Invitation{
- {
- ID: Int64(1),
- Login: String("monalisa"),
- Email: String("octocat@github.com"),
- Role: String("direct_member"),
- CreatedAt: &createdAt,
- Inviter: &User{
- Login: String("other_user"),
- ID: Int64(1),
- AvatarURL: String("https://github.com/images/error/other_user_happy.gif"),
- GravatarID: String(""),
- URL: String("https://api.github.com/users/other_user"),
- HTMLURL: String("https://github.com/other_user"),
- FollowersURL: String("https://api.github.com/users/other_user/followers"),
- FollowingURL: String("https://api.github.com/users/other_user/following/other_user"),
- GistsURL: String("https://api.github.com/users/other_user/gists/gist_id"),
- StarredURL: String("https://api.github.com/users/other_user/starred/owner/repo"),
- SubscriptionsURL: String("https://api.github.com/users/other_user/subscriptions"),
- OrganizationsURL: String("https://api.github.com/users/other_user/orgs"),
- ReposURL: String("https://api.github.com/users/other_user/repos"),
- EventsURL: String("https://api.github.com/users/other_user/events/privacy"),
- ReceivedEventsURL: String("https://api.github.com/users/other_user/received_events/privacy"),
- Type: String("User"),
- SiteAdmin: Bool(false),
- },
- }}
-
- if !reflect.DeepEqual(invitations, want) {
- t.Errorf("Organizations.ListPendingOrgInvitations returned %+v, want %+v", invitations, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/orgs_outside_collaborators_test.go b/vendor/github.com/google/go-github/github/orgs_outside_collaborators_test.go
deleted file mode 100644
index 8b72feb2..00000000
--- a/vendor/github.com/google/go-github/github/orgs_outside_collaborators_test.go
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright 2017 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestOrganizationsService_ListOutsideCollaborators(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/outside_collaborators", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "filter": "2fa_disabled",
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOutsideCollaboratorsOptions{
- Filter: "2fa_disabled",
- ListOptions: ListOptions{Page: 2},
- }
- members, _, err := client.Organizations.ListOutsideCollaborators(context.Background(), "o", opt)
- if err != nil {
- t.Errorf("Organizations.ListOutsideCollaborators returned error: %v", err)
- }
-
- want := []*User{{ID: Int64(1)}}
- if !reflect.DeepEqual(members, want) {
- t.Errorf("Organizations.ListOutsideCollaborators returned %+v, want %+v", members, want)
- }
-}
-
-func TestOrganizationsService_ListOutsideCollaborators_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Organizations.ListOutsideCollaborators(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_RemoveOutsideCollaborator(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- handler := func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- }
- mux.HandleFunc("/orgs/o/outside_collaborators/u", handler)
-
- _, err := client.Organizations.RemoveOutsideCollaborator(context.Background(), "o", "u")
- if err != nil {
- t.Errorf("Organizations.RemoveOutsideCollaborator returned error: %v", err)
- }
-}
-
-func TestOrganizationsService_RemoveOutsideCollaborator_NonMember(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- handler := func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- w.WriteHeader(http.StatusNotFound)
- }
- mux.HandleFunc("/orgs/o/outside_collaborators/u", handler)
-
- _, err := client.Organizations.RemoveOutsideCollaborator(context.Background(), "o", "u")
- if err, ok := err.(*ErrorResponse); !ok {
- t.Errorf("Organizations.RemoveOutsideCollaborator did not return an error")
- } else if err.Response.StatusCode != http.StatusNotFound {
- t.Errorf("Organizations.RemoveOutsideCollaborator did not return 404 status code")
- }
-}
-
-func TestOrganizationsService_RemoveOutsideCollaborator_Member(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- handler := func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- w.WriteHeader(http.StatusUnprocessableEntity)
- }
- mux.HandleFunc("/orgs/o/outside_collaborators/u", handler)
-
- _, err := client.Organizations.RemoveOutsideCollaborator(context.Background(), "o", "u")
- if err, ok := err.(*ErrorResponse); !ok {
- t.Errorf("Organizations.RemoveOutsideCollaborator did not return an error")
- } else if err.Response.StatusCode != http.StatusUnprocessableEntity {
- t.Errorf("Organizations.RemoveOutsideCollaborator did not return 422 status code")
- }
-}
-
-func TestOrganizationsService_ConvertMemberToOutsideCollaborator(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- handler := func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- }
- mux.HandleFunc("/orgs/o/outside_collaborators/u", handler)
-
- _, err := client.Organizations.ConvertMemberToOutsideCollaborator(context.Background(), "o", "u")
- if err != nil {
- t.Errorf("Organizations.ConvertMemberToOutsideCollaborator returned error: %v", err)
- }
-}
-
-func TestOrganizationsService_ConvertMemberToOutsideCollaborator_NonMemberOrLastOwner(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- handler := func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- w.WriteHeader(http.StatusForbidden)
- }
- mux.HandleFunc("/orgs/o/outside_collaborators/u", handler)
-
- _, err := client.Organizations.ConvertMemberToOutsideCollaborator(context.Background(), "o", "u")
- if err, ok := err.(*ErrorResponse); !ok {
- t.Errorf("Organizations.ConvertMemberToOutsideCollaborator did not return an error")
- } else if err.Response.StatusCode != http.StatusForbidden {
- t.Errorf("Organizations.ConvertMemberToOutsideCollaborator did not return 403 status code")
- }
-}
diff --git a/vendor/github.com/google/go-github/github/orgs_projects_test.go b/vendor/github.com/google/go-github/github/orgs_projects_test.go
deleted file mode 100644
index 97a7002f..00000000
--- a/vendor/github.com/google/go-github/github/orgs_projects_test.go
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2017 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestOrganizationsService_ListProjects(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/projects", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
- testFormValues(t, r, values{"state": "open", "page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ProjectListOptions{State: "open", ListOptions: ListOptions{Page: 2}}
- projects, _, err := client.Organizations.ListProjects(context.Background(), "o", opt)
- if err != nil {
- t.Errorf("Organizations.ListProjects returned error: %v", err)
- }
-
- want := []*Project{{ID: Int64(1)}}
- if !reflect.DeepEqual(projects, want) {
- t.Errorf("Organizations.ListProjects returned %+v, want %+v", projects, want)
- }
-}
-
-func TestOrganizationsService_CreateProject(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &ProjectOptions{Name: "Project Name", Body: "Project body."}
-
- mux.HandleFunc("/orgs/o/projects", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
-
- v := &ProjectOptions{}
- json.NewDecoder(r.Body).Decode(v)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- project, _, err := client.Organizations.CreateProject(context.Background(), "o", input)
- if err != nil {
- t.Errorf("Organizations.CreateProject returned error: %v", err)
- }
-
- want := &Project{ID: Int64(1)}
- if !reflect.DeepEqual(project, want) {
- t.Errorf("Organizations.CreateProject returned %+v, want %+v", project, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/orgs_teams_test.go b/vendor/github.com/google/go-github/github/orgs_teams_test.go
deleted file mode 100644
index ead8024e..00000000
--- a/vendor/github.com/google/go-github/github/orgs_teams_test.go
+++ /dev/null
@@ -1,663 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "strings"
- "testing"
- "time"
-)
-
-func TestOrganizationsService_ListTeams(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/teams", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeNestedTeamsPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 2}
- teams, _, err := client.Organizations.ListTeams(context.Background(), "o", opt)
- if err != nil {
- t.Errorf("Organizations.ListTeams returned error: %v", err)
- }
-
- want := []*Team{{ID: Int64(1)}}
- if !reflect.DeepEqual(teams, want) {
- t.Errorf("Organizations.ListTeams returned %+v, want %+v", teams, want)
- }
-}
-
-func TestOrganizationsService_ListTeams_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Organizations.ListTeams(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_GetTeam(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeNestedTeamsPreview)
- fmt.Fprint(w, `{"id":1, "name":"n", "description": "d", "url":"u", "slug": "s", "permission":"p", "ldap_dn":"cn=n,ou=groups,dc=example,dc=com", "parent":null}`)
- })
-
- team, _, err := client.Organizations.GetTeam(context.Background(), 1)
- if err != nil {
- t.Errorf("Organizations.GetTeam returned error: %v", err)
- }
-
- want := &Team{ID: Int64(1), Name: String("n"), Description: String("d"), URL: String("u"), Slug: String("s"), Permission: String("p"), LDAPDN: String("cn=n,ou=groups,dc=example,dc=com")}
- if !reflect.DeepEqual(team, want) {
- t.Errorf("Organizations.GetTeam returned %+v, want %+v", team, want)
- }
-}
-
-func TestOrganizationService_GetTeam_nestedTeams(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeNestedTeamsPreview)
- fmt.Fprint(w, `{"id":1, "name":"n", "description": "d", "url":"u", "slug": "s", "permission":"p",
- "parent": {"id":2, "name":"n", "description": "d", "parent": null}}`)
- })
-
- team, _, err := client.Organizations.GetTeam(context.Background(), 1)
- if err != nil {
- t.Errorf("Organizations.GetTeam returned error: %v", err)
- }
-
- want := &Team{ID: Int64(1), Name: String("n"), Description: String("d"), URL: String("u"), Slug: String("s"), Permission: String("p"),
- Parent: &Team{ID: Int64(2), Name: String("n"), Description: String("d")},
- }
- if !reflect.DeepEqual(team, want) {
- t.Errorf("Organizations.GetTeam returned %+v, want %+v", team, want)
- }
-}
-
-func TestOrganizationsService_CreateTeam(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &NewTeam{Name: "n", Privacy: String("closed"), RepoNames: []string{"r"}}
-
- mux.HandleFunc("/orgs/o/teams", func(w http.ResponseWriter, r *http.Request) {
- v := new(NewTeam)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeNestedTeamsPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- team, _, err := client.Organizations.CreateTeam(context.Background(), "o", input)
- if err != nil {
- t.Errorf("Organizations.CreateTeam returned error: %v", err)
- }
-
- want := &Team{ID: Int64(1)}
- if !reflect.DeepEqual(team, want) {
- t.Errorf("Organizations.CreateTeam returned %+v, want %+v", team, want)
- }
-}
-
-func TestOrganizationsService_CreateTeam_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Organizations.CreateTeam(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_EditTeam(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &NewTeam{Name: "n", Privacy: String("closed")}
-
- mux.HandleFunc("/teams/1", func(w http.ResponseWriter, r *http.Request) {
- v := new(NewTeam)
- json.NewDecoder(r.Body).Decode(v)
-
- testHeader(t, r, "Accept", mediaTypeNestedTeamsPreview)
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- team, _, err := client.Organizations.EditTeam(context.Background(), 1, input)
- if err != nil {
- t.Errorf("Organizations.EditTeam returned error: %v", err)
- }
-
- want := &Team{ID: Int64(1)}
- if !reflect.DeepEqual(team, want) {
- t.Errorf("Organizations.EditTeam returned %+v, want %+v", team, want)
- }
-}
-
-func TestOrganizationsService_DeleteTeam(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeNestedTeamsPreview)
- })
-
- _, err := client.Organizations.DeleteTeam(context.Background(), 1)
- if err != nil {
- t.Errorf("Organizations.DeleteTeam returned error: %v", err)
- }
-}
-
-func TestOrganizationsService_ListChildTeams(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1/teams", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeNestedTeamsPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":2}]`)
- })
-
- opt := &ListOptions{Page: 2}
- teams, _, err := client.Organizations.ListChildTeams(context.Background(), 1, opt)
- if err != nil {
- t.Errorf("Organizations.ListTeams returned error: %v", err)
- }
-
- want := []*Team{{ID: Int64(2)}}
- if !reflect.DeepEqual(teams, want) {
- t.Errorf("Organizations.ListTeams returned %+v, want %+v", teams, want)
- }
-}
-
-func TestOrganizationsService_ListTeamMembers(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1/members", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeNestedTeamsPreview)
- testFormValues(t, r, values{"role": "member", "page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &OrganizationListTeamMembersOptions{Role: "member", ListOptions: ListOptions{Page: 2}}
- members, _, err := client.Organizations.ListTeamMembers(context.Background(), 1, opt)
- if err != nil {
- t.Errorf("Organizations.ListTeamMembers returned error: %v", err)
- }
-
- want := []*User{{ID: Int64(1)}}
- if !reflect.DeepEqual(members, want) {
- t.Errorf("Organizations.ListTeamMembers returned %+v, want %+v", members, want)
- }
-}
-
-func TestOrganizationsService_IsTeamMember_true(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1/members/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- })
-
- member, _, err := client.Organizations.IsTeamMember(context.Background(), 1, "u")
- if err != nil {
- t.Errorf("Organizations.IsTeamMember returned error: %v", err)
- }
- if want := true; member != want {
- t.Errorf("Organizations.IsTeamMember returned %+v, want %+v", member, want)
- }
-}
-
-// ensure that a 404 response is interpreted as "false" and not an error
-func TestOrganizationsService_IsTeamMember_false(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1/members/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNotFound)
- })
-
- member, _, err := client.Organizations.IsTeamMember(context.Background(), 1, "u")
- if err != nil {
- t.Errorf("Organizations.IsTeamMember returned error: %+v", err)
- }
- if want := false; member != want {
- t.Errorf("Organizations.IsTeamMember returned %+v, want %+v", member, want)
- }
-}
-
-// ensure that a 400 response is interpreted as an actual error, and not simply
-// as "false" like the above case of a 404
-func TestOrganizationsService_IsTeamMember_error(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1/members/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- http.Error(w, "BadRequest", http.StatusBadRequest)
- })
-
- member, _, err := client.Organizations.IsTeamMember(context.Background(), 1, "u")
- if err == nil {
- t.Errorf("Expected HTTP 400 response")
- }
- if want := false; member != want {
- t.Errorf("Organizations.IsTeamMember returned %+v, want %+v", member, want)
- }
-}
-
-func TestOrganizationsService_IsTeamMember_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Organizations.IsTeamMember(context.Background(), 1, "%")
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_PublicizeMembership(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Organizations.PublicizeMembership(context.Background(), "o", "u")
- if err != nil {
- t.Errorf("Organizations.PublicizeMembership returned error: %v", err)
- }
-}
-
-func TestOrganizationsService_PublicizeMembership_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Organizations.PublicizeMembership(context.Background(), "%", "u")
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_ConcealMembership(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Organizations.ConcealMembership(context.Background(), "o", "u")
- if err != nil {
- t.Errorf("Organizations.ConcealMembership returned error: %v", err)
- }
-}
-
-func TestOrganizationsService_ConcealMembership_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Organizations.ConcealMembership(context.Background(), "%", "u")
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_ListTeamRepos(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1/repos", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- acceptHeaders := []string{mediaTypeTopicsPreview, mediaTypeNestedTeamsPreview}
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 2}
- members, _, err := client.Organizations.ListTeamRepos(context.Background(), 1, opt)
- if err != nil {
- t.Errorf("Organizations.ListTeamRepos returned error: %v", err)
- }
-
- want := []*Repository{{ID: Int64(1)}}
- if !reflect.DeepEqual(members, want) {
- t.Errorf("Organizations.ListTeamRepos returned %+v, want %+v", members, want)
- }
-}
-
-func TestOrganizationsService_IsTeamRepo_true(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- acceptHeaders := []string{mediaTypeOrgPermissionRepo, mediaTypeNestedTeamsPreview}
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
- fmt.Fprint(w, `{"id":1}`)
- })
-
- repo, _, err := client.Organizations.IsTeamRepo(context.Background(), 1, "o", "r")
- if err != nil {
- t.Errorf("Organizations.IsTeamRepo returned error: %v", err)
- }
-
- want := &Repository{ID: Int64(1)}
- if !reflect.DeepEqual(repo, want) {
- t.Errorf("Organizations.IsTeamRepo returned %+v, want %+v", repo, want)
- }
-}
-
-func TestOrganizationsService_IsTeamRepo_false(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNotFound)
- })
-
- repo, resp, err := client.Organizations.IsTeamRepo(context.Background(), 1, "o", "r")
- if err == nil {
- t.Errorf("Expected HTTP 404 response")
- }
- if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want {
- t.Errorf("Organizations.IsTeamRepo returned status %d, want %d", got, want)
- }
- if repo != nil {
- t.Errorf("Organizations.IsTeamRepo returned %+v, want nil", repo)
- }
-}
-
-func TestOrganizationsService_IsTeamRepo_error(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- http.Error(w, "BadRequest", http.StatusBadRequest)
- })
-
- repo, resp, err := client.Organizations.IsTeamRepo(context.Background(), 1, "o", "r")
- if err == nil {
- t.Errorf("Expected HTTP 400 response")
- }
- if got, want := resp.Response.StatusCode, http.StatusBadRequest; got != want {
- t.Errorf("Organizations.IsTeamRepo returned status %d, want %d", got, want)
- }
- if repo != nil {
- t.Errorf("Organizations.IsTeamRepo returned %+v, want nil", repo)
- }
-}
-
-func TestOrganizationsService_IsTeamRepo_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Organizations.IsTeamRepo(context.Background(), 1, "%", "r")
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_AddTeamRepo(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- opt := &OrganizationAddTeamRepoOptions{Permission: "admin"}
-
- mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) {
- v := new(OrganizationAddTeamRepoOptions)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PUT")
- if !reflect.DeepEqual(v, opt) {
- t.Errorf("Request body = %+v, want %+v", v, opt)
- }
-
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Organizations.AddTeamRepo(context.Background(), 1, "o", "r", opt)
- if err != nil {
- t.Errorf("Organizations.AddTeamRepo returned error: %v", err)
- }
-}
-
-func TestOrganizationsService_AddTeamRepo_noAccess(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- w.WriteHeader(http.StatusUnprocessableEntity)
- })
-
- _, err := client.Organizations.AddTeamRepo(context.Background(), 1, "o", "r", nil)
- if err == nil {
- t.Errorf("Expcted error to be returned")
- }
-}
-
-func TestOrganizationsService_AddTeamRepo_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Organizations.AddTeamRepo(context.Background(), 1, "%", "r", nil)
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_RemoveTeamRepo(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Organizations.RemoveTeamRepo(context.Background(), 1, "o", "r")
- if err != nil {
- t.Errorf("Organizations.RemoveTeamRepo returned error: %v", err)
- }
-}
-
-func TestOrganizationsService_RemoveTeamRepo_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Organizations.RemoveTeamRepo(context.Background(), 1, "%", "r")
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_GetTeamMembership(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1/memberships/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeNestedTeamsPreview)
- fmt.Fprint(w, `{"url":"u", "state":"active"}`)
- })
-
- membership, _, err := client.Organizations.GetTeamMembership(context.Background(), 1, "u")
- if err != nil {
- t.Errorf("Organizations.GetTeamMembership returned error: %v", err)
- }
-
- want := &Membership{URL: String("u"), State: String("active")}
- if !reflect.DeepEqual(membership, want) {
- t.Errorf("Organizations.GetTeamMembership returned %+v, want %+v", membership, want)
- }
-}
-
-func TestOrganizationsService_AddTeamMembership(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- opt := &OrganizationAddTeamMembershipOptions{Role: "maintainer"}
-
- mux.HandleFunc("/teams/1/memberships/u", func(w http.ResponseWriter, r *http.Request) {
- v := new(OrganizationAddTeamMembershipOptions)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PUT")
- if !reflect.DeepEqual(v, opt) {
- t.Errorf("Request body = %+v, want %+v", v, opt)
- }
-
- fmt.Fprint(w, `{"url":"u", "state":"pending"}`)
- })
-
- membership, _, err := client.Organizations.AddTeamMembership(context.Background(), 1, "u", opt)
- if err != nil {
- t.Errorf("Organizations.AddTeamMembership returned error: %v", err)
- }
-
- want := &Membership{URL: String("u"), State: String("pending")}
- if !reflect.DeepEqual(membership, want) {
- t.Errorf("Organizations.AddTeamMembership returned %+v, want %+v", membership, want)
- }
-}
-
-func TestOrganizationsService_RemoveTeamMembership(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1/memberships/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Organizations.RemoveTeamMembership(context.Background(), 1, "u")
- if err != nil {
- t.Errorf("Organizations.RemoveTeamMembership returned error: %v", err)
- }
-}
-
-func TestOrganizationsService_ListUserTeams(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/teams", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeNestedTeamsPreview)
- testFormValues(t, r, values{"page": "1"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 1}
- teams, _, err := client.Organizations.ListUserTeams(context.Background(), opt)
- if err != nil {
- t.Errorf("Organizations.ListUserTeams returned error: %v", err)
- }
-
- want := []*Team{{ID: Int64(1)}}
- if !reflect.DeepEqual(teams, want) {
- t.Errorf("Organizations.ListUserTeams returned %+v, want %+v", teams, want)
- }
-}
-
-func TestOrganizationsService_ListPendingTeamInvitations(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/teams/1/invitations", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "1"})
- fmt.Fprint(w, `[
- {
- "id": 1,
- "login": "monalisa",
- "email": "octocat@github.com",
- "role": "direct_member",
- "created_at": "2017-01-21T00:00:00Z",
- "inviter": {
- "login": "other_user",
- "id": 1,
- "avatar_url": "https://github.com/images/error/other_user_happy.gif",
- "gravatar_id": "",
- "url": "https://api.github.com/users/other_user",
- "html_url": "https://github.com/other_user",
- "followers_url": "https://api.github.com/users/other_user/followers",
- "following_url": "https://api.github.com/users/other_user/following/other_user",
- "gists_url": "https://api.github.com/users/other_user/gists/gist_id",
- "starred_url": "https://api.github.com/users/other_user/starred/owner/repo",
- "subscriptions_url": "https://api.github.com/users/other_user/subscriptions",
- "organizations_url": "https://api.github.com/users/other_user/orgs",
- "repos_url": "https://api.github.com/users/other_user/repos",
- "events_url": "https://api.github.com/users/other_user/events/privacy",
- "received_events_url": "https://api.github.com/users/other_user/received_events/privacy",
- "type": "User",
- "site_admin": false
- }
- }
- ]`)
- })
-
- opt := &ListOptions{Page: 1}
- invitations, _, err := client.Organizations.ListPendingTeamInvitations(context.Background(), 1, opt)
- if err != nil {
- t.Errorf("Organizations.ListPendingTeamInvitations returned error: %v", err)
- }
-
- createdAt := time.Date(2017, 01, 21, 0, 0, 0, 0, time.UTC)
- want := []*Invitation{
- {
- ID: Int64(1),
- Login: String("monalisa"),
- Email: String("octocat@github.com"),
- Role: String("direct_member"),
- CreatedAt: &createdAt,
- Inviter: &User{
- Login: String("other_user"),
- ID: Int64(1),
- AvatarURL: String("https://github.com/images/error/other_user_happy.gif"),
- GravatarID: String(""),
- URL: String("https://api.github.com/users/other_user"),
- HTMLURL: String("https://github.com/other_user"),
- FollowersURL: String("https://api.github.com/users/other_user/followers"),
- FollowingURL: String("https://api.github.com/users/other_user/following/other_user"),
- GistsURL: String("https://api.github.com/users/other_user/gists/gist_id"),
- StarredURL: String("https://api.github.com/users/other_user/starred/owner/repo"),
- SubscriptionsURL: String("https://api.github.com/users/other_user/subscriptions"),
- OrganizationsURL: String("https://api.github.com/users/other_user/orgs"),
- ReposURL: String("https://api.github.com/users/other_user/repos"),
- EventsURL: String("https://api.github.com/users/other_user/events/privacy"),
- ReceivedEventsURL: String("https://api.github.com/users/other_user/received_events/privacy"),
- Type: String("User"),
- SiteAdmin: Bool(false),
- },
- }}
-
- if !reflect.DeepEqual(invitations, want) {
- t.Errorf("Organizations.ListPendingTeamInvitations returned %+v, want %+v", invitations, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/orgs_test.go b/vendor/github.com/google/go-github/github/orgs_test.go
deleted file mode 100644
index ca4263e0..00000000
--- a/vendor/github.com/google/go-github/github/orgs_test.go
+++ /dev/null
@@ -1,179 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestOrganizationsService_ListAll(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- since := 1342004
- mux.HandleFunc("/organizations", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testFormValues(t, r, values{"since": "1342004"})
- fmt.Fprint(w, `[{"id":4314092}]`)
- })
-
- opt := &OrganizationsListOptions{Since: since}
- orgs, _, err := client.Organizations.ListAll(context.Background(), opt)
- if err != nil {
- t.Errorf("Organizations.ListAll returned error: %v", err)
- }
-
- want := []*Organization{{ID: Int64(4314092)}}
- if !reflect.DeepEqual(orgs, want) {
- t.Errorf("Organizations.ListAll returned %+v, want %+v", orgs, want)
- }
-}
-
-func TestOrganizationsService_List_authenticatedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/orgs", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, `[{"id":1},{"id":2}]`)
- })
-
- orgs, _, err := client.Organizations.List(context.Background(), "", nil)
- if err != nil {
- t.Errorf("Organizations.List returned error: %v", err)
- }
-
- want := []*Organization{{ID: Int64(1)}, {ID: Int64(2)}}
- if !reflect.DeepEqual(orgs, want) {
- t.Errorf("Organizations.List returned %+v, want %+v", orgs, want)
- }
-}
-
-func TestOrganizationsService_List_specifiedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/orgs", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1},{"id":2}]`)
- })
-
- opt := &ListOptions{Page: 2}
- orgs, _, err := client.Organizations.List(context.Background(), "u", opt)
- if err != nil {
- t.Errorf("Organizations.List returned error: %v", err)
- }
-
- want := []*Organization{{ID: Int64(1)}, {ID: Int64(2)}}
- if !reflect.DeepEqual(orgs, want) {
- t.Errorf("Organizations.List returned %+v, want %+v", orgs, want)
- }
-}
-
-func TestOrganizationsService_List_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Organizations.List(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_Get(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, `{"id":1, "login":"l", "url":"u", "avatar_url": "a", "location":"l"}`)
- })
-
- org, _, err := client.Organizations.Get(context.Background(), "o")
- if err != nil {
- t.Errorf("Organizations.Get returned error: %v", err)
- }
-
- want := &Organization{ID: Int64(1), Login: String("l"), URL: String("u"), AvatarURL: String("a"), Location: String("l")}
- if !reflect.DeepEqual(org, want) {
- t.Errorf("Organizations.Get returned %+v, want %+v", org, want)
- }
-}
-
-func TestOrganizationsService_Get_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Organizations.Get(context.Background(), "%")
- testURLParseError(t, err)
-}
-
-func TestOrganizationsService_GetByID(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/organizations/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, `{"id":1, "login":"l", "url":"u", "avatar_url": "a", "location":"l"}`)
- })
-
- org, _, err := client.Organizations.GetByID(context.Background(), 1)
- if err != nil {
- t.Fatalf("Organizations.GetByID returned error: %v", err)
- }
-
- want := &Organization{ID: Int64(1), Login: String("l"), URL: String("u"), AvatarURL: String("a"), Location: String("l")}
- if !reflect.DeepEqual(org, want) {
- t.Errorf("Organizations.GetByID returned %+v, want %+v", org, want)
- }
-}
-
-func TestOrganizationsService_Edit(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Organization{Login: String("l")}
-
- mux.HandleFunc("/orgs/o", func(w http.ResponseWriter, r *http.Request) {
- v := new(Organization)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- org, _, err := client.Organizations.Edit(context.Background(), "o", input)
- if err != nil {
- t.Errorf("Organizations.Edit returned error: %v", err)
- }
-
- want := &Organization{ID: Int64(1)}
- if !reflect.DeepEqual(org, want) {
- t.Errorf("Organizations.Edit returned %+v, want %+v", org, want)
- }
-}
-
-func TestOrganizationsService_Edit_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Organizations.Edit(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/orgs_users_blocking_test.go b/vendor/github.com/google/go-github/github/orgs_users_blocking_test.go
deleted file mode 100644
index 5d38cc44..00000000
--- a/vendor/github.com/google/go-github/github/orgs_users_blocking_test.go
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2017 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestOrganizationsService_ListBlockedUsers(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/blocks", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeBlockUsersPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{
- "login": "octocat"
- }]`)
- })
-
- opt := &ListOptions{Page: 2}
- blockedUsers, _, err := client.Organizations.ListBlockedUsers(context.Background(), "o", opt)
- if err != nil {
- t.Errorf("Organizations.ListBlockedUsers returned error: %v", err)
- }
-
- want := []*User{{Login: String("octocat")}}
- if !reflect.DeepEqual(blockedUsers, want) {
- t.Errorf("Organizations.ListBlockedUsers returned %+v, want %+v", blockedUsers, want)
- }
-}
-
-func TestOrganizationsService_IsBlocked(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/blocks/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeBlockUsersPreview)
- w.WriteHeader(http.StatusNoContent)
- })
-
- isBlocked, _, err := client.Organizations.IsBlocked(context.Background(), "o", "u")
- if err != nil {
- t.Errorf("Organizations.IsBlocked returned error: %v", err)
- }
- if want := true; isBlocked != want {
- t.Errorf("Organizations.IsBlocked returned %+v, want %+v", isBlocked, want)
- }
-}
-
-func TestOrganizationsService_BlockUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/blocks/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- testHeader(t, r, "Accept", mediaTypeBlockUsersPreview)
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Organizations.BlockUser(context.Background(), "o", "u")
- if err != nil {
- t.Errorf("Organizations.BlockUser returned error: %v", err)
- }
-}
-
-func TestOrganizationsService_UnblockUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/orgs/o/blocks/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeBlockUsersPreview)
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Organizations.UnblockUser(context.Background(), "o", "u")
- if err != nil {
- t.Errorf("Organizations.UnblockUser returned error: %v", err)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/projects_test.go b/vendor/github.com/google/go-github/github/projects_test.go
deleted file mode 100644
index 9cb12aaa..00000000
--- a/vendor/github.com/google/go-github/github/projects_test.go
+++ /dev/null
@@ -1,371 +0,0 @@
-// 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestProjectsService_UpdateProject(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &ProjectOptions{Name: "Project Name", Body: "Project body.", State: "open"}
-
- mux.HandleFunc("/projects/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PATCH")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
-
- v := &ProjectOptions{}
- json.NewDecoder(r.Body).Decode(v)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- project, _, err := client.Projects.UpdateProject(context.Background(), 1, input)
- if err != nil {
- t.Errorf("Projects.UpdateProject returned error: %v", err)
- }
-
- want := &Project{ID: Int64(1)}
- if !reflect.DeepEqual(project, want) {
- t.Errorf("Projects.UpdateProject returned %+v, want %+v", project, want)
- }
-}
-
-func TestProjectsService_GetProject(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/projects/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
- fmt.Fprint(w, `{"id":1}`)
- })
-
- project, _, err := client.Projects.GetProject(context.Background(), 1)
- if err != nil {
- t.Errorf("Projects.GetProject returned error: %v", err)
- }
-
- want := &Project{ID: Int64(1)}
- if !reflect.DeepEqual(project, want) {
- t.Errorf("Projects.GetProject returned %+v, want %+v", project, want)
- }
-}
-
-func TestProjectsService_DeleteProject(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/projects/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
- })
-
- _, err := client.Projects.DeleteProject(context.Background(), 1)
- if err != nil {
- t.Errorf("Projects.DeleteProject returned error: %v", err)
- }
-}
-
-func TestProjectsService_ListProjectColumns(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/projects/1/columns", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 2}
- columns, _, err := client.Projects.ListProjectColumns(context.Background(), 1, opt)
- if err != nil {
- t.Errorf("Projects.ListProjectColumns returned error: %v", err)
- }
-
- want := []*ProjectColumn{{ID: Int64(1)}}
- if !reflect.DeepEqual(columns, want) {
- t.Errorf("Projects.ListProjectColumns returned %+v, want %+v", columns, want)
- }
-}
-
-func TestProjectsService_GetProjectColumn(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/projects/columns/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
- fmt.Fprint(w, `{"id":1}`)
- })
-
- column, _, err := client.Projects.GetProjectColumn(context.Background(), 1)
- if err != nil {
- t.Errorf("Projects.GetProjectColumn returned error: %v", err)
- }
-
- want := &ProjectColumn{ID: Int64(1)}
- if !reflect.DeepEqual(column, want) {
- t.Errorf("Projects.GetProjectColumn returned %+v, want %+v", column, want)
- }
-}
-
-func TestProjectsService_CreateProjectColumn(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &ProjectColumnOptions{Name: "Column Name"}
-
- mux.HandleFunc("/projects/1/columns", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
-
- v := &ProjectColumnOptions{}
- json.NewDecoder(r.Body).Decode(v)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- column, _, err := client.Projects.CreateProjectColumn(context.Background(), 1, input)
- if err != nil {
- t.Errorf("Projects.CreateProjectColumn returned error: %v", err)
- }
-
- want := &ProjectColumn{ID: Int64(1)}
- if !reflect.DeepEqual(column, want) {
- t.Errorf("Projects.CreateProjectColumn returned %+v, want %+v", column, want)
- }
-}
-
-func TestProjectsService_UpdateProjectColumn(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &ProjectColumnOptions{Name: "Column Name"}
-
- mux.HandleFunc("/projects/columns/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PATCH")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
-
- v := &ProjectColumnOptions{}
- json.NewDecoder(r.Body).Decode(v)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- column, _, err := client.Projects.UpdateProjectColumn(context.Background(), 1, input)
- if err != nil {
- t.Errorf("Projects.UpdateProjectColumn returned error: %v", err)
- }
-
- want := &ProjectColumn{ID: Int64(1)}
- if !reflect.DeepEqual(column, want) {
- t.Errorf("Projects.UpdateProjectColumn returned %+v, want %+v", column, want)
- }
-}
-
-func TestProjectsService_DeleteProjectColumn(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/projects/columns/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
- })
-
- _, err := client.Projects.DeleteProjectColumn(context.Background(), 1)
- if err != nil {
- t.Errorf("Projects.DeleteProjectColumn returned error: %v", err)
- }
-}
-
-func TestProjectsService_MoveProjectColumn(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &ProjectColumnMoveOptions{Position: "after:12345"}
-
- mux.HandleFunc("/projects/columns/1/moves", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
-
- v := &ProjectColumnMoveOptions{}
- json.NewDecoder(r.Body).Decode(v)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
- })
-
- _, err := client.Projects.MoveProjectColumn(context.Background(), 1, input)
- if err != nil {
- t.Errorf("Projects.MoveProjectColumn returned error: %v", err)
- }
-}
-
-func TestProjectsService_ListProjectCards(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/projects/columns/1/cards", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 2}
- cards, _, err := client.Projects.ListProjectCards(context.Background(), 1, opt)
- if err != nil {
- t.Errorf("Projects.ListProjectCards returned error: %v", err)
- }
-
- want := []*ProjectCard{{ID: Int64(1)}}
- if !reflect.DeepEqual(cards, want) {
- t.Errorf("Projects.ListProjectCards returned %+v, want %+v", cards, want)
- }
-}
-
-func TestProjectsService_GetProjectCard(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/projects/columns/cards/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
- fmt.Fprint(w, `{"id":1}`)
- })
-
- card, _, err := client.Projects.GetProjectCard(context.Background(), 1)
- if err != nil {
- t.Errorf("Projects.GetProjectCard returned error: %v", err)
- }
-
- want := &ProjectCard{ID: Int64(1)}
- if !reflect.DeepEqual(card, want) {
- t.Errorf("Projects.GetProjectCard returned %+v, want %+v", card, want)
- }
-}
-
-func TestProjectsService_CreateProjectCard(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &ProjectCardOptions{
- ContentID: 12345,
- ContentType: "Issue",
- }
-
- mux.HandleFunc("/projects/columns/1/cards", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
-
- v := &ProjectCardOptions{}
- json.NewDecoder(r.Body).Decode(v)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- card, _, err := client.Projects.CreateProjectCard(context.Background(), 1, input)
- if err != nil {
- t.Errorf("Projects.CreateProjectCard returned error: %v", err)
- }
-
- want := &ProjectCard{ID: Int64(1)}
- if !reflect.DeepEqual(card, want) {
- t.Errorf("Projects.CreateProjectCard returned %+v, want %+v", card, want)
- }
-}
-
-func TestProjectsService_UpdateProjectCard(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &ProjectCardOptions{
- ContentID: 12345,
- ContentType: "Issue",
- }
-
- mux.HandleFunc("/projects/columns/cards/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PATCH")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
-
- v := &ProjectCardOptions{}
- json.NewDecoder(r.Body).Decode(v)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- card, _, err := client.Projects.UpdateProjectCard(context.Background(), 1, input)
- if err != nil {
- t.Errorf("Projects.UpdateProjectCard returned error: %v", err)
- }
-
- want := &ProjectCard{ID: Int64(1)}
- if !reflect.DeepEqual(card, want) {
- t.Errorf("Projects.UpdateProjectCard returned %+v, want %+v", card, want)
- }
-}
-
-func TestProjectsService_DeleteProjectCard(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/projects/columns/cards/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
- })
-
- _, err := client.Projects.DeleteProjectCard(context.Background(), 1)
- if err != nil {
- t.Errorf("Projects.DeleteProjectCard returned error: %v", err)
- }
-}
-
-func TestProjectsService_MoveProjectCard(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &ProjectCardMoveOptions{Position: "after:12345"}
-
- mux.HandleFunc("/projects/columns/cards/1/moves", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
-
- v := &ProjectCardMoveOptions{}
- json.NewDecoder(r.Body).Decode(v)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
- })
-
- _, err := client.Projects.MoveProjectCard(context.Background(), 1, input)
- if err != nil {
- t.Errorf("Projects.MoveProjectCard returned error: %v", err)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/pulls_comments_test.go b/vendor/github.com/google/go-github/github/pulls_comments_test.go
deleted file mode 100644
index becb30e1..00000000
--- a/vendor/github.com/google/go-github/github/pulls_comments_test.go
+++ /dev/null
@@ -1,203 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
- "time"
-)
-
-func TestPullRequestsService_ListComments_allPulls(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/comments", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
- testFormValues(t, r, values{
- "sort": "updated",
- "direction": "desc",
- "since": "2002-02-10T15:30:00Z",
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &PullRequestListCommentsOptions{
- Sort: "updated",
- Direction: "desc",
- Since: time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC),
- ListOptions: ListOptions{Page: 2},
- }
- pulls, _, err := client.PullRequests.ListComments(context.Background(), "o", "r", 0, opt)
- if err != nil {
- t.Errorf("PullRequests.ListComments returned error: %v", err)
- }
-
- want := []*PullRequestComment{{ID: Int64(1)}}
- if !reflect.DeepEqual(pulls, want) {
- t.Errorf("PullRequests.ListComments returned %+v, want %+v", pulls, want)
- }
-}
-
-func TestPullRequestsService_ListComments_specificPull(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1/comments", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- pulls, _, err := client.PullRequests.ListComments(context.Background(), "o", "r", 1, nil)
- if err != nil {
- t.Errorf("PullRequests.ListComments returned error: %v", err)
- }
-
- want := []*PullRequestComment{{ID: Int64(1)}}
- if !reflect.DeepEqual(pulls, want) {
- t.Errorf("PullRequests.ListComments returned %+v, want %+v", pulls, want)
- }
-}
-
-func TestPullRequestsService_ListComments_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.PullRequests.ListComments(context.Background(), "%", "r", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestPullRequestsService_GetComment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/comments/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
- fmt.Fprint(w, `{"id":1}`)
- })
-
- comment, _, err := client.PullRequests.GetComment(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("PullRequests.GetComment returned error: %v", err)
- }
-
- want := &PullRequestComment{ID: Int64(1)}
- if !reflect.DeepEqual(comment, want) {
- t.Errorf("PullRequests.GetComment returned %+v, want %+v", comment, want)
- }
-}
-
-func TestPullRequestsService_GetComment_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.PullRequests.GetComment(context.Background(), "%", "r", 1)
- testURLParseError(t, err)
-}
-
-func TestPullRequestsService_CreateComment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &PullRequestComment{Body: String("b")}
-
- mux.HandleFunc("/repos/o/r/pulls/1/comments", func(w http.ResponseWriter, r *http.Request) {
- v := new(PullRequestComment)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- comment, _, err := client.PullRequests.CreateComment(context.Background(), "o", "r", 1, input)
- if err != nil {
- t.Errorf("PullRequests.CreateComment returned error: %v", err)
- }
-
- want := &PullRequestComment{ID: Int64(1)}
- if !reflect.DeepEqual(comment, want) {
- t.Errorf("PullRequests.CreateComment returned %+v, want %+v", comment, want)
- }
-}
-
-func TestPullRequestsService_CreateComment_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.PullRequests.CreateComment(context.Background(), "%", "r", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestPullRequestsService_EditComment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &PullRequestComment{Body: String("b")}
-
- mux.HandleFunc("/repos/o/r/pulls/comments/1", func(w http.ResponseWriter, r *http.Request) {
- v := new(PullRequestComment)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- comment, _, err := client.PullRequests.EditComment(context.Background(), "o", "r", 1, input)
- if err != nil {
- t.Errorf("PullRequests.EditComment returned error: %v", err)
- }
-
- want := &PullRequestComment{ID: Int64(1)}
- if !reflect.DeepEqual(comment, want) {
- t.Errorf("PullRequests.EditComment returned %+v, want %+v", comment, want)
- }
-}
-
-func TestPullRequestsService_EditComment_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.PullRequests.EditComment(context.Background(), "%", "r", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestPullRequestsService_DeleteComment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/comments/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.PullRequests.DeleteComment(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("PullRequests.DeleteComment returned error: %v", err)
- }
-}
-
-func TestPullRequestsService_DeleteComment_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.PullRequests.DeleteComment(context.Background(), "%", "r", 1)
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/pulls_reviewers_test.go b/vendor/github.com/google/go-github/github/pulls_reviewers_test.go
deleted file mode 100644
index 48a3bf0c..00000000
--- a/vendor/github.com/google/go-github/github/pulls_reviewers_test.go
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2017 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestRequestReviewers(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testBody(t, r, `{"reviewers":["octocat","googlebot"],"team_reviewers":["justice-league","injustice-league"]}`+"\n")
- testHeader(t, r, "Accept", mediaTypeTeamReviewPreview)
- fmt.Fprint(w, `{"number":1}`)
- })
-
- // This returns a PR, unmarshalling of which is tested elsewhere
- pull, _, err := client.PullRequests.RequestReviewers(context.Background(), "o", "r", 1, ReviewersRequest{Reviewers: []string{"octocat", "googlebot"}, TeamReviewers: []string{"justice-league", "injustice-league"}})
- if err != nil {
- t.Errorf("PullRequests.RequestReviewers returned error: %v", err)
- }
- want := &PullRequest{Number: Int(1)}
- if !reflect.DeepEqual(pull, want) {
- t.Errorf("PullRequests.RequestReviewers returned %+v, want %+v", pull, want)
- }
-}
-
-func TestRemoveReviewers(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeTeamReviewPreview)
- testBody(t, r, `{"reviewers":["octocat","googlebot"],"team_reviewers":["justice-league"]}`+"\n")
- })
-
- _, err := client.PullRequests.RemoveReviewers(context.Background(), "o", "r", 1, ReviewersRequest{Reviewers: []string{"octocat", "googlebot"}, TeamReviewers: []string{"justice-league"}})
- if err != nil {
- t.Errorf("PullRequests.RemoveReviewers returned error: %v", err)
- }
-}
-
-func TestListReviewers(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeTeamReviewPreview)
- fmt.Fprint(w, `{"users":[{"login":"octocat","id":1}],"teams":[{"id":1,"name":"Justice League"}]}`)
- })
-
- reviewers, _, err := client.PullRequests.ListReviewers(context.Background(), "o", "r", 1, nil)
- if err != nil {
- t.Errorf("PullRequests.ListReviewers returned error: %v", err)
- }
-
- want := &Reviewers{
- Users: []*User{
- {
- Login: String("octocat"),
- ID: Int64(1),
- },
- },
- Teams: []*Team{
- {
- ID: Int64(1),
- Name: String("Justice League"),
- },
- },
- }
- if !reflect.DeepEqual(reviewers, want) {
- t.Errorf("PullRequests.ListReviewers returned %+v, want %+v", reviewers, want)
- }
-}
-
-func TestListReviewers_withOptions(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
- fmt.Fprint(w, `{}`)
- })
-
- _, _, err := client.PullRequests.ListReviewers(context.Background(), "o", "r", 1, &ListOptions{Page: 2})
- if err != nil {
- t.Errorf("PullRequests.ListReviewers returned error: %v", err)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/pulls_reviews_test.go b/vendor/github.com/google/go-github/github/pulls_reviews_test.go
deleted file mode 100644
index 58e301bd..00000000
--- a/vendor/github.com/google/go-github/github/pulls_reviews_test.go
+++ /dev/null
@@ -1,273 +0,0 @@
-// 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestPullRequestsService_ListReviews(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1/reviews", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":1},{"id":2}]`)
- })
-
- opt := &ListOptions{Page: 2}
- reviews, _, err := client.PullRequests.ListReviews(context.Background(), "o", "r", 1, opt)
- if err != nil {
- t.Errorf("PullRequests.ListReviews returned error: %v", err)
- }
-
- want := []*PullRequestReview{
- {ID: Int64(1)},
- {ID: Int64(2)},
- }
- if !reflect.DeepEqual(reviews, want) {
- t.Errorf("PullRequests.ListReviews returned %+v, want %+v", reviews, want)
- }
-}
-
-func TestPullRequestsService_ListReviews_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.PullRequests.ListReviews(context.Background(), "%", "r", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestPullRequestsService_GetReview(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1/reviews/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id":1}`)
- })
-
- review, _, err := client.PullRequests.GetReview(context.Background(), "o", "r", 1, 1)
- if err != nil {
- t.Errorf("PullRequests.GetReview returned error: %v", err)
- }
-
- want := &PullRequestReview{ID: Int64(1)}
- if !reflect.DeepEqual(review, want) {
- t.Errorf("PullRequests.GetReview returned %+v, want %+v", review, want)
- }
-}
-
-func TestPullRequestsService_GetReview_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.PullRequests.GetReview(context.Background(), "%", "r", 1, 1)
- testURLParseError(t, err)
-}
-
-func TestPullRequestsService_DeletePendingReview(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1/reviews/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- fmt.Fprint(w, `{"id":1}`)
- })
-
- review, _, err := client.PullRequests.DeletePendingReview(context.Background(), "o", "r", 1, 1)
- if err != nil {
- t.Errorf("PullRequests.DeletePendingReview returned error: %v", err)
- }
-
- want := &PullRequestReview{ID: Int64(1)}
- if !reflect.DeepEqual(review, want) {
- t.Errorf("PullRequests.DeletePendingReview returned %+v, want %+v", review, want)
- }
-}
-
-func TestPullRequestsService_DeletePendingReview_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.PullRequests.DeletePendingReview(context.Background(), "%", "r", 1, 1)
- testURLParseError(t, err)
-}
-
-func TestPullRequestsService_ListReviewComments(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1/reviews/1/comments", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `[{"id":1},{"id":2}]`)
- })
-
- comments, _, err := client.PullRequests.ListReviewComments(context.Background(), "o", "r", 1, 1, nil)
- if err != nil {
- t.Errorf("PullRequests.ListReviewComments returned error: %v", err)
- }
-
- want := []*PullRequestComment{
- {ID: Int64(1)},
- {ID: Int64(2)},
- }
- if !reflect.DeepEqual(comments, want) {
- t.Errorf("PullRequests.ListReviewComments returned %+v, want %+v", comments, want)
- }
-}
-
-func TestPullRequestsService_ListReviewComments_withOptions(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1/reviews/1/comments", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
- fmt.Fprint(w, `[]`)
- })
-
- _, _, err := client.PullRequests.ListReviewComments(context.Background(), "o", "r", 1, 1, &ListOptions{Page: 2})
- if err != nil {
- t.Errorf("PullRequests.ListReviewComments returned error: %v", err)
- }
-}
-
-func TestPullRequestsService_ListReviewComments_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.PullRequests.ListReviewComments(context.Background(), "%", "r", 1, 1, nil)
- testURLParseError(t, err)
-}
-
-func TestPullRequestsService_CreateReview(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &PullRequestReviewRequest{
- CommitID: String("commit_id"),
- Body: String("b"),
- Event: String("APPROVE"),
- }
-
- mux.HandleFunc("/repos/o/r/pulls/1/reviews", func(w http.ResponseWriter, r *http.Request) {
- v := new(PullRequestReviewRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- review, _, err := client.PullRequests.CreateReview(context.Background(), "o", "r", 1, input)
- if err != nil {
- t.Errorf("PullRequests.CreateReview returned error: %v", err)
- }
-
- want := &PullRequestReview{ID: Int64(1)}
- if !reflect.DeepEqual(review, want) {
- t.Errorf("PullRequests.CreateReview returned %+v, want %+v", review, want)
- }
-}
-
-func TestPullRequestsService_CreateReview_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.PullRequests.CreateReview(context.Background(), "%", "r", 1, &PullRequestReviewRequest{})
- testURLParseError(t, err)
-}
-
-func TestPullRequestsService_SubmitReview(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &PullRequestReviewRequest{
- Body: String("b"),
- Event: String("APPROVE"),
- }
-
- mux.HandleFunc("/repos/o/r/pulls/1/reviews/1/events", func(w http.ResponseWriter, r *http.Request) {
- v := new(PullRequestReviewRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- review, _, err := client.PullRequests.SubmitReview(context.Background(), "o", "r", 1, 1, input)
- if err != nil {
- t.Errorf("PullRequests.SubmitReview returned error: %v", err)
- }
-
- want := &PullRequestReview{ID: Int64(1)}
- if !reflect.DeepEqual(review, want) {
- t.Errorf("PullRequests.SubmitReview returned %+v, want %+v", review, want)
- }
-}
-
-func TestPullRequestsService_SubmitReview_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.PullRequests.SubmitReview(context.Background(), "%", "r", 1, 1, &PullRequestReviewRequest{})
- testURLParseError(t, err)
-}
-
-func TestPullRequestsService_DismissReview(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &PullRequestReviewDismissalRequest{Message: String("m")}
-
- mux.HandleFunc("/repos/o/r/pulls/1/reviews/1/dismissals", func(w http.ResponseWriter, r *http.Request) {
- v := new(PullRequestReviewDismissalRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PUT")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- review, _, err := client.PullRequests.DismissReview(context.Background(), "o", "r", 1, 1, input)
- if err != nil {
- t.Errorf("PullRequests.DismissReview returned error: %v", err)
- }
-
- want := &PullRequestReview{ID: Int64(1)}
- if !reflect.DeepEqual(review, want) {
- t.Errorf("PullRequests.DismissReview returned %+v, want %+v", review, want)
- }
-}
-
-func TestPullRequestsService_DismissReview_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.PullRequests.DismissReview(context.Background(), "%", "r", 1, 1, &PullRequestReviewDismissalRequest{})
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/pulls_test.go b/vendor/github.com/google/go-github/github/pulls_test.go
deleted file mode 100644
index 7d02c1a6..00000000
--- a/vendor/github.com/google/go-github/github/pulls_test.go
+++ /dev/null
@@ -1,529 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "io"
- "net/http"
- "reflect"
- "strings"
- "testing"
-)
-
-func TestPullRequestsService_List(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testFormValues(t, r, values{
- "state": "closed",
- "head": "h",
- "base": "b",
- "sort": "created",
- "direction": "desc",
- "page": "2",
- })
- fmt.Fprint(w, `[{"number":1}]`)
- })
-
- opt := &PullRequestListOptions{"closed", "h", "b", "created", "desc", ListOptions{Page: 2}}
- pulls, _, err := client.PullRequests.List(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("PullRequests.List returned error: %v", err)
- }
-
- want := []*PullRequest{{Number: Int(1)}}
- if !reflect.DeepEqual(pulls, want) {
- t.Errorf("PullRequests.List returned %+v, want %+v", pulls, want)
- }
-}
-
-func TestPullRequestsService_List_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.PullRequests.List(context.Background(), "%", "r", nil)
- testURLParseError(t, err)
-}
-
-func TestPullRequestsService_Get(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, `{"number":1}`)
- })
-
- pull, _, err := client.PullRequests.Get(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("PullRequests.Get returned error: %v", err)
- }
-
- want := &PullRequest{Number: Int(1)}
- if !reflect.DeepEqual(pull, want) {
- t.Errorf("PullRequests.Get returned %+v, want %+v", pull, want)
- }
-}
-
-func TestPullRequestsService_GetRaw_diff(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- const rawStr = "@@diff content"
-
- mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeV3Diff)
- fmt.Fprint(w, rawStr)
- })
-
- got, _, err := client.PullRequests.GetRaw(context.Background(), "o", "r", 1, RawOptions{Diff})
- if err != nil {
- t.Fatalf("PullRequests.GetRaw returned error: %v", err)
- }
- want := rawStr
- if got != want {
- t.Errorf("PullRequests.GetRaw returned %s want %s", got, want)
- }
-}
-
-func TestPullRequestsService_GetRaw_patch(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- const rawStr = "@@patch content"
-
- mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeV3Patch)
- fmt.Fprint(w, rawStr)
- })
-
- got, _, err := client.PullRequests.GetRaw(context.Background(), "o", "r", 1, RawOptions{Patch})
- if err != nil {
- t.Fatalf("PullRequests.GetRaw returned error: %v", err)
- }
- want := rawStr
- if got != want {
- t.Errorf("PullRequests.GetRaw returned %s want %s", got, want)
- }
-}
-
-func TestPullRequestsService_GetRaw_invalid(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.PullRequests.GetRaw(context.Background(), "o", "r", 1, RawOptions{100})
- if err == nil {
- t.Fatal("PullRequests.GetRaw should return error")
- }
- if !strings.Contains(err.Error(), "unsupported raw type") {
- t.Error("PullRequests.GetRaw should return unsupported raw type error")
- }
-}
-
-func TestPullRequestsService_Get_headAndBase(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"number":1,"head":{"ref":"r2","repo":{"id":2}},"base":{"ref":"r1","repo":{"id":1}}}`)
- })
-
- pull, _, err := client.PullRequests.Get(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("PullRequests.Get returned error: %v", err)
- }
-
- want := &PullRequest{
- Number: Int(1),
- Head: &PullRequestBranch{
- Ref: String("r2"),
- Repo: &Repository{ID: Int64(2)},
- },
- Base: &PullRequestBranch{
- Ref: String("r1"),
- Repo: &Repository{ID: Int64(1)},
- },
- }
- if !reflect.DeepEqual(pull, want) {
- t.Errorf("PullRequests.Get returned %+v, want %+v", pull, want)
- }
-}
-
-func TestPullRequestsService_Get_urlFields(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"number":1,
- "url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347",
- "html_url": "https://github.com/octocat/Hello-World/pull/1347",
- "issue_url": "https://api.github.com/repos/octocat/Hello-World/issues/1347",
- "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e",
- "diff_url": "https://github.com/octocat/Hello-World/pull/1347.diff",
- "patch_url": "https://github.com/octocat/Hello-World/pull/1347.patch",
- "review_comments_url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments",
- "review_comment_url": "https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}"}`)
- })
-
- pull, _, err := client.PullRequests.Get(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("PullRequests.Get returned error: %v", err)
- }
-
- want := &PullRequest{
- Number: Int(1),
- URL: String("https://api.github.com/repos/octocat/Hello-World/pulls/1347"),
- HTMLURL: String("https://github.com/octocat/Hello-World/pull/1347"),
- IssueURL: String("https://api.github.com/repos/octocat/Hello-World/issues/1347"),
- StatusesURL: String("https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e"),
- DiffURL: String("https://github.com/octocat/Hello-World/pull/1347.diff"),
- PatchURL: String("https://github.com/octocat/Hello-World/pull/1347.patch"),
- ReviewCommentsURL: String("https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments"),
- ReviewCommentURL: String("https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}"),
- }
-
- if !reflect.DeepEqual(pull, want) {
- t.Errorf("PullRequests.Get returned %+v, want %+v", pull, want)
- }
-}
-
-func TestPullRequestsService_Get_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.PullRequests.Get(context.Background(), "%", "r", 1)
- testURLParseError(t, err)
-}
-
-func TestPullRequestsService_Create(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &NewPullRequest{Title: String("t")}
-
- mux.HandleFunc("/repos/o/r/pulls", func(w http.ResponseWriter, r *http.Request) {
- v := new(NewPullRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"number":1}`)
- })
-
- pull, _, err := client.PullRequests.Create(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("PullRequests.Create returned error: %v", err)
- }
-
- want := &PullRequest{Number: Int(1)}
- if !reflect.DeepEqual(pull, want) {
- t.Errorf("PullRequests.Create returned %+v, want %+v", pull, want)
- }
-}
-
-func TestPullRequestsService_Create_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.PullRequests.Create(context.Background(), "%", "r", nil)
- testURLParseError(t, err)
-}
-
-func TestPullRequestsService_Edit(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- tests := []struct {
- input *PullRequest
- sendResponse string
-
- wantUpdate string
- want *PullRequest
- }{
- {
- input: &PullRequest{Title: String("t")},
- sendResponse: `{"number":1}`,
- wantUpdate: `{"title":"t"}`,
- want: &PullRequest{Number: Int(1)},
- },
- {
- // base update
- input: &PullRequest{Base: &PullRequestBranch{Ref: String("master")}},
- sendResponse: `{"number":1,"base":{"ref":"master"}}`,
- wantUpdate: `{"base":"master"}`,
- want: &PullRequest{
- Number: Int(1),
- Base: &PullRequestBranch{Ref: String("master")},
- },
- },
- }
-
- for i, tt := range tests {
- madeRequest := false
- mux.HandleFunc(fmt.Sprintf("/repos/o/r/pulls/%v", i), func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PATCH")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testBody(t, r, tt.wantUpdate+"\n")
- io.WriteString(w, tt.sendResponse)
- madeRequest = true
- })
-
- pull, _, err := client.PullRequests.Edit(context.Background(), "o", "r", i, tt.input)
- if err != nil {
- t.Errorf("%d: PullRequests.Edit returned error: %v", i, err)
- }
-
- if !reflect.DeepEqual(pull, tt.want) {
- t.Errorf("%d: PullRequests.Edit returned %+v, want %+v", i, pull, tt.want)
- }
-
- if !madeRequest {
- t.Errorf("%d: PullRequest.Edit did not make the expected request", i)
- }
- }
-}
-
-func TestPullRequestsService_Edit_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.PullRequests.Edit(context.Background(), "%", "r", 1, &PullRequest{})
- testURLParseError(t, err)
-}
-
-func TestPullRequestsService_ListCommits(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1/commits", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGitSigningPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `
- [
- {
- "sha": "3",
- "parents": [
- {
- "sha": "2"
- }
- ]
- },
- {
- "sha": "2",
- "parents": [
- {
- "sha": "1"
- }
- ]
- }
- ]`)
- })
-
- opt := &ListOptions{Page: 2}
- commits, _, err := client.PullRequests.ListCommits(context.Background(), "o", "r", 1, opt)
- if err != nil {
- t.Errorf("PullRequests.ListCommits returned error: %v", err)
- }
-
- want := []*RepositoryCommit{
- {
- SHA: String("3"),
- Parents: []Commit{
- {
- SHA: String("2"),
- },
- },
- },
- {
- SHA: String("2"),
- Parents: []Commit{
- {
- SHA: String("1"),
- },
- },
- },
- }
- if !reflect.DeepEqual(commits, want) {
- t.Errorf("PullRequests.ListCommits returned %+v, want %+v", commits, want)
- }
-}
-
-func TestPullRequestsService_ListFiles(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1/files", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `
- [
- {
- "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
- "filename": "file1.txt",
- "status": "added",
- "additions": 103,
- "deletions": 21,
- "changes": 124,
- "patch": "@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test"
- },
- {
- "sha": "f61aebed695e2e4193db5e6dcb09b5b57875f334",
- "filename": "file2.txt",
- "status": "modified",
- "additions": 5,
- "deletions": 3,
- "changes": 103,
- "patch": "@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test"
- }
- ]`)
- })
-
- opt := &ListOptions{Page: 2}
- commitFiles, _, err := client.PullRequests.ListFiles(context.Background(), "o", "r", 1, opt)
- if err != nil {
- t.Errorf("PullRequests.ListFiles returned error: %v", err)
- }
-
- want := []*CommitFile{
- {
- SHA: String("6dcb09b5b57875f334f61aebed695e2e4193db5e"),
- Filename: String("file1.txt"),
- Additions: Int(103),
- Deletions: Int(21),
- Changes: Int(124),
- Status: String("added"),
- Patch: String("@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test"),
- },
- {
- SHA: String("f61aebed695e2e4193db5e6dcb09b5b57875f334"),
- Filename: String("file2.txt"),
- Additions: Int(5),
- Deletions: Int(3),
- Changes: Int(103),
- Status: String("modified"),
- Patch: String("@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test"),
- },
- }
-
- if !reflect.DeepEqual(commitFiles, want) {
- t.Errorf("PullRequests.ListFiles returned %+v, want %+v", commitFiles, want)
- }
-}
-
-func TestPullRequestsService_IsMerged(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1/merge", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNoContent)
- })
-
- isMerged, _, err := client.PullRequests.IsMerged(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("PullRequests.IsMerged returned error: %v", err)
- }
-
- want := true
- if !reflect.DeepEqual(isMerged, want) {
- t.Errorf("PullRequests.IsMerged returned %+v, want %+v", isMerged, want)
- }
-}
-
-func TestPullRequestsService_Merge(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/1/merge", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- fmt.Fprint(w, `
- {
- "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
- "merged": true,
- "message": "Pull Request successfully merged"
- }`)
- })
-
- options := &PullRequestOptions{MergeMethod: "rebase"}
- merge, _, err := client.PullRequests.Merge(context.Background(), "o", "r", 1, "merging pull request", options)
- if err != nil {
- t.Errorf("PullRequests.Merge returned error: %v", err)
- }
-
- want := &PullRequestMergeResult{
- SHA: String("6dcb09b5b57875f334f61aebed695e2e4193db5e"),
- Merged: Bool(true),
- Message: String("Pull Request successfully merged"),
- }
- if !reflect.DeepEqual(merge, want) {
- t.Errorf("PullRequests.Merge returned %+v, want %+v", merge, want)
- }
-}
-
-// Test that different merge options produce expected PUT requests. See issue https://github.com/google/go-github/issues/500.
-func TestPullRequestsService_Merge_options(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- tests := []struct {
- options *PullRequestOptions
- wantBody string
- }{
- {
- options: nil,
- wantBody: `{"commit_message":"merging pull request"}`,
- },
- {
- options: &PullRequestOptions{},
- wantBody: `{"commit_message":"merging pull request"}`,
- },
- {
- options: &PullRequestOptions{MergeMethod: "rebase"},
- wantBody: `{"commit_message":"merging pull request","merge_method":"rebase"}`,
- },
- {
- options: &PullRequestOptions{SHA: "6dcb09b5b57875f334f61aebed695e2e4193db5e"},
- wantBody: `{"commit_message":"merging pull request","sha":"6dcb09b5b57875f334f61aebed695e2e4193db5e"}`,
- },
- {
- options: &PullRequestOptions{
- CommitTitle: "Extra detail",
- SHA: "6dcb09b5b57875f334f61aebed695e2e4193db5e",
- MergeMethod: "squash",
- },
- wantBody: `{"commit_message":"merging pull request","commit_title":"Extra detail","merge_method":"squash","sha":"6dcb09b5b57875f334f61aebed695e2e4193db5e"}`,
- },
- }
-
- for i, test := range tests {
- madeRequest := false
- mux.HandleFunc(fmt.Sprintf("/repos/o/r/pulls/%d/merge", i), func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- testBody(t, r, test.wantBody+"\n")
- madeRequest = true
- })
- _, _, _ = client.PullRequests.Merge(context.Background(), "o", "r", i, "merging pull request", test.options)
- if !madeRequest {
- t.Errorf("%d: PullRequests.Merge(%#v): expected request was not made", i, test.options)
- }
- }
-}
diff --git a/vendor/github.com/google/go-github/github/reactions_test.go b/vendor/github.com/google/go-github/github/reactions_test.go
deleted file mode 100644
index 2a43a8b8..00000000
--- a/vendor/github.com/google/go-github/github/reactions_test.go
+++ /dev/null
@@ -1,201 +0,0 @@
-// 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
-
-import (
- "context"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestReactionsService_ListCommentReactions(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
-
- w.WriteHeader(http.StatusOK)
- w.Write([]byte(`[{"id":1,"user":{"login":"l","id":2},"content":"+1"}]`))
- })
-
- got, _, err := client.Reactions.ListCommentReactions(context.Background(), "o", "r", 1, nil)
- if err != nil {
- t.Errorf("ListCommentReactions returned error: %v", err)
- }
- if want := []*Reaction{{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}}; !reflect.DeepEqual(got, want) {
- t.Errorf("ListCommentReactions = %+v, want %+v", got, want)
- }
-}
-
-func TestReactionsService_CreateCommentReaction(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
-
- w.WriteHeader(http.StatusCreated)
- w.Write([]byte(`{"id":1,"user":{"login":"l","id":2},"content":"+1"}`))
- })
-
- got, _, err := client.Reactions.CreateCommentReaction(context.Background(), "o", "r", 1, "+1")
- if err != nil {
- t.Errorf("CreateCommentReaction returned error: %v", err)
- }
- want := &Reaction{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("CreateCommentReaction = %+v, want %+v", got, want)
- }
-}
-
-func TestReactionsService_ListIssueReactions(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/1/reactions", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
-
- w.WriteHeader(http.StatusOK)
- w.Write([]byte(`[{"id":1,"user":{"login":"l","id":2},"content":"+1"}]`))
- })
-
- got, _, err := client.Reactions.ListIssueReactions(context.Background(), "o", "r", 1, nil)
- if err != nil {
- t.Errorf("ListIssueReactions returned error: %v", err)
- }
- if want := []*Reaction{{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}}; !reflect.DeepEqual(got, want) {
- t.Errorf("ListIssueReactions = %+v, want %+v", got, want)
- }
-}
-
-func TestReactionsService_CreateIssueReaction(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/1/reactions", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
-
- w.WriteHeader(http.StatusCreated)
- w.Write([]byte(`{"id":1,"user":{"login":"l","id":2},"content":"+1"}`))
- })
-
- got, _, err := client.Reactions.CreateIssueReaction(context.Background(), "o", "r", 1, "+1")
- if err != nil {
- t.Errorf("CreateIssueReaction returned error: %v", err)
- }
- want := &Reaction{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("CreateIssueReaction = %+v, want %+v", got, want)
- }
-}
-
-func TestReactionsService_ListIssueCommentReactions(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
-
- w.WriteHeader(http.StatusOK)
- w.Write([]byte(`[{"id":1,"user":{"login":"l","id":2},"content":"+1"}]`))
- })
-
- got, _, err := client.Reactions.ListIssueCommentReactions(context.Background(), "o", "r", 1, nil)
- if err != nil {
- t.Errorf("ListIssueCommentReactions returned error: %v", err)
- }
- if want := []*Reaction{{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}}; !reflect.DeepEqual(got, want) {
- t.Errorf("ListIssueCommentReactions = %+v, want %+v", got, want)
- }
-}
-
-func TestReactionsService_CreateIssueCommentReaction(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/issues/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
-
- w.WriteHeader(http.StatusCreated)
- w.Write([]byte(`{"id":1,"user":{"login":"l","id":2},"content":"+1"}`))
- })
-
- got, _, err := client.Reactions.CreateIssueCommentReaction(context.Background(), "o", "r", 1, "+1")
- if err != nil {
- t.Errorf("CreateIssueCommentReaction returned error: %v", err)
- }
- want := &Reaction{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("CreateIssueCommentReaction = %+v, want %+v", got, want)
- }
-}
-
-func TestReactionsService_ListPullRequestCommentReactions(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
-
- w.WriteHeader(http.StatusOK)
- w.Write([]byte(`[{"id":1,"user":{"login":"l","id":2},"content":"+1"}]`))
- })
-
- got, _, err := client.Reactions.ListPullRequestCommentReactions(context.Background(), "o", "r", 1, nil)
- if err != nil {
- t.Errorf("ListPullRequestCommentReactions returned error: %v", err)
- }
- if want := []*Reaction{{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}}; !reflect.DeepEqual(got, want) {
- t.Errorf("ListPullRequestCommentReactions = %+v, want %+v", got, want)
- }
-}
-
-func TestReactionsService_CreatePullRequestCommentReaction(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pulls/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
-
- w.WriteHeader(http.StatusCreated)
- w.Write([]byte(`{"id":1,"user":{"login":"l","id":2},"content":"+1"}`))
- })
-
- got, _, err := client.Reactions.CreatePullRequestCommentReaction(context.Background(), "o", "r", 1, "+1")
- if err != nil {
- t.Errorf("CreatePullRequestCommentReaction returned error: %v", err)
- }
- want := &Reaction{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("CreatePullRequestCommentReaction = %+v, want %+v", got, want)
- }
-}
-
-func TestReactionsService_DeleteReaction(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/reactions/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
-
- w.WriteHeader(http.StatusNoContent)
- })
-
- if _, err := client.Reactions.DeleteReaction(context.Background(), 1); err != nil {
- t.Errorf("DeleteReaction returned error: %v", err)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/repos_collaborators_test.go b/vendor/github.com/google/go-github/github/repos_collaborators_test.go
deleted file mode 100644
index c814a5f9..00000000
--- a/vendor/github.com/google/go-github/github/repos_collaborators_test.go
+++ /dev/null
@@ -1,201 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestRepositoriesService_ListCollaborators(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/collaborators", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeNestedTeamsPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprintf(w, `[{"id":1}, {"id":2}]`)
- })
-
- opt := &ListCollaboratorsOptions{
- ListOptions: ListOptions{Page: 2},
- }
- users, _, err := client.Repositories.ListCollaborators(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Repositories.ListCollaborators returned error: %v", err)
- }
-
- want := []*User{{ID: Int64(1)}, {ID: Int64(2)}}
- if !reflect.DeepEqual(users, want) {
- t.Errorf("Repositori es.ListCollaborators returned %+v, want %+v", users, want)
- }
-}
-
-func TestRepositoriesService_ListCollaborators_withAffiliation(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/collaborators", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"affiliation": "all", "page": "2"})
- fmt.Fprintf(w, `[{"id":1}, {"id":2}]`)
- })
-
- opt := &ListCollaboratorsOptions{
- ListOptions: ListOptions{Page: 2},
- Affiliation: "all",
- }
- users, _, err := client.Repositories.ListCollaborators(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Repositories.ListCollaborators returned error: %v", err)
- }
-
- want := []*User{{ID: Int64(1)}, {ID: Int64(2)}}
- if !reflect.DeepEqual(users, want) {
- t.Errorf("Repositories.ListCollaborators returned %+v, want %+v", users, want)
- }
-}
-
-func TestRepositoriesService_ListCollaborators_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.ListCollaborators(context.Background(), "%", "%", nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_IsCollaborator_True(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/collaborators/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNoContent)
- })
-
- isCollab, _, err := client.Repositories.IsCollaborator(context.Background(), "o", "r", "u")
- if err != nil {
- t.Errorf("Repositories.IsCollaborator returned error: %v", err)
- }
-
- if !isCollab {
- t.Errorf("Repositories.IsCollaborator returned false, want true")
- }
-}
-
-func TestRepositoriesService_IsCollaborator_False(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/collaborators/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNotFound)
- })
-
- isCollab, _, err := client.Repositories.IsCollaborator(context.Background(), "o", "r", "u")
- if err != nil {
- t.Errorf("Repositories.IsCollaborator returned error: %v", err)
- }
-
- if isCollab {
- t.Errorf("Repositories.IsCollaborator returned true, want false")
- }
-}
-
-func TestRepositoriesService_IsCollaborator_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.IsCollaborator(context.Background(), "%", "%", "%")
- testURLParseError(t, err)
-}
-
-func TestRepositoryService_GetPermissionLevel(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/collaborators/u/permission", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprintf(w, `{"permission":"admin","user":{"login":"u"}}`)
- })
-
- rpl, _, err := client.Repositories.GetPermissionLevel(context.Background(), "o", "r", "u")
- if err != nil {
- t.Errorf("Repositories.GetPermissionLevel returned error: %v", err)
- }
-
- want := &RepositoryPermissionLevel{
- Permission: String("admin"),
- User: &User{
- Login: String("u"),
- },
- }
-
- if !reflect.DeepEqual(rpl, want) {
- t.Errorf("Repositories.GetPermissionLevel returned %+v, want %+v", rpl, want)
- }
-}
-
-func TestRepositoriesService_AddCollaborator(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- opt := &RepositoryAddCollaboratorOptions{Permission: "admin"}
-
- mux.HandleFunc("/repos/o/r/collaborators/u", func(w http.ResponseWriter, r *http.Request) {
- v := new(RepositoryAddCollaboratorOptions)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PUT")
- testHeader(t, r, "Accept", mediaTypeRepositoryInvitationsPreview)
- if !reflect.DeepEqual(v, opt) {
- t.Errorf("Request body = %+v, want %+v", v, opt)
- }
-
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Repositories.AddCollaborator(context.Background(), "o", "r", "u", opt)
- if err != nil {
- t.Errorf("Repositories.AddCollaborator returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_AddCollaborator_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Repositories.AddCollaborator(context.Background(), "%", "%", "%", nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_RemoveCollaborator(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/collaborators/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Repositories.RemoveCollaborator(context.Background(), "o", "r", "u")
- if err != nil {
- t.Errorf("Repositories.RemoveCollaborator returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_RemoveCollaborator_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Repositories.RemoveCollaborator(context.Background(), "%", "%", "%")
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/repos_comments_test.go b/vendor/github.com/google/go-github/github/repos_comments_test.go
deleted file mode 100644
index 0eb54eba..00000000
--- a/vendor/github.com/google/go-github/github/repos_comments_test.go
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestRepositoriesService_ListComments(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/comments", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}, {"id":2}]`)
- })
-
- opt := &ListOptions{Page: 2}
- comments, _, err := client.Repositories.ListComments(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Repositories.ListComments returned error: %v", err)
- }
-
- want := []*RepositoryComment{{ID: Int64(1)}, {ID: Int64(2)}}
- if !reflect.DeepEqual(comments, want) {
- t.Errorf("Repositories.ListComments returned %+v, want %+v", comments, want)
- }
-}
-
-func TestRepositoriesService_ListComments_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.ListComments(context.Background(), "%", "%", nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_ListCommitComments(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/commits/s/comments", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}, {"id":2}]`)
- })
-
- opt := &ListOptions{Page: 2}
- comments, _, err := client.Repositories.ListCommitComments(context.Background(), "o", "r", "s", opt)
- if err != nil {
- t.Errorf("Repositories.ListCommitComments returned error: %v", err)
- }
-
- want := []*RepositoryComment{{ID: Int64(1)}, {ID: Int64(2)}}
- if !reflect.DeepEqual(comments, want) {
- t.Errorf("Repositories.ListCommitComments returned %+v, want %+v", comments, want)
- }
-}
-
-func TestRepositoriesService_ListCommitComments_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.ListCommitComments(context.Background(), "%", "%", "%", nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_CreateComment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &RepositoryComment{Body: String("b")}
-
- mux.HandleFunc("/repos/o/r/commits/s/comments", func(w http.ResponseWriter, r *http.Request) {
- v := new(RepositoryComment)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- comment, _, err := client.Repositories.CreateComment(context.Background(), "o", "r", "s", input)
- if err != nil {
- t.Errorf("Repositories.CreateComment returned error: %v", err)
- }
-
- want := &RepositoryComment{ID: Int64(1)}
- if !reflect.DeepEqual(comment, want) {
- t.Errorf("Repositories.CreateComment returned %+v, want %+v", comment, want)
- }
-}
-
-func TestRepositoriesService_CreateComment_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.CreateComment(context.Background(), "%", "%", "%", nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_GetComment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/comments/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeReactionsPreview)
- fmt.Fprint(w, `{"id":1}`)
- })
-
- comment, _, err := client.Repositories.GetComment(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Repositories.GetComment returned error: %v", err)
- }
-
- want := &RepositoryComment{ID: Int64(1)}
- if !reflect.DeepEqual(comment, want) {
- t.Errorf("Repositories.GetComment returned %+v, want %+v", comment, want)
- }
-}
-
-func TestRepositoriesService_GetComment_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.GetComment(context.Background(), "%", "%", 1)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_UpdateComment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &RepositoryComment{Body: String("b")}
-
- mux.HandleFunc("/repos/o/r/comments/1", func(w http.ResponseWriter, r *http.Request) {
- v := new(RepositoryComment)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- comment, _, err := client.Repositories.UpdateComment(context.Background(), "o", "r", 1, input)
- if err != nil {
- t.Errorf("Repositories.UpdateComment returned error: %v", err)
- }
-
- want := &RepositoryComment{ID: Int64(1)}
- if !reflect.DeepEqual(comment, want) {
- t.Errorf("Repositories.UpdateComment returned %+v, want %+v", comment, want)
- }
-}
-
-func TestRepositoriesService_UpdateComment_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.UpdateComment(context.Background(), "%", "%", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_DeleteComment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/comments/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Repositories.DeleteComment(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Repositories.DeleteComment returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_DeleteComment_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Repositories.DeleteComment(context.Background(), "%", "%", 1)
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/repos_commits_test.go b/vendor/github.com/google/go-github/github/repos_commits_test.go
deleted file mode 100644
index 3f7039da..00000000
--- a/vendor/github.com/google/go-github/github/repos_commits_test.go
+++ /dev/null
@@ -1,325 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "strings"
- "testing"
- "time"
-)
-
-func TestRepositoriesService_ListCommits(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- // given
- mux.HandleFunc("/repos/o/r/commits", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGitSigningPreview)
- testFormValues(t, r,
- values{
- "sha": "s",
- "path": "p",
- "author": "a",
- "since": "2013-08-01T00:00:00Z",
- "until": "2013-09-03T00:00:00Z",
- })
- fmt.Fprintf(w, `[{"sha": "s"}]`)
- })
-
- opt := &CommitsListOptions{
- SHA: "s",
- Path: "p",
- Author: "a",
- Since: time.Date(2013, time.August, 1, 0, 0, 0, 0, time.UTC),
- Until: time.Date(2013, time.September, 3, 0, 0, 0, 0, time.UTC),
- }
- commits, _, err := client.Repositories.ListCommits(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Repositories.ListCommits returned error: %v", err)
- }
-
- want := []*RepositoryCommit{{SHA: String("s")}}
- if !reflect.DeepEqual(commits, want) {
- t.Errorf("Repositories.ListCommits returned %+v, want %+v", commits, want)
- }
-}
-
-func TestRepositoriesService_GetCommit(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/commits/s", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGitSigningPreview)
- fmt.Fprintf(w, `{
- "sha": "s",
- "commit": { "message": "m" },
- "author": { "login": "l" },
- "committer": { "login": "l" },
- "parents": [ { "sha": "s" } ],
- "stats": { "additions": 104, "deletions": 4, "total": 108 },
- "files": [
- {
- "filename": "f",
- "additions": 10,
- "deletions": 2,
- "changes": 12,
- "status": "s",
- "patch": "p",
- "blob_url": "b",
- "raw_url": "r",
- "contents_url": "c"
- }
- ]
- }`)
- })
-
- commit, _, err := client.Repositories.GetCommit(context.Background(), "o", "r", "s")
- if err != nil {
- t.Errorf("Repositories.GetCommit returned error: %v", err)
- }
-
- want := &RepositoryCommit{
- SHA: String("s"),
- Commit: &Commit{
- Message: String("m"),
- },
- Author: &User{
- Login: String("l"),
- },
- Committer: &User{
- Login: String("l"),
- },
- Parents: []Commit{
- {
- SHA: String("s"),
- },
- },
- Stats: &CommitStats{
- Additions: Int(104),
- Deletions: Int(4),
- Total: Int(108),
- },
- Files: []CommitFile{
- {
- Filename: String("f"),
- Additions: Int(10),
- Deletions: Int(2),
- Changes: Int(12),
- Status: String("s"),
- Patch: String("p"),
- BlobURL: String("b"),
- RawURL: String("r"),
- ContentsURL: String("c"),
- },
- },
- }
- if !reflect.DeepEqual(commit, want) {
- t.Errorf("Repositories.GetCommit returned \n%+v, want \n%+v", commit, want)
- }
-}
-
-func TestRepositoriesService_GetCommitRaw_diff(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- const rawStr = "@@diff content"
-
- mux.HandleFunc("/repos/o/r/commits/s", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeV3Diff)
- fmt.Fprint(w, rawStr)
- })
-
- got, _, err := client.Repositories.GetCommitRaw(context.Background(), "o", "r", "s", RawOptions{Type: Diff})
- if err != nil {
- t.Fatalf("Repositories.GetCommitRaw returned error: %v", err)
- }
- want := rawStr
- if got != want {
- t.Errorf("Repositories.GetCommitRaw returned %s want %s", got, want)
- }
-}
-
-func TestRepositoriesService_GetCommitRaw_patch(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- const rawStr = "@@patch content"
-
- mux.HandleFunc("/repos/o/r/commits/s", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeV3Patch)
- fmt.Fprint(w, rawStr)
- })
-
- got, _, err := client.Repositories.GetCommitRaw(context.Background(), "o", "r", "s", RawOptions{Type: Patch})
- if err != nil {
- t.Fatalf("Repositories.GetCommitRaw returned error: %v", err)
- }
- want := rawStr
- if got != want {
- t.Errorf("Repositories.GetCommitRaw returned %s want %s", got, want)
- }
-}
-
-func TestRepositoriesService_GetCommitRaw_invalid(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.GetCommitRaw(context.Background(), "o", "r", "s", RawOptions{100})
- if err == nil {
- t.Fatal("Repositories.GetCommitRaw should return error")
- }
- if !strings.Contains(err.Error(), "unsupported raw type") {
- t.Error("Repositories.GetCommitRaw should return unsupported raw type error")
- }
-}
-
-func TestRepositoriesService_GetCommitSHA1(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
- const sha1 = "01234abcde"
-
- mux.HandleFunc("/repos/o/r/commits/master", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeV3SHA)
-
- fmt.Fprintf(w, sha1)
- })
-
- got, _, err := client.Repositories.GetCommitSHA1(context.Background(), "o", "r", "master", "")
- if err != nil {
- t.Errorf("Repositories.GetCommitSHA1 returned error: %v", err)
- }
-
- want := sha1
- if got != want {
- t.Errorf("Repositories.GetCommitSHA1 = %v, want %v", got, want)
- }
-
- mux.HandleFunc("/repos/o/r/commits/tag", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeV3SHA)
- testHeader(t, r, "If-None-Match", `"`+sha1+`"`)
-
- w.WriteHeader(http.StatusNotModified)
- })
-
- got, _, err = client.Repositories.GetCommitSHA1(context.Background(), "o", "r", "tag", sha1)
- if err == nil {
- t.Errorf("Expected HTTP 304 response")
- }
-
- want = ""
- if got != want {
- t.Errorf("Repositories.GetCommitSHA1 = %v, want %v", got, want)
- }
-}
-
-func TestRepositoriesService_CompareCommits(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/compare/b...h", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprintf(w, `{
- "base_commit": {
- "sha": "s",
- "commit": {
- "author": { "name": "n" },
- "committer": { "name": "n" },
- "message": "m",
- "tree": { "sha": "t" }
- },
- "author": { "login": "l" },
- "committer": { "login": "l" },
- "parents": [ { "sha": "s" } ]
- },
- "status": "s",
- "ahead_by": 1,
- "behind_by": 2,
- "total_commits": 1,
- "commits": [
- {
- "sha": "s",
- "commit": { "author": { "name": "n" } },
- "author": { "login": "l" },
- "committer": { "login": "l" },
- "parents": [ { "sha": "s" } ]
- }
- ],
- "files": [ { "filename": "f" } ],
- "html_url": "https://github.com/o/r/compare/b...h",
- "permalink_url": "https://github.com/o/r/compare/o:bbcd538c8e72b8c175046e27cc8f907076331401...o:0328041d1152db8ae77652d1618a02e57f745f17",
- "diff_url": "https://github.com/o/r/compare/b...h.diff",
- "patch_url": "https://github.com/o/r/compare/b...h.patch",
- "url": "https://api.github.com/repos/o/r/compare/b...h"
- }`)
- })
-
- got, _, err := client.Repositories.CompareCommits(context.Background(), "o", "r", "b", "h")
- if err != nil {
- t.Errorf("Repositories.CompareCommits returned error: %v", err)
- }
-
- want := &CommitsComparison{
- BaseCommit: &RepositoryCommit{
- SHA: String("s"),
- Commit: &Commit{
- Author: &CommitAuthor{Name: String("n")},
- Committer: &CommitAuthor{Name: String("n")},
- Message: String("m"),
- Tree: &Tree{SHA: String("t")},
- },
- Author: &User{Login: String("l")},
- Committer: &User{Login: String("l")},
- Parents: []Commit{
- {
- SHA: String("s"),
- },
- },
- },
- Status: String("s"),
- AheadBy: Int(1),
- BehindBy: Int(2),
- TotalCommits: Int(1),
- Commits: []RepositoryCommit{
- {
- SHA: String("s"),
- Commit: &Commit{
- Author: &CommitAuthor{Name: String("n")},
- },
- Author: &User{Login: String("l")},
- Committer: &User{Login: String("l")},
- Parents: []Commit{
- {
- SHA: String("s"),
- },
- },
- },
- },
- Files: []CommitFile{
- {
- Filename: String("f"),
- },
- },
- HTMLURL: String("https://github.com/o/r/compare/b...h"),
- PermalinkURL: String("https://github.com/o/r/compare/o:bbcd538c8e72b8c175046e27cc8f907076331401...o:0328041d1152db8ae77652d1618a02e57f745f17"),
- DiffURL: String("https://github.com/o/r/compare/b...h.diff"),
- PatchURL: String("https://github.com/o/r/compare/b...h.patch"),
- URL: String("https://api.github.com/repos/o/r/compare/b...h"),
- }
-
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Repositories.CompareCommits returned \n%+v, want \n%+v", got, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/repos_community_health_test.go b/vendor/github.com/google/go-github/github/repos_community_health_test.go
deleted file mode 100644
index c9499aa1..00000000
--- a/vendor/github.com/google/go-github/github/repos_community_health_test.go
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright 2017 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
- "time"
-)
-
-func TestRepositoriesService_GetCommunityHealthMetrics(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/community/profile", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeRepositoryCommunityHealthMetricsPreview)
- fmt.Fprintf(w, `{
- "health_percentage": 100,
- "files": {
- "code_of_conduct": {
- "name": "Contributor Covenant",
- "key": "contributor_covenant",
- "url": null,
- "html_url": "https://github.com/octocat/Hello-World/blob/master/CODE_OF_CONDUCT.md"
- },
- "contributing": {
- "url": "https://api.github.com/repos/octocat/Hello-World/contents/CONTRIBUTING",
- "html_url": "https://github.com/octocat/Hello-World/blob/master/CONTRIBUTING"
- },
- "license": {
- "name": "MIT License",
- "key": "mit",
- "url": "https://api.github.com/licenses/mit",
- "html_url": "https://github.com/octocat/Hello-World/blob/master/LICENSE"
- },
- "readme": {
- "url": "https://api.github.com/repos/octocat/Hello-World/contents/README.md",
- "html_url": "https://github.com/octocat/Hello-World/blob/master/README.md"
- }
- },
- "updated_at": "2017-02-28T00:00:00Z"
- }`)
- })
-
- got, _, err := client.Repositories.GetCommunityHealthMetrics(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Repositories.GetCommunityHealthMetrics returned error: %v", err)
- }
-
- updatedAt := time.Date(2017, 02, 28, 0, 0, 0, 0, time.UTC)
- want := &CommunityHealthMetrics{
- HealthPercentage: Int(100),
- UpdatedAt: &updatedAt,
- Files: &CommunityHealthFiles{
- CodeOfConduct: &Metric{
- Name: String("Contributor Covenant"),
- Key: String("contributor_covenant"),
- HTMLURL: String("https://github.com/octocat/Hello-World/blob/master/CODE_OF_CONDUCT.md"),
- },
- Contributing: &Metric{
- URL: String("https://api.github.com/repos/octocat/Hello-World/contents/CONTRIBUTING"),
- HTMLURL: String("https://github.com/octocat/Hello-World/blob/master/CONTRIBUTING"),
- },
- License: &Metric{
- Name: String("MIT License"),
- Key: String("mit"),
- URL: String("https://api.github.com/licenses/mit"),
- HTMLURL: String("https://github.com/octocat/Hello-World/blob/master/LICENSE"),
- },
- Readme: &Metric{
- URL: String("https://api.github.com/repos/octocat/Hello-World/contents/README.md"),
- HTMLURL: String("https://github.com/octocat/Hello-World/blob/master/README.md"),
- },
- },
- }
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Repositories.GetCommunityHealthMetrics:\ngot:\n%v\nwant:\n%v", Stringify(got), Stringify(want))
- }
-}
diff --git a/vendor/github.com/google/go-github/github/repos_contents_test.go b/vendor/github.com/google/go-github/github/repos_contents_test.go
deleted file mode 100644
index 0a08e8c7..00000000
--- a/vendor/github.com/google/go-github/github/repos_contents_test.go
+++ /dev/null
@@ -1,378 +0,0 @@
-// Copyright 2014 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
-
-import (
- "context"
- "fmt"
- "io/ioutil"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestRepositoryContent_GetContent(t *testing.T) {
- tests := []struct {
- encoding, content *string // input encoding and content
- want string // desired output
- wantErr bool // whether an error is expected
- }{
- {
- encoding: String(""),
- content: String("hello"),
- want: "hello",
- wantErr: false,
- },
- {
- encoding: nil,
- content: String("hello"),
- want: "hello",
- wantErr: false,
- },
- {
- encoding: nil,
- content: nil,
- want: "",
- wantErr: false,
- },
- {
- encoding: String("base64"),
- content: String("aGVsbG8="),
- want: "hello",
- wantErr: false,
- },
- {
- encoding: String("bad"),
- content: String("aGVsbG8="),
- want: "",
- wantErr: true,
- },
- }
-
- for _, tt := range tests {
- r := RepositoryContent{Encoding: tt.encoding, Content: tt.content}
- got, err := r.GetContent()
- if err != nil && !tt.wantErr {
- t.Errorf("RepositoryContent(%q, %q) returned unexpected error: %v", tt.encoding, tt.content, err)
- }
- if err == nil && tt.wantErr {
- t.Errorf("RepositoryContent(%q, %q) did not return unexpected error", tt.encoding, tt.content)
- }
- if want := tt.want; got != want {
- t.Errorf("RepositoryContent.GetContent returned %+v, want %+v", got, want)
- }
- }
-}
-
-func TestRepositoriesService_GetReadme(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
- mux.HandleFunc("/repos/o/r/readme", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{
- "type": "file",
- "encoding": "base64",
- "size": 5362,
- "name": "README.md",
- "path": "README.md"
- }`)
- })
- readme, _, err := client.Repositories.GetReadme(context.Background(), "o", "r", &RepositoryContentGetOptions{})
- if err != nil {
- t.Errorf("Repositories.GetReadme returned error: %v", err)
- }
- want := &RepositoryContent{Type: String("file"), Name: String("README.md"), Size: Int(5362), Encoding: String("base64"), Path: String("README.md")}
- if !reflect.DeepEqual(readme, want) {
- t.Errorf("Repositories.GetReadme returned %+v, want %+v", readme, want)
- }
-}
-
-func TestRepositoriesService_DownloadContents_Success(t *testing.T) {
- client, mux, serverURL, teardown := setup()
- defer teardown()
- mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `[{
- "type": "file",
- "name": "f",
- "download_url": "`+serverURL+baseURLPath+`/download/f"
- }]`)
- })
- mux.HandleFunc("/download/f", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, "foo")
- })
-
- r, err := client.Repositories.DownloadContents(context.Background(), "o", "r", "d/f", nil)
- if err != nil {
- t.Errorf("Repositories.DownloadContents returned error: %v", err)
- }
-
- bytes, err := ioutil.ReadAll(r)
- if err != nil {
- t.Errorf("Error reading response body: %v", err)
- }
- r.Close()
-
- if got, want := string(bytes), "foo"; got != want {
- t.Errorf("Repositories.DownloadContents returned %v, want %v", got, want)
- }
-}
-
-func TestRepositoriesService_DownloadContents_NoDownloadURL(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
- mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `[{
- "type": "file",
- "name": "f",
- }]`)
- })
-
- _, err := client.Repositories.DownloadContents(context.Background(), "o", "r", "d/f", nil)
- if err == nil {
- t.Errorf("Repositories.DownloadContents did not return expected error")
- }
-}
-
-func TestRepositoriesService_DownloadContents_NoFile(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
- mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `[]`)
- })
-
- _, err := client.Repositories.DownloadContents(context.Background(), "o", "r", "d/f", nil)
- if err == nil {
- t.Errorf("Repositories.DownloadContents did not return expected error")
- }
-}
-
-func TestRepositoriesService_GetContents_File(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
- mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{
- "type": "file",
- "encoding": "base64",
- "size": 20678,
- "name": "LICENSE",
- "path": "LICENSE"
- }`)
- })
- fileContents, _, _, err := client.Repositories.GetContents(context.Background(), "o", "r", "p", &RepositoryContentGetOptions{})
- if err != nil {
- t.Errorf("Repositories.GetContents returned error: %v", err)
- }
- want := &RepositoryContent{Type: String("file"), Name: String("LICENSE"), Size: Int(20678), Encoding: String("base64"), Path: String("LICENSE")}
- if !reflect.DeepEqual(fileContents, want) {
- t.Errorf("Repositories.GetContents returned %+v, want %+v", fileContents, want)
- }
-}
-
-func TestRepositoriesService_GetContents_FilenameNeedsEscape(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
- mux.HandleFunc("/repos/o/r/contents/p#?%/ä¸.go", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{}`)
- })
- _, _, _, err := client.Repositories.GetContents(context.Background(), "o", "r", "p#?%/ä¸.go", &RepositoryContentGetOptions{})
- if err != nil {
- t.Fatalf("Repositories.GetContents returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_GetContents_DirectoryWithSpaces(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
- mux.HandleFunc("/repos/o/r/contents/some directory/file.go", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{}`)
- })
- _, _, _, err := client.Repositories.GetContents(context.Background(), "o", "r", "some directory/file.go", &RepositoryContentGetOptions{})
- if err != nil {
- t.Fatalf("Repositories.GetContents returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_GetContents_DirectoryWithPlusChars(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
- mux.HandleFunc("/repos/o/r/contents/some directory+name/file.go", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{}`)
- })
- _, _, _, err := client.Repositories.GetContents(context.Background(), "o", "r", "some directory+name/file.go", &RepositoryContentGetOptions{})
- if err != nil {
- t.Fatalf("Repositories.GetContents returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_GetContents_Directory(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
- mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `[{
- "type": "dir",
- "name": "lib",
- "path": "lib"
- },
- {
- "type": "file",
- "size": 20678,
- "name": "LICENSE",
- "path": "LICENSE"
- }]`)
- })
- _, directoryContents, _, err := client.Repositories.GetContents(context.Background(), "o", "r", "p", &RepositoryContentGetOptions{})
- if err != nil {
- t.Errorf("Repositories.GetContents returned error: %v", err)
- }
- want := []*RepositoryContent{{Type: String("dir"), Name: String("lib"), Path: String("lib")},
- {Type: String("file"), Name: String("LICENSE"), Size: Int(20678), Path: String("LICENSE")}}
- if !reflect.DeepEqual(directoryContents, want) {
- t.Errorf("Repositories.GetContents_Directory returned %+v, want %+v", directoryContents, want)
- }
-}
-
-func TestRepositoriesService_CreateFile(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
- mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- fmt.Fprint(w, `{
- "content":{
- "name":"p"
- },
- "commit":{
- "message":"m",
- "sha":"f5f369044773ff9c6383c087466d12adb6fa0828"
- }
- }`)
- })
- message := "m"
- content := []byte("c")
- repositoryContentsOptions := &RepositoryContentFileOptions{
- Message: &message,
- Content: content,
- Committer: &CommitAuthor{Name: String("n"), Email: String("e")},
- }
- createResponse, _, err := client.Repositories.CreateFile(context.Background(), "o", "r", "p", repositoryContentsOptions)
- if err != nil {
- t.Errorf("Repositories.CreateFile returned error: %v", err)
- }
- want := &RepositoryContentResponse{
- Content: &RepositoryContent{Name: String("p")},
- Commit: Commit{
- Message: String("m"),
- SHA: String("f5f369044773ff9c6383c087466d12adb6fa0828"),
- },
- }
- if !reflect.DeepEqual(createResponse, want) {
- t.Errorf("Repositories.CreateFile returned %+v, want %+v", createResponse, want)
- }
-}
-
-func TestRepositoriesService_UpdateFile(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
- mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- fmt.Fprint(w, `{
- "content":{
- "name":"p"
- },
- "commit":{
- "message":"m",
- "sha":"f5f369044773ff9c6383c087466d12adb6fa0828"
- }
- }`)
- })
- message := "m"
- content := []byte("c")
- sha := "f5f369044773ff9c6383c087466d12adb6fa0828"
- repositoryContentsOptions := &RepositoryContentFileOptions{
- Message: &message,
- Content: content,
- SHA: &sha,
- Committer: &CommitAuthor{Name: String("n"), Email: String("e")},
- }
- updateResponse, _, err := client.Repositories.UpdateFile(context.Background(), "o", "r", "p", repositoryContentsOptions)
- if err != nil {
- t.Errorf("Repositories.UpdateFile returned error: %v", err)
- }
- want := &RepositoryContentResponse{
- Content: &RepositoryContent{Name: String("p")},
- Commit: Commit{
- Message: String("m"),
- SHA: String("f5f369044773ff9c6383c087466d12adb6fa0828"),
- },
- }
- if !reflect.DeepEqual(updateResponse, want) {
- t.Errorf("Repositories.UpdateFile returned %+v, want %+v", updateResponse, want)
- }
-}
-
-func TestRepositoriesService_DeleteFile(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
- mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- fmt.Fprint(w, `{
- "content": null,
- "commit":{
- "message":"m",
- "sha":"f5f369044773ff9c6383c087466d12adb6fa0828"
- }
- }`)
- })
- message := "m"
- sha := "f5f369044773ff9c6383c087466d12adb6fa0828"
- repositoryContentsOptions := &RepositoryContentFileOptions{
- Message: &message,
- SHA: &sha,
- Committer: &CommitAuthor{Name: String("n"), Email: String("e")},
- }
- deleteResponse, _, err := client.Repositories.DeleteFile(context.Background(), "o", "r", "p", repositoryContentsOptions)
- if err != nil {
- t.Errorf("Repositories.DeleteFile returned error: %v", err)
- }
- want := &RepositoryContentResponse{
- Content: nil,
- Commit: Commit{
- Message: String("m"),
- SHA: String("f5f369044773ff9c6383c087466d12adb6fa0828"),
- },
- }
- if !reflect.DeepEqual(deleteResponse, want) {
- t.Errorf("Repositories.DeleteFile returned %+v, want %+v", deleteResponse, want)
- }
-}
-
-func TestRepositoriesService_GetArchiveLink(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
- mux.HandleFunc("/repos/o/r/tarball", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- http.Redirect(w, r, "http://github.com/a", http.StatusFound)
- })
- url, resp, err := client.Repositories.GetArchiveLink(context.Background(), "o", "r", Tarball, &RepositoryContentGetOptions{})
- if err != nil {
- t.Errorf("Repositories.GetArchiveLink returned error: %v", err)
- }
- if resp.StatusCode != http.StatusFound {
- t.Errorf("Repositories.GetArchiveLink returned status: %d, want %d", resp.StatusCode, http.StatusFound)
- }
- want := "http://github.com/a"
- if url.String() != want {
- t.Errorf("Repositories.GetArchiveLink returned %+v, want %+v", url.String(), want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/repos_deployments_test.go b/vendor/github.com/google/go-github/github/repos_deployments_test.go
deleted file mode 100644
index b1e5ec6f..00000000
--- a/vendor/github.com/google/go-github/github/repos_deployments_test.go
+++ /dev/null
@@ -1,168 +0,0 @@
-// Copyright 2014 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "strings"
- "testing"
-)
-
-func TestRepositoriesService_ListDeployments(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/deployments", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testFormValues(t, r, values{"environment": "test"})
- fmt.Fprint(w, `[{"id":1}, {"id":2}]`)
- })
-
- opt := &DeploymentsListOptions{Environment: "test"}
- deployments, _, err := client.Repositories.ListDeployments(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Repositories.ListDeployments returned error: %v", err)
- }
-
- want := []*Deployment{{ID: Int64(1)}, {ID: Int64(2)}}
- if !reflect.DeepEqual(deployments, want) {
- t.Errorf("Repositories.ListDeployments returned %+v, want %+v", deployments, want)
- }
-}
-
-func TestRepositoriesService_GetDeployment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/deployments/3", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- fmt.Fprint(w, `{"id":3}`)
- })
-
- deployment, _, err := client.Repositories.GetDeployment(context.Background(), "o", "r", 3)
- if err != nil {
- t.Errorf("Repositories.GetDeployment returned error: %v", err)
- }
-
- want := &Deployment{ID: Int64(3)}
-
- if !reflect.DeepEqual(deployment, want) {
- t.Errorf("Repositories.GetDeployment returned %+v, want %+v", deployment, want)
- }
-}
-
-func TestRepositoriesService_CreateDeployment(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &DeploymentRequest{Ref: String("1111"), Task: String("deploy"), TransientEnvironment: Bool(true)}
-
- acceptHeaders := []string{mediaTypeDeploymentStatusPreview, mediaTypeGraphQLNodeIDPreview}
- mux.HandleFunc("/repos/o/r/deployments", func(w http.ResponseWriter, r *http.Request) {
- v := new(DeploymentRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"ref": "1111", "task": "deploy"}`)
- })
-
- deployment, _, err := client.Repositories.CreateDeployment(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("Repositories.CreateDeployment returned error: %v", err)
- }
-
- want := &Deployment{Ref: String("1111"), Task: String("deploy")}
- if !reflect.DeepEqual(deployment, want) {
- t.Errorf("Repositories.CreateDeployment returned %+v, want %+v", deployment, want)
- }
-}
-
-func TestRepositoriesService_ListDeploymentStatuses(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/deployments/1/statuses", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGraphQLNodeIDPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}, {"id":2}]`)
- })
-
- opt := &ListOptions{Page: 2}
- statutses, _, err := client.Repositories.ListDeploymentStatuses(context.Background(), "o", "r", 1, opt)
- if err != nil {
- t.Errorf("Repositories.ListDeploymentStatuses returned error: %v", err)
- }
-
- want := []*DeploymentStatus{{ID: Int64(1)}, {ID: Int64(2)}}
- if !reflect.DeepEqual(statutses, want) {
- t.Errorf("Repositories.ListDeploymentStatuses returned %+v, want %+v", statutses, want)
- }
-}
-
-func TestRepositoriesService_GetDeploymentStatus(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- acceptHeaders := []string{mediaTypeDeploymentStatusPreview, mediaTypeGraphQLNodeIDPreview}
- mux.HandleFunc("/repos/o/r/deployments/3/statuses/4", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
- fmt.Fprint(w, `{"id":4}`)
- })
-
- deploymentStatus, _, err := client.Repositories.GetDeploymentStatus(context.Background(), "o", "r", 3, 4)
- if err != nil {
- t.Errorf("Repositories.GetDeploymentStatus returned error: %v", err)
- }
-
- want := &DeploymentStatus{ID: Int64(4)}
- if !reflect.DeepEqual(deploymentStatus, want) {
- t.Errorf("Repositories.GetDeploymentStatus returned %+v, want %+v", deploymentStatus, want)
- }
-}
-
-func TestRepositoriesService_CreateDeploymentStatus(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &DeploymentStatusRequest{State: String("inactive"), Description: String("deploy"), AutoInactive: Bool(false)}
-
- acceptHeaders := []string{mediaTypeDeploymentStatusPreview, mediaTypeGraphQLNodeIDPreview}
- mux.HandleFunc("/repos/o/r/deployments/1/statuses", func(w http.ResponseWriter, r *http.Request) {
- v := new(DeploymentStatusRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"state": "inactive", "description": "deploy"}`)
- })
-
- deploymentStatus, _, err := client.Repositories.CreateDeploymentStatus(context.Background(), "o", "r", 1, input)
- if err != nil {
- t.Errorf("Repositories.CreateDeploymentStatus returned error: %v", err)
- }
-
- want := &DeploymentStatus{State: String("inactive"), Description: String("deploy")}
- if !reflect.DeepEqual(deploymentStatus, want) {
- t.Errorf("Repositories.CreateDeploymentStatus returned %+v, want %+v", deploymentStatus, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/repos_forks_test.go b/vendor/github.com/google/go-github/github/repos_forks_test.go
deleted file mode 100644
index 8513f0e2..00000000
--- a/vendor/github.com/google/go-github/github/repos_forks_test.go
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestRepositoriesService_ListForks(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeTopicsPreview)
- testFormValues(t, r, values{
- "sort": "newest",
- "page": "3",
- })
- fmt.Fprint(w, `[{"id":1},{"id":2}]`)
- })
-
- opt := &RepositoryListForksOptions{
- Sort: "newest",
- ListOptions: ListOptions{Page: 3},
- }
- repos, _, err := client.Repositories.ListForks(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Repositories.ListForks returned error: %v", err)
- }
-
- want := []*Repository{{ID: Int64(1)}, {ID: Int64(2)}}
- if !reflect.DeepEqual(repos, want) {
- t.Errorf("Repositories.ListForks returned %+v, want %+v", repos, want)
- }
-}
-
-func TestRepositoriesService_ListForks_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.ListForks(context.Background(), "%", "r", nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_CreateFork(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testFormValues(t, r, values{"organization": "o"})
- fmt.Fprint(w, `{"id":1}`)
- })
-
- opt := &RepositoryCreateForkOptions{Organization: "o"}
- repo, _, err := client.Repositories.CreateFork(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Repositories.CreateFork returned error: %v", err)
- }
-
- want := &Repository{ID: Int64(1)}
- if !reflect.DeepEqual(repo, want) {
- t.Errorf("Repositories.CreateFork returned %+v, want %+v", repo, want)
- }
-}
-
-func TestRepositoriesService_CreateFork_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.CreateFork(context.Background(), "%", "r", nil)
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/repos_hooks_test.go b/vendor/github.com/google/go-github/github/repos_hooks_test.go
deleted file mode 100644
index a1435619..00000000
--- a/vendor/github.com/google/go-github/github/repos_hooks_test.go
+++ /dev/null
@@ -1,206 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestRepositoriesService_CreateHook(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Hook{Name: String("t")}
-
- mux.HandleFunc("/repos/o/r/hooks", func(w http.ResponseWriter, r *http.Request) {
- v := new(Hook)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- hook, _, err := client.Repositories.CreateHook(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("Repositories.CreateHook returned error: %v", err)
- }
-
- want := &Hook{ID: Int64(1)}
- if !reflect.DeepEqual(hook, want) {
- t.Errorf("Repositories.CreateHook returned %+v, want %+v", hook, want)
- }
-}
-
-func TestRepositoriesService_CreateHook_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.CreateHook(context.Background(), "%", "%", nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_ListHooks(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/hooks", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}, {"id":2}]`)
- })
-
- opt := &ListOptions{Page: 2}
-
- hooks, _, err := client.Repositories.ListHooks(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Repositories.ListHooks returned error: %v", err)
- }
-
- want := []*Hook{{ID: Int64(1)}, {ID: Int64(2)}}
- if !reflect.DeepEqual(hooks, want) {
- t.Errorf("Repositories.ListHooks returned %+v, want %+v", hooks, want)
- }
-}
-
-func TestRepositoriesService_ListHooks_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.ListHooks(context.Background(), "%", "%", nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_GetHook(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/hooks/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id":1}`)
- })
-
- hook, _, err := client.Repositories.GetHook(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Repositories.GetHook returned error: %v", err)
- }
-
- want := &Hook{ID: Int64(1)}
- if !reflect.DeepEqual(hook, want) {
- t.Errorf("Repositories.GetHook returned %+v, want %+v", hook, want)
- }
-}
-
-func TestRepositoriesService_GetHook_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.GetHook(context.Background(), "%", "%", 1)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_EditHook(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Hook{Name: String("t")}
-
- mux.HandleFunc("/repos/o/r/hooks/1", func(w http.ResponseWriter, r *http.Request) {
- v := new(Hook)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- hook, _, err := client.Repositories.EditHook(context.Background(), "o", "r", 1, input)
- if err != nil {
- t.Errorf("Repositories.EditHook returned error: %v", err)
- }
-
- want := &Hook{ID: Int64(1)}
- if !reflect.DeepEqual(hook, want) {
- t.Errorf("Repositories.EditHook returned %+v, want %+v", hook, want)
- }
-}
-
-func TestRepositoriesService_EditHook_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.EditHook(context.Background(), "%", "%", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_DeleteHook(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/hooks/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Repositories.DeleteHook(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Repositories.DeleteHook returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_DeleteHook_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Repositories.DeleteHook(context.Background(), "%", "%", 1)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_PingHook(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/hooks/1/pings", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- })
-
- _, err := client.Repositories.PingHook(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Repositories.PingHook returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_TestHook(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/hooks/1/tests", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- })
-
- _, err := client.Repositories.TestHook(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Repositories.TestHook returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_TestHook_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Repositories.TestHook(context.Background(), "%", "%", 1)
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/repos_invitations_test.go b/vendor/github.com/google/go-github/github/repos_invitations_test.go
deleted file mode 100644
index 27bec41d..00000000
--- a/vendor/github.com/google/go-github/github/repos_invitations_test.go
+++ /dev/null
@@ -1,74 +0,0 @@
-// 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestRepositoriesService_ListInvitations(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/invitations", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeRepositoryInvitationsPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprintf(w, `[{"id":1}, {"id":2}]`)
- })
-
- opt := &ListOptions{Page: 2}
- got, _, err := client.Repositories.ListInvitations(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Repositories.ListInvitations returned error: %v", err)
- }
-
- want := []*RepositoryInvitation{{ID: Int64(1)}, {ID: Int64(2)}}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Repositories.ListInvitations = %+v, want %+v", got, want)
- }
-}
-
-func TestRepositoriesService_DeleteInvitation(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/invitations/2", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeRepositoryInvitationsPreview)
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Repositories.DeleteInvitation(context.Background(), "o", "r", 2)
- if err != nil {
- t.Errorf("Repositories.DeleteInvitation returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_UpdateInvitation(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/invitations/2", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PATCH")
- testHeader(t, r, "Accept", mediaTypeRepositoryInvitationsPreview)
- fmt.Fprintf(w, `{"id":1}`)
- })
-
- got, _, err := client.Repositories.UpdateInvitation(context.Background(), "o", "r", 2, "write")
- if err != nil {
- t.Errorf("Repositories.UpdateInvitation returned error: %v", err)
- }
-
- want := &RepositoryInvitation{ID: Int64(1)}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Repositories.UpdateInvitation = %+v, want %+v", got, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/repos_keys_test.go b/vendor/github.com/google/go-github/github/repos_keys_test.go
deleted file mode 100644
index 75a17356..00000000
--- a/vendor/github.com/google/go-github/github/repos_keys_test.go
+++ /dev/null
@@ -1,169 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestRepositoriesService_ListKeys(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/keys", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 2}
- keys, _, err := client.Repositories.ListKeys(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Repositories.ListKeys returned error: %v", err)
- }
-
- want := []*Key{{ID: Int64(1)}}
- if !reflect.DeepEqual(keys, want) {
- t.Errorf("Repositories.ListKeys returned %+v, want %+v", keys, want)
- }
-}
-
-func TestRepositoriesService_ListKeys_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.ListKeys(context.Background(), "%", "%", nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_GetKey(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/keys/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id":1}`)
- })
-
- key, _, err := client.Repositories.GetKey(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Repositories.GetKey returned error: %v", err)
- }
-
- want := &Key{ID: Int64(1)}
- if !reflect.DeepEqual(key, want) {
- t.Errorf("Repositories.GetKey returned %+v, want %+v", key, want)
- }
-}
-
-func TestRepositoriesService_GetKey_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.GetKey(context.Background(), "%", "%", 1)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_CreateKey(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Key{Key: String("k"), Title: String("t")}
-
- mux.HandleFunc("/repos/o/r/keys", func(w http.ResponseWriter, r *http.Request) {
- v := new(Key)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- key, _, err := client.Repositories.CreateKey(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("Repositories.GetKey returned error: %v", err)
- }
-
- want := &Key{ID: Int64(1)}
- if !reflect.DeepEqual(key, want) {
- t.Errorf("Repositories.GetKey returned %+v, want %+v", key, want)
- }
-}
-
-func TestRepositoriesService_CreateKey_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.CreateKey(context.Background(), "%", "%", nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_EditKey(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Key{Key: String("k"), Title: String("t")}
-
- mux.HandleFunc("/repos/o/r/keys/1", func(w http.ResponseWriter, r *http.Request) {
- v := new(Key)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- key, _, err := client.Repositories.EditKey(context.Background(), "o", "r", 1, input)
- if err != nil {
- t.Errorf("Repositories.EditKey returned error: %v", err)
- }
-
- want := &Key{ID: Int64(1)}
- if !reflect.DeepEqual(key, want) {
- t.Errorf("Repositories.EditKey returned %+v, want %+v", key, want)
- }
-}
-
-func TestRepositoriesService_EditKey_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.EditKey(context.Background(), "%", "%", 1, nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_DeleteKey(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/keys/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Repositories.DeleteKey(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Repositories.DeleteKey returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_DeleteKey_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Repositories.DeleteKey(context.Background(), "%", "%", 1)
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/repos_merging_test.go b/vendor/github.com/google/go-github/github/repos_merging_test.go
deleted file mode 100644
index 086f24bb..00000000
--- a/vendor/github.com/google/go-github/github/repos_merging_test.go
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2014 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestRepositoriesService_Merge(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &RepositoryMergeRequest{
- Base: String("b"),
- Head: String("h"),
- CommitMessage: String("c"),
- }
-
- mux.HandleFunc("/repos/o/r/merges", func(w http.ResponseWriter, r *http.Request) {
- v := new(RepositoryMergeRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"sha":"s"}`)
- })
-
- commit, _, err := client.Repositories.Merge(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("Repositories.Merge returned error: %v", err)
- }
-
- want := &RepositoryCommit{SHA: String("s")}
- if !reflect.DeepEqual(commit, want) {
- t.Errorf("Repositories.Merge returned %+v, want %+v", commit, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/repos_pages_test.go b/vendor/github.com/google/go-github/github/repos_pages_test.go
deleted file mode 100644
index 21a00f9d..00000000
--- a/vendor/github.com/google/go-github/github/repos_pages_test.go
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright 2014 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestRepositoriesService_GetPagesInfo(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pages", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypePagesPreview)
- fmt.Fprint(w, `{"url":"u","status":"s","cname":"c","custom_404":false,"html_url":"h"}`)
- })
-
- page, _, err := client.Repositories.GetPagesInfo(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Repositories.GetPagesInfo returned error: %v", err)
- }
-
- want := &Pages{URL: String("u"), Status: String("s"), CNAME: String("c"), Custom404: Bool(false), HTMLURL: String("h")}
- if !reflect.DeepEqual(page, want) {
- t.Errorf("Repositories.GetPagesInfo returned %+v, want %+v", page, want)
- }
-}
-
-func TestRepositoriesService_ListPagesBuilds(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pages/builds", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `[{"url":"u","status":"s","commit":"c"}]`)
- })
-
- pages, _, err := client.Repositories.ListPagesBuilds(context.Background(), "o", "r", nil)
- if err != nil {
- t.Errorf("Repositories.ListPagesBuilds returned error: %v", err)
- }
-
- want := []*PagesBuild{{URL: String("u"), Status: String("s"), Commit: String("c")}}
- if !reflect.DeepEqual(pages, want) {
- t.Errorf("Repositories.ListPagesBuilds returned %+v, want %+v", pages, want)
- }
-}
-
-func TestRepositoriesService_ListPagesBuilds_withOptions(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pages/builds", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
- fmt.Fprint(w, `[]`)
- })
-
- _, _, err := client.Repositories.ListPagesBuilds(context.Background(), "o", "r", &ListOptions{Page: 2})
- if err != nil {
- t.Errorf("Repositories.ListPagesBuilds returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_GetLatestPagesBuild(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pages/builds/latest", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"url":"u","status":"s","commit":"c"}`)
- })
-
- build, _, err := client.Repositories.GetLatestPagesBuild(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Repositories.GetLatestPagesBuild returned error: %v", err)
- }
-
- want := &PagesBuild{URL: String("u"), Status: String("s"), Commit: String("c")}
- if !reflect.DeepEqual(build, want) {
- t.Errorf("Repositories.GetLatestPagesBuild returned %+v, want %+v", build, want)
- }
-}
-
-func TestRepositoriesService_GetPageBuild(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pages/builds/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"url":"u","status":"s","commit":"c"}`)
- })
-
- build, _, err := client.Repositories.GetPageBuild(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Repositories.GetPageBuild returned error: %v", err)
- }
-
- want := &PagesBuild{URL: String("u"), Status: String("s"), Commit: String("c")}
- if !reflect.DeepEqual(build, want) {
- t.Errorf("Repositories.GetPageBuild returned %+v, want %+v", build, want)
- }
-}
-
-func TestRepositoriesService_RequestPageBuild(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/pages/builds", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypePagesPreview)
- fmt.Fprint(w, `{"url":"u","status":"s"}`)
- })
-
- build, _, err := client.Repositories.RequestPageBuild(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Repositories.RequestPageBuild returned error: %v", err)
- }
-
- want := &PagesBuild{URL: String("u"), Status: String("s")}
- if !reflect.DeepEqual(build, want) {
- t.Errorf("Repositories.RequestPageBuild returned %+v, want %+v", build, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/repos_projects_test.go b/vendor/github.com/google/go-github/github/repos_projects_test.go
deleted file mode 100644
index c0392254..00000000
--- a/vendor/github.com/google/go-github/github/repos_projects_test.go
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2017 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestRepositoriesService_ListProjects(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/projects", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ProjectListOptions{ListOptions: ListOptions{Page: 2}}
- projects, _, err := client.Repositories.ListProjects(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Repositories.ListProjects returned error: %v", err)
- }
-
- want := []*Project{{ID: Int64(1)}}
- if !reflect.DeepEqual(projects, want) {
- t.Errorf("Repositories.ListProjects returned %+v, want %+v", projects, want)
- }
-}
-
-func TestRepositoriesService_CreateProject(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &ProjectOptions{Name: "Project Name", Body: "Project body."}
-
- mux.HandleFunc("/repos/o/r/projects", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeProjectsPreview)
-
- v := &ProjectOptions{}
- json.NewDecoder(r.Body).Decode(v)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- project, _, err := client.Repositories.CreateProject(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("Repositories.CreateProject returned error: %v", err)
- }
-
- want := &Project{ID: Int64(1)}
- if !reflect.DeepEqual(project, want) {
- t.Errorf("Repositories.CreateProject returned %+v, want %+v", project, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/repos_releases_test.go b/vendor/github.com/google/go-github/github/repos_releases_test.go
deleted file mode 100644
index 126a4284..00000000
--- a/vendor/github.com/google/go-github/github/repos_releases_test.go
+++ /dev/null
@@ -1,353 +0,0 @@
-// Copyright 2013 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
-
-import (
- "bytes"
- "context"
- "encoding/json"
- "fmt"
- "io/ioutil"
- "net/http"
- "os"
- "reflect"
- "strings"
- "testing"
-)
-
-func TestRepositoriesService_ListReleases(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/releases", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 2}
- releases, _, err := client.Repositories.ListReleases(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Repositories.ListReleases returned error: %v", err)
- }
- want := []*RepositoryRelease{{ID: Int64(1)}}
- if !reflect.DeepEqual(releases, want) {
- t.Errorf("Repositories.ListReleases returned %+v, want %+v", releases, want)
- }
-}
-
-func TestRepositoriesService_GetRelease(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/releases/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id":1,"author":{"login":"l"}}`)
- })
-
- release, resp, err := client.Repositories.GetRelease(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Repositories.GetRelease returned error: %v\n%v", err, resp.Body)
- }
-
- want := &RepositoryRelease{ID: Int64(1), Author: &User{Login: String("l")}}
- if !reflect.DeepEqual(release, want) {
- t.Errorf("Repositories.GetRelease returned %+v, want %+v", release, want)
- }
-}
-
-func TestRepositoriesService_GetLatestRelease(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/releases/latest", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id":3}`)
- })
-
- release, resp, err := client.Repositories.GetLatestRelease(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Repositories.GetLatestRelease returned error: %v\n%v", err, resp.Body)
- }
-
- want := &RepositoryRelease{ID: Int64(3)}
- if !reflect.DeepEqual(release, want) {
- t.Errorf("Repositories.GetLatestRelease returned %+v, want %+v", release, want)
- }
-}
-
-func TestRepositoriesService_GetReleaseByTag(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/releases/tags/foo", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id":13}`)
- })
-
- release, resp, err := client.Repositories.GetReleaseByTag(context.Background(), "o", "r", "foo")
- if err != nil {
- t.Errorf("Repositories.GetReleaseByTag returned error: %v\n%v", err, resp.Body)
- }
-
- want := &RepositoryRelease{ID: Int64(13)}
- if !reflect.DeepEqual(release, want) {
- t.Errorf("Repositories.GetReleaseByTag returned %+v, want %+v", release, want)
- }
-}
-
-func TestRepositoriesService_CreateRelease(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &RepositoryRelease{Name: String("v1.0")}
-
- mux.HandleFunc("/repos/o/r/releases", func(w http.ResponseWriter, r *http.Request) {
- v := new(RepositoryRelease)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
- fmt.Fprint(w, `{"id":1}`)
- })
-
- release, _, err := client.Repositories.CreateRelease(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("Repositories.CreateRelease returned error: %v", err)
- }
-
- want := &RepositoryRelease{ID: Int64(1)}
- if !reflect.DeepEqual(release, want) {
- t.Errorf("Repositories.CreateRelease returned %+v, want %+v", release, want)
- }
-}
-
-func TestRepositoriesService_EditRelease(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &RepositoryRelease{Name: String("n")}
-
- mux.HandleFunc("/repos/o/r/releases/1", func(w http.ResponseWriter, r *http.Request) {
- v := new(RepositoryRelease)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
- fmt.Fprint(w, `{"id":1}`)
- })
-
- release, _, err := client.Repositories.EditRelease(context.Background(), "o", "r", 1, input)
- if err != nil {
- t.Errorf("Repositories.EditRelease returned error: %v", err)
- }
- want := &RepositoryRelease{ID: Int64(1)}
- if !reflect.DeepEqual(release, want) {
- t.Errorf("Repositories.EditRelease returned = %+v, want %+v", release, want)
- }
-}
-
-func TestRepositoriesService_DeleteRelease(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/releases/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Repositories.DeleteRelease(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Repositories.DeleteRelease returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_ListReleaseAssets(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/releases/1/assets", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 2}
- assets, _, err := client.Repositories.ListReleaseAssets(context.Background(), "o", "r", 1, opt)
- if err != nil {
- t.Errorf("Repositories.ListReleaseAssets returned error: %v", err)
- }
- want := []*ReleaseAsset{{ID: Int64(1)}}
- if !reflect.DeepEqual(assets, want) {
- t.Errorf("Repositories.ListReleaseAssets returned %+v, want %+v", assets, want)
- }
-}
-
-func TestRepositoriesService_GetReleaseAsset(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id":1}`)
- })
-
- asset, _, err := client.Repositories.GetReleaseAsset(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Repositories.GetReleaseAsset returned error: %v", err)
- }
- want := &ReleaseAsset{ID: Int64(1)}
- if !reflect.DeepEqual(asset, want) {
- t.Errorf("Repositories.GetReleaseAsset returned %+v, want %+v", asset, want)
- }
-}
-
-func TestRepositoriesService_DownloadReleaseAsset_Stream(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", defaultMediaType)
- w.Header().Set("Content-Type", "application/octet-stream")
- w.Header().Set("Content-Disposition", "attachment; filename=hello-world.txt")
- fmt.Fprint(w, "Hello World")
- })
-
- reader, _, err := client.Repositories.DownloadReleaseAsset(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Repositories.DownloadReleaseAsset returned error: %v", err)
- }
- want := []byte("Hello World")
- content, err := ioutil.ReadAll(reader)
- if err != nil {
- t.Errorf("Repositories.DownloadReleaseAsset returned bad reader: %v", err)
- }
- if !bytes.Equal(want, content) {
- t.Errorf("Repositories.DownloadReleaseAsset returned %+v, want %+v", content, want)
- }
-}
-
-func TestRepositoriesService_DownloadReleaseAsset_Redirect(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", defaultMediaType)
- http.Redirect(w, r, "/yo", http.StatusFound)
- })
-
- _, got, err := client.Repositories.DownloadReleaseAsset(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Repositories.DownloadReleaseAsset returned error: %v", err)
- }
- want := "/yo"
- if !strings.HasSuffix(got, want) {
- t.Errorf("Repositories.DownloadReleaseAsset returned %+v, want %+v", got, want)
- }
-}
-
-func TestRepositoriesService_DownloadReleaseAsset_APIError(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", defaultMediaType)
- w.WriteHeader(http.StatusNotFound)
- fmt.Fprint(w, `{"message":"Not Found","documentation_url":"https://developer.github.com/v3"}`)
- })
-
- resp, loc, err := client.Repositories.DownloadReleaseAsset(context.Background(), "o", "r", 1)
- if err == nil {
- t.Error("Repositories.DownloadReleaseAsset did not return an error")
- }
-
- if resp != nil {
- resp.Close()
- t.Error("Repositories.DownloadReleaseAsset returned stream, want nil")
- }
-
- if loc != "" {
- t.Errorf(`Repositories.DownloadReleaseAsset returned "%s", want empty ""`, loc)
- }
-}
-
-func TestRepositoriesService_EditReleaseAsset(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &ReleaseAsset{Name: String("n")}
-
- mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) {
- v := new(ReleaseAsset)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
- fmt.Fprint(w, `{"id":1}`)
- })
-
- asset, _, err := client.Repositories.EditReleaseAsset(context.Background(), "o", "r", 1, input)
- if err != nil {
- t.Errorf("Repositories.EditReleaseAsset returned error: %v", err)
- }
- want := &ReleaseAsset{ID: Int64(1)}
- if !reflect.DeepEqual(asset, want) {
- t.Errorf("Repositories.EditReleaseAsset returned = %+v, want %+v", asset, want)
- }
-}
-
-func TestRepositoriesService_DeleteReleaseAsset(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Repositories.DeleteReleaseAsset(context.Background(), "o", "r", 1)
- if err != nil {
- t.Errorf("Repositories.DeleteReleaseAsset returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_UploadReleaseAsset(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/releases/1/assets", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testHeader(t, r, "Content-Type", "text/plain; charset=utf-8")
- testHeader(t, r, "Content-Length", "12")
- testFormValues(t, r, values{"name": "n"})
- testBody(t, r, "Upload me !\n")
-
- fmt.Fprintf(w, `{"id":1}`)
- })
-
- file, dir, err := openTestFile("upload.txt", "Upload me !\n")
- if err != nil {
- t.Fatalf("Unable to create temp file: %v", err)
- }
- defer os.RemoveAll(dir)
-
- opt := &UploadOptions{Name: "n"}
- asset, _, err := client.Repositories.UploadReleaseAsset(context.Background(), "o", "r", 1, opt, file)
- if err != nil {
- t.Errorf("Repositories.UploadReleaseAssert returned error: %v", err)
- }
- want := &ReleaseAsset{ID: Int64(1)}
- if !reflect.DeepEqual(asset, want) {
- t.Errorf("Repositories.UploadReleaseAssert returned %+v, want %+v", asset, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/repos_stats_test.go b/vendor/github.com/google/go-github/github/repos_stats_test.go
deleted file mode 100644
index 875acfc7..00000000
--- a/vendor/github.com/google/go-github/github/repos_stats_test.go
+++ /dev/null
@@ -1,211 +0,0 @@
-// Copyright 2014 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
- "time"
-)
-
-func TestRepositoriesService_ListContributorsStats(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/stats/contributors", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
-
- fmt.Fprint(w, `
-[
- {
- "author": {
- "id": 1
- },
- "total": 135,
- "weeks": [
- {
- "w": 1367712000,
- "a": 6898,
- "d": 77,
- "c": 10
- }
- ]
- }
-]
-`)
- })
-
- stats, _, err := client.Repositories.ListContributorsStats(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("RepositoriesService.ListContributorsStats returned error: %v", err)
- }
-
- want := []*ContributorStats{
- {
- Author: &Contributor{
- ID: Int64(1),
- },
- Total: Int(135),
- Weeks: []WeeklyStats{
- {
- Week: &Timestamp{time.Date(2013, 05, 05, 00, 00, 00, 0, time.UTC).Local()},
- Additions: Int(6898),
- Deletions: Int(77),
- Commits: Int(10),
- },
- },
- },
- }
-
- if !reflect.DeepEqual(stats, want) {
- t.Errorf("RepositoriesService.ListContributorsStats returned %+v, want %+v", stats, want)
- }
-}
-
-func TestRepositoriesService_ListCommitActivity(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/stats/commit_activity", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
-
- fmt.Fprint(w, `
-[
- {
- "days": [0, 3, 26, 20, 39, 1, 0],
- "total": 89,
- "week": 1336280400
- }
-]
-`)
- })
-
- activity, _, err := client.Repositories.ListCommitActivity(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("RepositoriesService.ListCommitActivity returned error: %v", err)
- }
-
- want := []*WeeklyCommitActivity{
- {
- Days: []int{0, 3, 26, 20, 39, 1, 0},
- Total: Int(89),
- Week: &Timestamp{time.Date(2012, 05, 06, 05, 00, 00, 0, time.UTC).Local()},
- },
- }
-
- if !reflect.DeepEqual(activity, want) {
- t.Errorf("RepositoriesService.ListCommitActivity returned %+v, want %+v", activity, want)
- }
-}
-
-func TestRepositoriesService_ListCodeFrequency(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/stats/code_frequency", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
-
- fmt.Fprint(w, `[[1302998400, 1124, -435]]`)
- })
-
- code, _, err := client.Repositories.ListCodeFrequency(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("RepositoriesService.ListCodeFrequency returned error: %v", err)
- }
-
- want := []*WeeklyStats{{
- Week: &Timestamp{time.Date(2011, 04, 17, 00, 00, 00, 0, time.UTC).Local()},
- Additions: Int(1124),
- Deletions: Int(-435),
- }}
-
- if !reflect.DeepEqual(code, want) {
- t.Errorf("RepositoriesService.ListCodeFrequency returned %+v, want %+v", code, want)
- }
-}
-
-func TestRepositoriesService_Participation(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/stats/participation", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
-
- fmt.Fprint(w, `
-{
- "all": [
- 11,21,15,2,8,1,8,23,17,21,11,10,33,
- 91,38,34,22,23,32,3,43,87,71,18,13,5,
- 13,16,66,27,12,45,110,117,13,8,18,9,19,
- 26,39,12,20,31,46,91,45,10,24,9,29,7
- ],
- "owner": [
- 3,2,3,0,2,0,5,14,7,9,1,5,0,
- 48,19,2,0,1,10,2,23,40,35,8,8,2,
- 10,6,30,0,2,9,53,104,3,3,10,4,7,
- 11,21,4,4,22,26,63,11,2,14,1,10,3
- ]
-}
-`)
- })
-
- participation, _, err := client.Repositories.ListParticipation(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("RepositoriesService.ListParticipation returned error: %v", err)
- }
-
- want := &RepositoryParticipation{
- All: []int{
- 11, 21, 15, 2, 8, 1, 8, 23, 17, 21, 11, 10, 33,
- 91, 38, 34, 22, 23, 32, 3, 43, 87, 71, 18, 13, 5,
- 13, 16, 66, 27, 12, 45, 110, 117, 13, 8, 18, 9, 19,
- 26, 39, 12, 20, 31, 46, 91, 45, 10, 24, 9, 29, 7,
- },
- Owner: []int{
- 3, 2, 3, 0, 2, 0, 5, 14, 7, 9, 1, 5, 0,
- 48, 19, 2, 0, 1, 10, 2, 23, 40, 35, 8, 8, 2,
- 10, 6, 30, 0, 2, 9, 53, 104, 3, 3, 10, 4, 7,
- 11, 21, 4, 4, 22, 26, 63, 11, 2, 14, 1, 10, 3,
- },
- }
-
- if !reflect.DeepEqual(participation, want) {
- t.Errorf("RepositoriesService.ListParticipation returned %+v, want %+v", participation, want)
- }
-}
-
-func TestRepositoriesService_ListPunchCard(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/stats/punch_card", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
-
- fmt.Fprint(w, `[
- [0, 0, 5],
- [0, 1, 43],
- [0, 2, 21]
- ]`)
- })
-
- card, _, err := client.Repositories.ListPunchCard(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("RepositoriesService.ListPunchCard returned error: %v", err)
- }
-
- want := []*PunchCard{
- {Day: Int(0), Hour: Int(0), Commits: Int(5)},
- {Day: Int(0), Hour: Int(1), Commits: Int(43)},
- {Day: Int(0), Hour: Int(2), Commits: Int(21)},
- }
-
- if !reflect.DeepEqual(card, want) {
- t.Errorf("RepositoriesService.ListPunchCard returned %+v, want %+v", card, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/repos_statuses_test.go b/vendor/github.com/google/go-github/github/repos_statuses_test.go
deleted file mode 100644
index b556b716..00000000
--- a/vendor/github.com/google/go-github/github/repos_statuses_test.go
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestRepositoriesService_ListStatuses(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/commits/r/statuses", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 2}
- statuses, _, err := client.Repositories.ListStatuses(context.Background(), "o", "r", "r", opt)
- if err != nil {
- t.Errorf("Repositories.ListStatuses returned error: %v", err)
- }
-
- want := []*RepoStatus{{ID: Int64(1)}}
- if !reflect.DeepEqual(statuses, want) {
- t.Errorf("Repositories.ListStatuses returned %+v, want %+v", statuses, want)
- }
-}
-
-func TestRepositoriesService_ListStatuses_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.ListStatuses(context.Background(), "%", "r", "r", nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_CreateStatus(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &RepoStatus{State: String("s"), TargetURL: String("t"), Description: String("d")}
-
- mux.HandleFunc("/repos/o/r/statuses/r", func(w http.ResponseWriter, r *http.Request) {
- v := new(RepoStatus)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
- fmt.Fprint(w, `{"id":1}`)
- })
-
- status, _, err := client.Repositories.CreateStatus(context.Background(), "o", "r", "r", input)
- if err != nil {
- t.Errorf("Repositories.CreateStatus returned error: %v", err)
- }
-
- want := &RepoStatus{ID: Int64(1)}
- if !reflect.DeepEqual(status, want) {
- t.Errorf("Repositories.CreateStatus returned %+v, want %+v", status, want)
- }
-}
-
-func TestRepositoriesService_CreateStatus_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.CreateStatus(context.Background(), "%", "r", "r", nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_GetCombinedStatus(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/commits/r/status", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `{"state":"success", "statuses":[{"id":1}]}`)
- })
-
- opt := &ListOptions{Page: 2}
- status, _, err := client.Repositories.GetCombinedStatus(context.Background(), "o", "r", "r", opt)
- if err != nil {
- t.Errorf("Repositories.GetCombinedStatus returned error: %v", err)
- }
-
- want := &CombinedStatus{State: String("success"), Statuses: []RepoStatus{{ID: Int64(1)}}}
- if !reflect.DeepEqual(status, want) {
- t.Errorf("Repositories.GetCombinedStatus returned %+v, want %+v", status, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/repos_test.go b/vendor/github.com/google/go-github/github/repos_test.go
deleted file mode 100644
index d553ccca..00000000
--- a/vendor/github.com/google/go-github/github/repos_test.go
+++ /dev/null
@@ -1,1091 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "strings"
- "testing"
-)
-
-func TestRepositoriesService_List_authenticatedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview}
- mux.HandleFunc("/user/repos", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
- fmt.Fprint(w, `[{"id":1},{"id":2}]`)
- })
-
- repos, _, err := client.Repositories.List(context.Background(), "", nil)
- if err != nil {
- t.Errorf("Repositories.List returned error: %v", err)
- }
-
- want := []*Repository{{ID: Int64(1)}, {ID: Int64(2)}}
- if !reflect.DeepEqual(repos, want) {
- t.Errorf("Repositories.List returned %+v, want %+v", repos, want)
- }
-}
-
-func TestRepositoriesService_List_specifiedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview}
- mux.HandleFunc("/users/u/repos", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
- testFormValues(t, r, values{
- "visibility": "public",
- "affiliation": "owner,collaborator",
- "sort": "created",
- "direction": "asc",
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &RepositoryListOptions{
- Visibility: "public",
- Affiliation: "owner,collaborator",
- Sort: "created",
- Direction: "asc",
- ListOptions: ListOptions{Page: 2},
- }
- repos, _, err := client.Repositories.List(context.Background(), "u", opt)
- if err != nil {
- t.Errorf("Repositories.List returned error: %v", err)
- }
-
- want := []*Repository{{ID: Int64(1)}}
- if !reflect.DeepEqual(repos, want) {
- t.Errorf("Repositories.List returned %+v, want %+v", repos, want)
- }
-}
-
-func TestRepositoriesService_List_specifiedUser_type(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview}
- mux.HandleFunc("/users/u/repos", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
- testFormValues(t, r, values{
- "type": "owner",
- })
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &RepositoryListOptions{
- Type: "owner",
- }
- repos, _, err := client.Repositories.List(context.Background(), "u", opt)
- if err != nil {
- t.Errorf("Repositories.List returned error: %v", err)
- }
-
- want := []*Repository{{ID: Int64(1)}}
- if !reflect.DeepEqual(repos, want) {
- t.Errorf("Repositories.List returned %+v, want %+v", repos, want)
- }
-}
-
-func TestRepositoriesService_List_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.List(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_ListByOrg(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview}
- mux.HandleFunc("/orgs/o/repos", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
- testFormValues(t, r, values{
- "type": "forks",
- "page": "2",
- })
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &RepositoryListByOrgOptions{"forks", ListOptions{Page: 2}}
- repos, _, err := client.Repositories.ListByOrg(context.Background(), "o", opt)
- if err != nil {
- t.Errorf("Repositories.ListByOrg returned error: %v", err)
- }
-
- want := []*Repository{{ID: Int64(1)}}
- if !reflect.DeepEqual(repos, want) {
- t.Errorf("Repositories.ListByOrg returned %+v, want %+v", repos, want)
- }
-}
-
-func TestRepositoriesService_ListByOrg_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.ListByOrg(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_ListAll(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repositories", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "since": "1",
- })
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &RepositoryListAllOptions{1}
- repos, _, err := client.Repositories.ListAll(context.Background(), opt)
- if err != nil {
- t.Errorf("Repositories.ListAll returned error: %v", err)
- }
-
- want := []*Repository{{ID: Int64(1)}}
- if !reflect.DeepEqual(repos, want) {
- t.Errorf("Repositories.ListAll returned %+v, want %+v", repos, want)
- }
-}
-
-func TestRepositoriesService_Create_user(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Repository{Name: String("n")}
-
- mux.HandleFunc("/user/repos", func(w http.ResponseWriter, r *http.Request) {
- v := new(Repository)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- repo, _, err := client.Repositories.Create(context.Background(), "", input)
- if err != nil {
- t.Errorf("Repositories.Create returned error: %v", err)
- }
-
- want := &Repository{ID: Int64(1)}
- if !reflect.DeepEqual(repo, want) {
- t.Errorf("Repositories.Create returned %+v, want %+v", repo, want)
- }
-}
-
-func TestRepositoriesService_Create_org(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Repository{Name: String("n")}
-
- mux.HandleFunc("/orgs/o/repos", func(w http.ResponseWriter, r *http.Request) {
- v := new(Repository)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- repo, _, err := client.Repositories.Create(context.Background(), "o", input)
- if err != nil {
- t.Errorf("Repositories.Create returned error: %v", err)
- }
-
- want := &Repository{ID: Int64(1)}
- if !reflect.DeepEqual(repo, want) {
- t.Errorf("Repositories.Create returned %+v, want %+v", repo, want)
- }
-}
-
-func TestRepositoriesService_Create_invalidOrg(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.Create(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_Get(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview}
- mux.HandleFunc("/repos/o/r", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
- fmt.Fprint(w, `{"id":1,"name":"n","description":"d","owner":{"login":"l"},"license":{"key":"mit"}}`)
- })
-
- repo, _, err := client.Repositories.Get(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Repositories.Get returned error: %v", err)
- }
-
- want := &Repository{ID: Int64(1), Name: String("n"), Description: String("d"), Owner: &User{Login: String("l")}, License: &License{Key: String("mit")}}
- if !reflect.DeepEqual(repo, want) {
- t.Errorf("Repositories.Get returned %+v, want %+v", repo, want)
- }
-}
-
-func TestRepositoriesService_GetCodeOfConduct(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/community/code_of_conduct", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeCodesOfConductPreview)
- fmt.Fprint(w, `{
- "key": "key",
- "name": "name",
- "url": "url",
- "body": "body"}`,
- )
- })
-
- coc, _, err := client.Repositories.GetCodeOfConduct(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Repositories.GetCodeOfConduct returned error: %v", err)
- }
-
- want := &CodeOfConduct{
- Key: String("key"),
- Name: String("name"),
- URL: String("url"),
- Body: String("body"),
- }
-
- if !reflect.DeepEqual(coc, want) {
- t.Errorf("Repositories.Get returned %+v, want %+v", coc, want)
- }
-}
-
-func TestRepositoriesService_GetByID(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repositories/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeLicensesPreview)
- fmt.Fprint(w, `{"id":1,"name":"n","description":"d","owner":{"login":"l"},"license":{"key":"mit"}}`)
- })
-
- repo, _, err := client.Repositories.GetByID(context.Background(), 1)
- if err != nil {
- t.Fatalf("Repositories.GetByID returned error: %v", err)
- }
-
- want := &Repository{ID: Int64(1), Name: String("n"), Description: String("d"), Owner: &User{Login: String("l")}, License: &License{Key: String("mit")}}
- if !reflect.DeepEqual(repo, want) {
- t.Errorf("Repositories.GetByID returned %+v, want %+v", repo, want)
- }
-}
-
-func TestRepositoriesService_Edit(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- i := true
- input := &Repository{HasIssues: &i}
-
- mux.HandleFunc("/repos/o/r", func(w http.ResponseWriter, r *http.Request) {
- v := new(Repository)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
- fmt.Fprint(w, `{"id":1}`)
- })
-
- repo, _, err := client.Repositories.Edit(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("Repositories.Edit returned error: %v", err)
- }
-
- want := &Repository{ID: Int64(1)}
- if !reflect.DeepEqual(repo, want) {
- t.Errorf("Repositories.Edit returned %+v, want %+v", repo, want)
- }
-}
-
-func TestRepositoriesService_Delete(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Repositories.Delete(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Repositories.Delete returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_Get_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.Get(context.Background(), "%", "r")
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_Edit_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.Edit(context.Background(), "%", "r", nil)
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_ListContributors(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/contributors", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "anon": "true",
- "page": "2",
- })
- fmt.Fprint(w, `[{"contributions":42}]`)
- })
-
- opts := &ListContributorsOptions{Anon: "true", ListOptions: ListOptions{Page: 2}}
- contributors, _, err := client.Repositories.ListContributors(context.Background(), "o", "r", opts)
- if err != nil {
- t.Errorf("Repositories.ListContributors returned error: %v", err)
- }
-
- want := []*Contributor{{Contributions: Int(42)}}
- if !reflect.DeepEqual(contributors, want) {
- t.Errorf("Repositories.ListContributors returned %+v, want %+v", contributors, want)
- }
-}
-
-func TestRepositoriesService_ListLanguages(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/languages", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"go":1}`)
- })
-
- languages, _, err := client.Repositories.ListLanguages(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Repositories.ListLanguages returned error: %v", err)
- }
-
- want := map[string]int{"go": 1}
- if !reflect.DeepEqual(languages, want) {
- t.Errorf("Repositories.ListLanguages returned %+v, want %+v", languages, want)
- }
-}
-
-func TestRepositoriesService_ListTeams(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/teams", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeNestedTeamsPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 2}
- teams, _, err := client.Repositories.ListTeams(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Repositories.ListTeams returned error: %v", err)
- }
-
- want := []*Team{{ID: Int64(1)}}
- if !reflect.DeepEqual(teams, want) {
- t.Errorf("Repositories.ListTeams returned %+v, want %+v", teams, want)
- }
-}
-
-func TestRepositoriesService_ListTags(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/tags", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"name":"n", "commit" : {"sha" : "s", "url" : "u"}, "zipball_url": "z", "tarball_url": "t"}]`)
- })
-
- opt := &ListOptions{Page: 2}
- tags, _, err := client.Repositories.ListTags(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Repositories.ListTags returned error: %v", err)
- }
-
- want := []*RepositoryTag{
- {
- Name: String("n"),
- Commit: &Commit{
- SHA: String("s"),
- URL: String("u"),
- },
- ZipballURL: String("z"),
- TarballURL: String("t"),
- },
- }
- if !reflect.DeepEqual(tags, want) {
- t.Errorf("Repositories.ListTags returned %+v, want %+v", tags, want)
- }
-}
-
-func TestRepositoriesService_ListBranches(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/branches", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"name":"master", "commit" : {"sha" : "a57781", "url" : "https://api.github.com/repos/o/r/commits/a57781"}}]`)
- })
-
- opt := &ListOptions{Page: 2}
- branches, _, err := client.Repositories.ListBranches(context.Background(), "o", "r", opt)
- if err != nil {
- t.Errorf("Repositories.ListBranches returned error: %v", err)
- }
-
- want := []*Branch{{Name: String("master"), Commit: &RepositoryCommit{SHA: String("a57781"), URL: String("https://api.github.com/repos/o/r/commits/a57781")}}}
- if !reflect.DeepEqual(branches, want) {
- t.Errorf("Repositories.ListBranches returned %+v, want %+v", branches, want)
- }
-}
-
-func TestRepositoriesService_GetBranch(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/branches/b", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview)
- fmt.Fprint(w, `{"name":"n", "commit":{"sha":"s","commit":{"message":"m"}}, "protected":true}`)
- })
-
- branch, _, err := client.Repositories.GetBranch(context.Background(), "o", "r", "b")
- if err != nil {
- t.Errorf("Repositories.GetBranch returned error: %v", err)
- }
-
- want := &Branch{
- Name: String("n"),
- Commit: &RepositoryCommit{
- SHA: String("s"),
- Commit: &Commit{
- Message: String("m"),
- },
- },
- Protected: Bool(true),
- }
-
- if !reflect.DeepEqual(branch, want) {
- t.Errorf("Repositories.GetBranch returned %+v, want %+v", branch, want)
- }
-}
-
-func TestRepositoriesService_GetBranchProtection(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) {
- v := new(ProtectionRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview)
- fmt.Fprintf(w, `{"required_status_checks":{"strict":true,"contexts":["continuous-integration"]},"required_pull_request_reviews":{"dismissal_restrictions":{"users":[{"id":3,"login":"u"}],"teams":[{"id":4,"slug":"t"}]},"dismiss_stale_reviews":true,"require_code_owner_reviews":true},"enforce_admins":{"url":"/repos/o/r/branches/b/protection/enforce_admins","enabled":true},"restrictions":{"users":[{"id":1,"login":"u"}],"teams":[{"id":2,"slug":"t"}]}}`)
- })
-
- protection, _, err := client.Repositories.GetBranchProtection(context.Background(), "o", "r", "b")
- if err != nil {
- t.Errorf("Repositories.GetBranchProtection returned error: %v", err)
- }
-
- want := &Protection{
- RequiredStatusChecks: &RequiredStatusChecks{
- Strict: true,
- Contexts: []string{"continuous-integration"},
- },
- RequiredPullRequestReviews: &PullRequestReviewsEnforcement{
- DismissStaleReviews: true,
- DismissalRestrictions: DismissalRestrictions{
- Users: []*User{
- {Login: String("u"), ID: Int64(3)},
- },
- Teams: []*Team{
- {Slug: String("t"), ID: Int64(4)},
- },
- },
- RequireCodeOwnerReviews: true,
- },
- EnforceAdmins: &AdminEnforcement{
- URL: String("/repos/o/r/branches/b/protection/enforce_admins"),
- Enabled: true,
- },
- Restrictions: &BranchRestrictions{
- Users: []*User{
- {Login: String("u"), ID: Int64(1)},
- },
- Teams: []*Team{
- {Slug: String("t"), ID: Int64(2)},
- },
- },
- }
- if !reflect.DeepEqual(protection, want) {
- t.Errorf("Repositories.GetBranchProtection returned %+v, want %+v", protection, want)
- }
-}
-
-func TestRepositoriesService_UpdateBranchProtection(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &ProtectionRequest{
- RequiredStatusChecks: &RequiredStatusChecks{
- Strict: true,
- Contexts: []string{"continuous-integration"},
- },
- RequiredPullRequestReviews: &PullRequestReviewsEnforcementRequest{
- DismissStaleReviews: true,
- DismissalRestrictionsRequest: &DismissalRestrictionsRequest{
- Users: []string{"uu"},
- Teams: []string{"tt"},
- },
- },
- Restrictions: &BranchRestrictionsRequest{
- Users: []string{"u"},
- Teams: []string{"t"},
- },
- }
-
- mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) {
- v := new(ProtectionRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PUT")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
- testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview)
- fmt.Fprintf(w, `{"required_status_checks":{"strict":true,"contexts":["continuous-integration"]},"required_pull_request_reviews":{"dismissal_restrictions":{"users":[{"id":3,"login":"uu"}],"teams":[{"id":4,"slug":"tt"}]},"dismiss_stale_reviews":true,"require_code_owner_reviews":true},"restrictions":{"users":[{"id":1,"login":"u"}],"teams":[{"id":2,"slug":"t"}]}}`)
- })
-
- protection, _, err := client.Repositories.UpdateBranchProtection(context.Background(), "o", "r", "b", input)
- if err != nil {
- t.Errorf("Repositories.UpdateBranchProtection returned error: %v", err)
- }
-
- want := &Protection{
- RequiredStatusChecks: &RequiredStatusChecks{
- Strict: true,
- Contexts: []string{"continuous-integration"},
- },
- RequiredPullRequestReviews: &PullRequestReviewsEnforcement{
- DismissStaleReviews: true,
- DismissalRestrictions: DismissalRestrictions{
- Users: []*User{
- {Login: String("uu"), ID: Int64(3)},
- },
- Teams: []*Team{
- {Slug: String("tt"), ID: Int64(4)},
- },
- },
- RequireCodeOwnerReviews: true,
- },
- Restrictions: &BranchRestrictions{
- Users: []*User{
- {Login: String("u"), ID: Int64(1)},
- },
- Teams: []*Team{
- {Slug: String("t"), ID: Int64(2)},
- },
- },
- }
- if !reflect.DeepEqual(protection, want) {
- t.Errorf("Repositories.UpdateBranchProtection returned %+v, want %+v", protection, want)
- }
-}
-
-func TestRepositoriesService_RemoveBranchProtection(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview)
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Repositories.RemoveBranchProtection(context.Background(), "o", "r", "b")
- if err != nil {
- t.Errorf("Repositories.RemoveBranchProtection returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_ListLanguages_invalidOwner(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Repositories.ListLanguages(context.Background(), "%", "%")
- testURLParseError(t, err)
-}
-
-func TestRepositoriesService_License(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/license", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"name": "LICENSE", "path": "LICENSE", "license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","featured":true}}`)
- })
-
- got, _, err := client.Repositories.License(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Repositories.License returned error: %v", err)
- }
-
- want := &RepositoryLicense{
- Name: String("LICENSE"),
- Path: String("LICENSE"),
- License: &License{
- Name: String("MIT License"),
- Key: String("mit"),
- SPDXID: String("MIT"),
- URL: String("https://api.github.com/licenses/mit"),
- Featured: Bool(true),
- },
- }
-
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Repositories.License returned %+v, want %+v", got, want)
- }
-}
-
-func TestRepositoriesService_GetRequiredStatusChecks(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/branches/b/protection/required_status_checks", func(w http.ResponseWriter, r *http.Request) {
- v := new(ProtectionRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview)
- fmt.Fprint(w, `{"strict": true,"contexts": ["x","y","z"]}`)
- })
-
- checks, _, err := client.Repositories.GetRequiredStatusChecks(context.Background(), "o", "r", "b")
- if err != nil {
- t.Errorf("Repositories.GetRequiredStatusChecks returned error: %v", err)
- }
-
- want := &RequiredStatusChecks{
- Strict: true,
- Contexts: []string{"x", "y", "z"},
- }
- if !reflect.DeepEqual(checks, want) {
- t.Errorf("Repositories.GetRequiredStatusChecks returned %+v, want %+v", checks, want)
- }
-}
-
-func TestRepositoriesService_ListRequiredStatusChecksContexts(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/branches/b/protection/required_status_checks/contexts", func(w http.ResponseWriter, r *http.Request) {
- v := new(ProtectionRequest)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview)
- fmt.Fprint(w, `["x", "y", "z"]`)
- })
-
- contexts, _, err := client.Repositories.ListRequiredStatusChecksContexts(context.Background(), "o", "r", "b")
- if err != nil {
- t.Errorf("Repositories.ListRequiredStatusChecksContexts returned error: %v", err)
- }
-
- want := []string{"x", "y", "z"}
- if !reflect.DeepEqual(contexts, want) {
- t.Errorf("Repositories.ListRequiredStatusChecksContexts returned %+v, want %+v", contexts, want)
- }
-}
-
-func TestRepositoriesService_GetPullRequestReviewEnforcement(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview)
- fmt.Fprintf(w, `{"dismissal_restrictions":{"users":[{"id":1,"login":"u"}],"teams":[{"id":2,"slug":"t"}]},"dismiss_stale_reviews":true,"require_code_owner_reviews":true}`)
- })
-
- enforcement, _, err := client.Repositories.GetPullRequestReviewEnforcement(context.Background(), "o", "r", "b")
- if err != nil {
- t.Errorf("Repositories.GetPullRequestReviewEnforcement returned error: %v", err)
- }
-
- want := &PullRequestReviewsEnforcement{
- DismissStaleReviews: true,
- DismissalRestrictions: DismissalRestrictions{
- Users: []*User{
- {Login: String("u"), ID: Int64(1)},
- },
- Teams: []*Team{
- {Slug: String("t"), ID: Int64(2)},
- },
- },
- RequireCodeOwnerReviews: true,
- }
-
- if !reflect.DeepEqual(enforcement, want) {
- t.Errorf("Repositories.GetPullRequestReviewEnforcement returned %+v, want %+v", enforcement, want)
- }
-}
-
-func TestRepositoriesService_UpdatePullRequestReviewEnforcement(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &PullRequestReviewsEnforcementUpdate{
- DismissalRestrictionsRequest: &DismissalRestrictionsRequest{
- Users: []string{"u"},
- Teams: []string{"t"},
- },
- }
-
- mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) {
- v := new(PullRequestReviewsEnforcementUpdate)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
- testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview)
- fmt.Fprintf(w, `{"dismissal_restrictions":{"users":[{"id":1,"login":"u"}],"teams":[{"id":2,"slug":"t"}]},"dismiss_stale_reviews":true,"require_code_owner_reviews":true}`)
- })
-
- enforcement, _, err := client.Repositories.UpdatePullRequestReviewEnforcement(context.Background(), "o", "r", "b", input)
- if err != nil {
- t.Errorf("Repositories.UpdatePullRequestReviewEnforcement returned error: %v", err)
- }
-
- want := &PullRequestReviewsEnforcement{
- DismissStaleReviews: true,
- DismissalRestrictions: DismissalRestrictions{
- Users: []*User{
- {Login: String("u"), ID: Int64(1)},
- },
- Teams: []*Team{
- {Slug: String("t"), ID: Int64(2)},
- },
- },
- RequireCodeOwnerReviews: true,
- }
- if !reflect.DeepEqual(enforcement, want) {
- t.Errorf("Repositories.UpdatePullRequestReviewEnforcement returned %+v, want %+v", enforcement, want)
- }
-}
-
-func TestRepositoriesService_DisableDismissalRestrictions(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PATCH")
- testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview)
- testBody(t, r, `{"dismissal_restrictions":[]}`+"\n")
- fmt.Fprintf(w, `{"dismissal_restrictions":{"users":[],"teams":[]},"dismiss_stale_reviews":true,"require_code_owner_reviews":true}`)
- })
-
- enforcement, _, err := client.Repositories.DisableDismissalRestrictions(context.Background(), "o", "r", "b")
- if err != nil {
- t.Errorf("Repositories.DisableDismissalRestrictions returned error: %v", err)
- }
-
- want := &PullRequestReviewsEnforcement{
- DismissStaleReviews: true,
- DismissalRestrictions: DismissalRestrictions{
- Users: []*User{},
- Teams: []*Team{},
- },
- RequireCodeOwnerReviews: true,
- }
- if !reflect.DeepEqual(enforcement, want) {
- t.Errorf("Repositories.DisableDismissalRestrictions returned %+v, want %+v", enforcement, want)
- }
-}
-
-func TestRepositoriesService_RemovePullRequestReviewEnforcement(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview)
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Repositories.RemovePullRequestReviewEnforcement(context.Background(), "o", "r", "b")
- if err != nil {
- t.Errorf("Repositories.RemovePullRequestReviewEnforcement returned error: %v", err)
- }
-}
-
-func TestRepositoriesService_GetAdminEnforcement(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/branches/b/protection/enforce_admins", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview)
- fmt.Fprintf(w, `{"url":"/repos/o/r/branches/b/protection/enforce_admins","enabled":true}`)
- })
-
- enforcement, _, err := client.Repositories.GetAdminEnforcement(context.Background(), "o", "r", "b")
- if err != nil {
- t.Errorf("Repositories.GetAdminEnforcement returned error: %v", err)
- }
-
- want := &AdminEnforcement{
- URL: String("/repos/o/r/branches/b/protection/enforce_admins"),
- Enabled: true,
- }
-
- if !reflect.DeepEqual(enforcement, want) {
- t.Errorf("Repositories.GetAdminEnforcement returned %+v, want %+v", enforcement, want)
- }
-}
-
-func TestRepositoriesService_AddAdminEnforcement(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/branches/b/protection/enforce_admins", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview)
- fmt.Fprintf(w, `{"url":"/repos/o/r/branches/b/protection/enforce_admins","enabled":true}`)
- })
-
- enforcement, _, err := client.Repositories.AddAdminEnforcement(context.Background(), "o", "r", "b")
- if err != nil {
- t.Errorf("Repositories.AddAdminEnforcement returned error: %v", err)
- }
-
- want := &AdminEnforcement{
- URL: String("/repos/o/r/branches/b/protection/enforce_admins"),
- Enabled: true,
- }
- if !reflect.DeepEqual(enforcement, want) {
- t.Errorf("Repositories.AddAdminEnforcement returned %+v, want %+v", enforcement, want)
- }
-}
-
-func TestRepositoriesService_RemoveAdminEnforcement(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/branches/b/protection/enforce_admins", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview)
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Repositories.RemoveAdminEnforcement(context.Background(), "o", "r", "b")
- if err != nil {
- t.Errorf("Repositories.RemoveAdminEnforcement returned error: %v", err)
- }
-}
-
-func TestPullRequestReviewsEnforcementRequest_MarshalJSON_nilDismissalRestirctions(t *testing.T) {
- req := PullRequestReviewsEnforcementRequest{}
-
- json, err := json.Marshal(req)
- if err != nil {
- t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned error: %v", err)
- }
-
- want := `{"dismissal_restrictions":[],"dismiss_stale_reviews":false,"require_code_owner_reviews":false}`
- if want != string(json) {
- t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned %+v, want %+v", string(json), want)
- }
-}
-
-func TestRepositoriesService_ListAllTopics(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeTopicsPreview)
- fmt.Fprint(w, `{"names":["go", "go-github", "github"]}`)
- })
-
- got, _, err := client.Repositories.ListAllTopics(context.Background(), "o", "r")
- if err != nil {
- t.Fatalf("Repositories.ListAllTopics returned error: %v", err)
- }
-
- want := []string{"go", "go-github", "github"}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Repositories.ListAllTopics returned %+v, want %+v", got, want)
- }
-}
-
-func TestRepositoriesService_ListAllTopics_emptyTopics(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeTopicsPreview)
- fmt.Fprint(w, `{"names":[]}`)
- })
-
- got, _, err := client.Repositories.ListAllTopics(context.Background(), "o", "r")
- if err != nil {
- t.Fatalf("Repositories.ListAllTopics returned error: %v", err)
- }
-
- want := []string{}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Repositories.ListAllTopics returned %+v, want %+v", got, want)
- }
-}
-
-func TestRepositoriesService_ReplaceAllTopics(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- testHeader(t, r, "Accept", mediaTypeTopicsPreview)
- fmt.Fprint(w, `{"names":["go", "go-github", "github"]}`)
- })
-
- got, _, err := client.Repositories.ReplaceAllTopics(context.Background(), "o", "r", []string{"go", "go-github", "github"})
- if err != nil {
- t.Fatalf("Repositories.ReplaceAllTopics returned error: %v", err)
- }
-
- want := []string{"go", "go-github", "github"}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Repositories.ReplaceAllTopics returned %+v, want %+v", got, want)
- }
-}
-
-func TestRepositoriesService_ReplaceAllTopics_nilSlice(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- testHeader(t, r, "Accept", mediaTypeTopicsPreview)
- testBody(t, r, `{"names":[]}`+"\n")
- fmt.Fprint(w, `{"names":[]}`)
- })
-
- got, _, err := client.Repositories.ReplaceAllTopics(context.Background(), "o", "r", nil)
- if err != nil {
- t.Fatalf("Repositories.ReplaceAllTopics returned error: %v", err)
- }
-
- want := []string{}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Repositories.ReplaceAllTopics returned %+v, want %+v", got, want)
- }
-}
-
-func TestRepositoriesService_ReplaceAllTopics_emptySlice(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- testHeader(t, r, "Accept", mediaTypeTopicsPreview)
- testBody(t, r, `{"names":[]}`+"\n")
- fmt.Fprint(w, `{"names":[]}`)
- })
-
- got, _, err := client.Repositories.ReplaceAllTopics(context.Background(), "o", "r", []string{})
- if err != nil {
- t.Fatalf("Repositories.ReplaceAllTopics returned error: %v", err)
- }
-
- want := []string{}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Repositories.ReplaceAllTopics returned %+v, want %+v", got, want)
- }
-}
-
-func TestRepositoriesService_Transfer(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := TransferRequest{NewOwner: "a", TeamID: []int64{123}}
-
- mux.HandleFunc("/repos/o/r/transfer", func(w http.ResponseWriter, r *http.Request) {
- var v TransferRequest
- json.NewDecoder(r.Body).Decode(&v)
-
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeRepositoryTransferPreview)
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"owner":{"login":"a"}}`)
- })
-
- got, _, err := client.Repositories.Transfer(context.Background(), "o", "r", input)
- if err != nil {
- t.Errorf("Repositories.Transfer returned error: %v", err)
- }
-
- want := &Repository{Owner: &User{Login: String("a")}}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Repositories.Transfer returned %+v, want %+v", got, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/repos_traffic_test.go b/vendor/github.com/google/go-github/github/repos_traffic_test.go
deleted file mode 100644
index 0a2eb4f3..00000000
--- a/vendor/github.com/google/go-github/github/repos_traffic_test.go
+++ /dev/null
@@ -1,145 +0,0 @@
-// 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
- "time"
-)
-
-func TestRepositoriesService_ListTrafficReferrers(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/traffic/popular/referrers", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprintf(w, `[{
- "referrer": "Google",
- "count": 4,
- "uniques": 3
- }]`)
- })
- referrers, _, err := client.Repositories.ListTrafficReferrers(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Repositories.ListPaths returned error: %+v", err)
- }
-
- want := []*TrafficReferrer{{
- Referrer: String("Google"),
- Count: Int(4),
- Uniques: Int(3),
- }}
- if !reflect.DeepEqual(referrers, want) {
- t.Errorf("Repositories.ListReferrers returned %+v, want %+v", referrers, want)
- }
-
-}
-
-func TestRepositoriesService_ListTrafficPaths(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/traffic/popular/paths", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprintf(w, `[{
- "path": "/github/hubot",
- "title": "github/hubot: A customizable life embetterment robot.",
- "count": 3542,
- "uniques": 2225
- }]`)
- })
- paths, _, err := client.Repositories.ListTrafficPaths(context.Background(), "o", "r")
- if err != nil {
- t.Errorf("Repositories.ListPaths returned error: %+v", err)
- }
-
- want := []*TrafficPath{{
- Path: String("/github/hubot"),
- Title: String("github/hubot: A customizable life embetterment robot."),
- Count: Int(3542),
- Uniques: Int(2225),
- }}
- if !reflect.DeepEqual(paths, want) {
- t.Errorf("Repositories.ListPaths returned %+v, want %+v", paths, want)
- }
-
-}
-
-func TestRepositoriesService_ListTrafficViews(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/traffic/views", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprintf(w, `{"count": 7,
- "uniques": 6,
- "views": [{
- "timestamp": "2016-05-31T16:00:00.000Z",
- "count": 7,
- "uniques": 6
- }]}`)
- })
-
- views, _, err := client.Repositories.ListTrafficViews(context.Background(), "o", "r", nil)
- if err != nil {
- t.Errorf("Repositories.ListPaths returned error: %+v", err)
- }
-
- want := &TrafficViews{
- Views: []*TrafficData{{
- Timestamp: &Timestamp{time.Date(2016, time.May, 31, 16, 0, 0, 0, time.UTC)},
- Count: Int(7),
- Uniques: Int(6),
- }},
- Count: Int(7),
- Uniques: Int(6),
- }
-
- if !reflect.DeepEqual(views, want) {
- t.Errorf("Repositories.ListViews returned %+v, want %+v", views, want)
- }
-
-}
-
-func TestRepositoriesService_ListTrafficClones(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/repos/o/r/traffic/clones", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprintf(w, `{"count": 7,
- "uniques": 6,
- "clones": [{
- "timestamp": "2016-05-31T16:00:00.00Z",
- "count": 7,
- "uniques": 6
- }]}`)
- })
-
- clones, _, err := client.Repositories.ListTrafficClones(context.Background(), "o", "r", nil)
- if err != nil {
- t.Errorf("Repositories.ListPaths returned error: %+v", err)
- }
-
- want := &TrafficClones{
- Clones: []*TrafficData{{
- Timestamp: &Timestamp{time.Date(2016, time.May, 31, 16, 0, 0, 0, time.UTC)},
- Count: Int(7),
- Uniques: Int(6),
- }},
- Count: Int(7),
- Uniques: Int(6),
- }
-
- if !reflect.DeepEqual(clones, want) {
- t.Errorf("Repositories.ListViews returned %+v, want %+v", clones, want)
- }
-
-}
diff --git a/vendor/github.com/google/go-github/github/search_test.go b/vendor/github.com/google/go-github/github/search_test.go
deleted file mode 100644
index cc9faacf..00000000
--- a/vendor/github.com/google/go-github/github/search_test.go
+++ /dev/null
@@ -1,268 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
-
- "testing"
-)
-
-func TestSearchService_Repositories(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/search/repositories", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "q": "blah",
- "sort": "forks",
- "order": "desc",
- "page": "2",
- "per_page": "2",
- })
-
- fmt.Fprint(w, `{"total_count": 4, "incomplete_results": false, "items": [{"id":1},{"id":2}]}`)
- })
-
- opts := &SearchOptions{Sort: "forks", Order: "desc", ListOptions: ListOptions{Page: 2, PerPage: 2}}
- result, _, err := client.Search.Repositories(context.Background(), "blah", opts)
- if err != nil {
- t.Errorf("Search.Repositories returned error: %v", err)
- }
-
- want := &RepositoriesSearchResult{
- Total: Int(4),
- IncompleteResults: Bool(false),
- Repositories: []Repository{{ID: Int64(1)}, {ID: Int64(2)}},
- }
- if !reflect.DeepEqual(result, want) {
- t.Errorf("Search.Repositories returned %+v, want %+v", result, want)
- }
-}
-
-func TestSearchService_Commits(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/search/commits", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "q": "blah",
- "sort": "author-date",
- "order": "desc",
- })
-
- fmt.Fprint(w, `{"total_count": 4, "incomplete_results": false, "items": [{"sha":"random_hash1"},{"sha":"random_hash2"}]}`)
- })
-
- opts := &SearchOptions{Sort: "author-date", Order: "desc"}
- result, _, err := client.Search.Commits(context.Background(), "blah", opts)
- if err != nil {
- t.Errorf("Search.Commits returned error: %v", err)
- }
-
- want := &CommitsSearchResult{
- Total: Int(4),
- IncompleteResults: Bool(false),
- Commits: []*CommitResult{{SHA: String("random_hash1")}, {SHA: String("random_hash2")}},
- }
- if !reflect.DeepEqual(result, want) {
- t.Errorf("Search.Commits returned %+v, want %+v", result, want)
- }
-}
-
-func TestSearchService_Issues(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/search/issues", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "q": "blah",
- "sort": "forks",
- "order": "desc",
- "page": "2",
- "per_page": "2",
- })
-
- fmt.Fprint(w, `{"total_count": 4, "incomplete_results": true, "items": [{"number":1},{"number":2}]}`)
- })
-
- opts := &SearchOptions{Sort: "forks", Order: "desc", ListOptions: ListOptions{Page: 2, PerPage: 2}}
- result, _, err := client.Search.Issues(context.Background(), "blah", opts)
- if err != nil {
- t.Errorf("Search.Issues returned error: %v", err)
- }
-
- want := &IssuesSearchResult{
- Total: Int(4),
- IncompleteResults: Bool(true),
- Issues: []Issue{{Number: Int(1)}, {Number: Int(2)}},
- }
- if !reflect.DeepEqual(result, want) {
- t.Errorf("Search.Issues returned %+v, want %+v", result, want)
- }
-}
-
-func TestSearchService_Issues_withQualifiers(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/search/issues", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "q": "gopher is:issue label:bug language:go",
- })
-
- fmt.Fprint(w, `{"total_count": 4, "incomplete_results": true, "items": [{"number":1},{"number":2}]}`)
- })
-
- opts := &SearchOptions{}
- result, _, err := client.Search.Issues(context.Background(), "gopher is:issue label:bug language:go", opts)
- if err != nil {
- t.Errorf("Search.Issues returned error: %v", err)
- }
-
- want := &IssuesSearchResult{
- Total: Int(4),
- IncompleteResults: Bool(true),
- Issues: []Issue{{Number: Int(1)}, {Number: Int(2)}},
- }
- if !reflect.DeepEqual(result, want) {
- t.Errorf("Search.Issues returned %+v, want %+v", result, want)
- }
-}
-
-func TestSearchService_Users(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/search/users", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "q": "blah",
- "sort": "forks",
- "order": "desc",
- "page": "2",
- "per_page": "2",
- })
-
- fmt.Fprint(w, `{"total_count": 4, "incomplete_results": false, "items": [{"id":1},{"id":2}]}`)
- })
-
- opts := &SearchOptions{Sort: "forks", Order: "desc", ListOptions: ListOptions{Page: 2, PerPage: 2}}
- result, _, err := client.Search.Users(context.Background(), "blah", opts)
- if err != nil {
- t.Errorf("Search.Issues returned error: %v", err)
- }
-
- want := &UsersSearchResult{
- Total: Int(4),
- IncompleteResults: Bool(false),
- Users: []User{{ID: Int64(1)}, {ID: Int64(2)}},
- }
- if !reflect.DeepEqual(result, want) {
- t.Errorf("Search.Users returned %+v, want %+v", result, want)
- }
-}
-
-func TestSearchService_Code(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/search/code", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "q": "blah",
- "sort": "forks",
- "order": "desc",
- "page": "2",
- "per_page": "2",
- })
-
- fmt.Fprint(w, `{"total_count": 4, "incomplete_results": false, "items": [{"name":"1"},{"name":"2"}]}`)
- })
-
- opts := &SearchOptions{Sort: "forks", Order: "desc", ListOptions: ListOptions{Page: 2, PerPage: 2}}
- result, _, err := client.Search.Code(context.Background(), "blah", opts)
- if err != nil {
- t.Errorf("Search.Code returned error: %v", err)
- }
-
- want := &CodeSearchResult{
- Total: Int(4),
- IncompleteResults: Bool(false),
- CodeResults: []CodeResult{{Name: String("1")}, {Name: String("2")}},
- }
- if !reflect.DeepEqual(result, want) {
- t.Errorf("Search.Code returned %+v, want %+v", result, want)
- }
-}
-
-func TestSearchService_CodeTextMatch(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/search/code", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
-
- textMatchResponse := `
- {
- "total_count": 1,
- "incomplete_results": false,
- "items": [
- {
- "name":"gopher1",
- "text_matches": [
- {
- "fragment": "I'm afraid my friend what you have found\nIs a gopher who lives to feed",
- "matches": [
- {
- "text": "gopher",
- "indices": [
- 14,
- 21
- ]
- }
- ]
- }
- ]
- }
- ]
- }
- `
-
- fmt.Fprint(w, textMatchResponse)
- })
-
- opts := &SearchOptions{Sort: "forks", Order: "desc", ListOptions: ListOptions{Page: 2, PerPage: 2}, TextMatch: true}
- result, _, err := client.Search.Code(context.Background(), "blah", opts)
- if err != nil {
- t.Errorf("Search.Code returned error: %v", err)
- }
-
- wantedCodeResult := CodeResult{
- Name: String("gopher1"),
- TextMatches: []TextMatch{{
- Fragment: String("I'm afraid my friend what you have found\nIs a gopher who lives to feed"),
- Matches: []Match{{Text: String("gopher"), Indices: []int{14, 21}}},
- },
- },
- }
-
- want := &CodeSearchResult{
- Total: Int(1),
- IncompleteResults: Bool(false),
- CodeResults: []CodeResult{wantedCodeResult},
- }
- if !reflect.DeepEqual(result, want) {
- t.Errorf("Search.Code returned %+v, want %+v", result, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/strings_test.go b/vendor/github.com/google/go-github/github/strings_test.go
deleted file mode 100644
index b0a82089..00000000
--- a/vendor/github.com/google/go-github/github/strings_test.go
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2013 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
-
-import (
- "fmt"
- "testing"
- "time"
-)
-
-func TestStringify(t *testing.T) {
- var nilPointer *string
-
- var tests = []struct {
- in interface{}
- out string
- }{
- // basic types
- {"foo", `"foo"`},
- {123, `123`},
- {1.5, `1.5`},
- {false, `false`},
- {
- []string{"a", "b"},
- `["a" "b"]`,
- },
- {
- struct {
- A []string
- }{nil},
- // nil slice is skipped
- `{}`,
- },
- {
- struct {
- A string
- }{"foo"},
- // structs not of a named type get no prefix
- `{A:"foo"}`,
- },
-
- // pointers
- {nilPointer, ``},
- {String("foo"), `"foo"`},
- {Int(123), `123`},
- {Bool(false), `false`},
- {
- []*string{String("a"), String("b")},
- `["a" "b"]`,
- },
-
- // actual GitHub structs
- {
- Timestamp{time.Date(2006, 01, 02, 15, 04, 05, 0, time.UTC)},
- `github.Timestamp{2006-01-02 15:04:05 +0000 UTC}`,
- },
- {
- &Timestamp{time.Date(2006, 01, 02, 15, 04, 05, 0, time.UTC)},
- `github.Timestamp{2006-01-02 15:04:05 +0000 UTC}`,
- },
- {
- User{ID: Int64(123), Name: String("n")},
- `github.User{ID:123, Name:"n"}`,
- },
- {
- Repository{Owner: &User{ID: Int64(123)}},
- `github.Repository{Owner:github.User{ID:123}}`,
- },
- }
-
- for i, tt := range tests {
- s := Stringify(tt.in)
- if s != tt.out {
- t.Errorf("%d. Stringify(%q) => %q, want %q", i, tt.in, s, tt.out)
- }
- }
-}
-
-// Directly test the String() methods on various GitHub types. We don't do an
-// exaustive test of all the various field types, since TestStringify() above
-// takes care of that. Rather, we just make sure that Stringify() is being
-// used to build the strings, which we do by verifying that pointers are
-// stringified as their underlying value.
-func TestString(t *testing.T) {
- var tests = []struct {
- in interface{}
- out string
- }{
- {CodeResult{Name: String("n")}, `github.CodeResult{Name:"n"}`},
- {CommitAuthor{Name: String("n")}, `github.CommitAuthor{Name:"n"}`},
- {CommitFile{SHA: String("s")}, `github.CommitFile{SHA:"s"}`},
- {CommitStats{Total: Int(1)}, `github.CommitStats{Total:1}`},
- {CommitsComparison{TotalCommits: Int(1)}, `github.CommitsComparison{TotalCommits:1}`},
- {Commit{SHA: String("s")}, `github.Commit{SHA:"s"}`},
- {Event{ID: String("1")}, `github.Event{ID:"1"}`},
- {GistComment{ID: Int64(1)}, `github.GistComment{ID:1}`},
- {GistFile{Size: Int(1)}, `github.GistFile{Size:1}`},
- {Gist{ID: String("1")}, `github.Gist{ID:"1", Files:map[]}`},
- {GitObject{SHA: String("s")}, `github.GitObject{SHA:"s"}`},
- {Gitignore{Name: String("n")}, `github.Gitignore{Name:"n"}`},
- {Hook{ID: Int64(1)}, `github.Hook{Config:map[], ID:1}`},
- {IssueComment{ID: Int64(1)}, `github.IssueComment{ID:1}`},
- {Issue{Number: Int(1)}, `github.Issue{Number:1}`},
- {Key{ID: Int64(1)}, `github.Key{ID:1}`},
- {Label{ID: Int64(1), Name: String("l")}, `github.Label{ID:1, Name:"l"}`},
- {Organization{ID: Int64(1)}, `github.Organization{ID:1}`},
- {PullRequestComment{ID: Int64(1)}, `github.PullRequestComment{ID:1}`},
- {PullRequest{Number: Int(1)}, `github.PullRequest{Number:1}`},
- {PullRequestReview{ID: Int64(1)}, `github.PullRequestReview{ID:1}`},
- {DraftReviewComment{Position: Int(1)}, `github.DraftReviewComment{Position:1}`},
- {PullRequestReviewRequest{Body: String("r")}, `github.PullRequestReviewRequest{Body:"r"}`},
- {PullRequestReviewDismissalRequest{Message: String("r")}, `github.PullRequestReviewDismissalRequest{Message:"r"}`},
- {PushEventCommit{SHA: String("s")}, `github.PushEventCommit{SHA:"s"}`},
- {PushEvent{PushID: Int64(1)}, `github.PushEvent{PushID:1}`},
- {Reference{Ref: String("r")}, `github.Reference{Ref:"r"}`},
- {ReleaseAsset{ID: Int64(1)}, `github.ReleaseAsset{ID:1}`},
- {RepoStatus{ID: Int64(1)}, `github.RepoStatus{ID:1}`},
- {RepositoryComment{ID: Int64(1)}, `github.RepositoryComment{ID:1}`},
- {RepositoryCommit{SHA: String("s")}, `github.RepositoryCommit{SHA:"s"}`},
- {RepositoryContent{Name: String("n")}, `github.RepositoryContent{Name:"n"}`},
- {RepositoryRelease{ID: Int64(1)}, `github.RepositoryRelease{ID:1}`},
- {Repository{ID: Int64(1)}, `github.Repository{ID:1}`},
- {Team{ID: Int64(1)}, `github.Team{ID:1}`},
- {TreeEntry{SHA: String("s")}, `github.TreeEntry{SHA:"s"}`},
- {Tree{SHA: String("s")}, `github.Tree{SHA:"s"}`},
- {User{ID: Int64(1)}, `github.User{ID:1}`},
- {WebHookAuthor{Name: String("n")}, `github.WebHookAuthor{Name:"n"}`},
- {WebHookCommit{ID: String("1")}, `github.WebHookCommit{ID:"1"}`},
- {WebHookPayload{Ref: String("r")}, `github.WebHookPayload{Ref:"r"}`},
- }
-
- for i, tt := range tests {
- s := tt.in.(fmt.Stringer).String()
- if s != tt.out {
- t.Errorf("%d. String() => %q, want %q", i, tt.in, tt.out)
- }
- }
-}
diff --git a/vendor/github.com/google/go-github/github/timestamp_test.go b/vendor/github.com/google/go-github/github/timestamp_test.go
deleted file mode 100644
index ea7fa0eb..00000000
--- a/vendor/github.com/google/go-github/github/timestamp_test.go
+++ /dev/null
@@ -1,189 +0,0 @@
-// Copyright 2013 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
-
-import (
- "encoding/json"
- "fmt"
- "testing"
- "time"
-)
-
-const (
- emptyTimeStr = `"0001-01-01T00:00:00Z"`
- referenceTimeStr = `"2006-01-02T15:04:05Z"`
- referenceTimeStrFractional = `"2006-01-02T15:04:05.000Z"` // This format was returned by the Projects API before October 1, 2017.
- referenceUnixTimeStr = `1136214245`
-)
-
-var (
- referenceTime = time.Date(2006, 01, 02, 15, 04, 05, 0, time.UTC)
- unixOrigin = time.Unix(0, 0).In(time.UTC)
-)
-
-func TestTimestamp_Marshal(t *testing.T) {
- testCases := []struct {
- desc string
- data Timestamp
- want string
- wantErr bool
- equal bool
- }{
- {"Reference", Timestamp{referenceTime}, referenceTimeStr, false, true},
- {"Empty", Timestamp{}, emptyTimeStr, false, true},
- {"Mismatch", Timestamp{}, referenceTimeStr, false, false},
- }
- for _, tc := range testCases {
- out, err := json.Marshal(tc.data)
- if gotErr := err != nil; gotErr != tc.wantErr {
- t.Errorf("%s: gotErr=%v, wantErr=%v, err=%v", tc.desc, gotErr, tc.wantErr, err)
- }
- got := string(out)
- equal := got == tc.want
- if (got == tc.want) != tc.equal {
- t.Errorf("%s: got=%s, want=%s, equal=%v, want=%v", tc.desc, got, tc.want, equal, tc.equal)
- }
- }
-}
-
-func TestTimestamp_Unmarshal(t *testing.T) {
- testCases := []struct {
- desc string
- data string
- want Timestamp
- wantErr bool
- equal bool
- }{
- {"Reference", referenceTimeStr, Timestamp{referenceTime}, false, true},
- {"ReferenceUnix", referenceUnixTimeStr, Timestamp{referenceTime}, false, true},
- {"ReferenceFractional", referenceTimeStrFractional, Timestamp{referenceTime}, false, true},
- {"Empty", emptyTimeStr, Timestamp{}, false, true},
- {"UnixStart", `0`, Timestamp{unixOrigin}, false, true},
- {"Mismatch", referenceTimeStr, Timestamp{}, false, false},
- {"MismatchUnix", `0`, Timestamp{}, false, false},
- {"Invalid", `"asdf"`, Timestamp{referenceTime}, true, false},
- }
- for _, tc := range testCases {
- var got Timestamp
- err := json.Unmarshal([]byte(tc.data), &got)
- if gotErr := err != nil; gotErr != tc.wantErr {
- t.Errorf("%s: gotErr=%v, wantErr=%v, err=%v", tc.desc, gotErr, tc.wantErr, err)
- continue
- }
- equal := got.Equal(tc.want)
- if equal != tc.equal {
- t.Errorf("%s: got=%#v, want=%#v, equal=%v, want=%v", tc.desc, got, tc.want, equal, tc.equal)
- }
- }
-}
-
-func TestTimstamp_MarshalReflexivity(t *testing.T) {
- testCases := []struct {
- desc string
- data Timestamp
- }{
- {"Reference", Timestamp{referenceTime}},
- {"Empty", Timestamp{}},
- }
- for _, tc := range testCases {
- data, err := json.Marshal(tc.data)
- if err != nil {
- t.Errorf("%s: Marshal err=%v", tc.desc, err)
- }
- var got Timestamp
- err = json.Unmarshal(data, &got)
- if err != nil {
- t.Errorf("%s: Unmarshal err=%v", tc.desc, err)
- }
- if !got.Equal(tc.data) {
- t.Errorf("%s: %+v != %+v", tc.desc, got, data)
- }
- }
-}
-
-type WrappedTimestamp struct {
- A int
- Time Timestamp
-}
-
-func TestWrappedTimstamp_Marshal(t *testing.T) {
- testCases := []struct {
- desc string
- data WrappedTimestamp
- want string
- wantErr bool
- equal bool
- }{
- {"Reference", WrappedTimestamp{0, Timestamp{referenceTime}}, fmt.Sprintf(`{"A":0,"Time":%s}`, referenceTimeStr), false, true},
- {"Empty", WrappedTimestamp{}, fmt.Sprintf(`{"A":0,"Time":%s}`, emptyTimeStr), false, true},
- {"Mismatch", WrappedTimestamp{}, fmt.Sprintf(`{"A":0,"Time":%s}`, referenceTimeStr), false, false},
- }
- for _, tc := range testCases {
- out, err := json.Marshal(tc.data)
- if gotErr := err != nil; gotErr != tc.wantErr {
- t.Errorf("%s: gotErr=%v, wantErr=%v, err=%v", tc.desc, gotErr, tc.wantErr, err)
- }
- got := string(out)
- equal := got == tc.want
- if equal != tc.equal {
- t.Errorf("%s: got=%s, want=%s, equal=%v, want=%v", tc.desc, got, tc.want, equal, tc.equal)
- }
- }
-}
-
-func TestWrappedTimstamp_Unmarshal(t *testing.T) {
- testCases := []struct {
- desc string
- data string
- want WrappedTimestamp
- wantErr bool
- equal bool
- }{
- {"Reference", referenceTimeStr, WrappedTimestamp{0, Timestamp{referenceTime}}, false, true},
- {"ReferenceUnix", referenceUnixTimeStr, WrappedTimestamp{0, Timestamp{referenceTime}}, false, true},
- {"Empty", emptyTimeStr, WrappedTimestamp{0, Timestamp{}}, false, true},
- {"UnixStart", `0`, WrappedTimestamp{0, Timestamp{unixOrigin}}, false, true},
- {"Mismatch", referenceTimeStr, WrappedTimestamp{0, Timestamp{}}, false, false},
- {"MismatchUnix", `0`, WrappedTimestamp{0, Timestamp{}}, false, false},
- {"Invalid", `"asdf"`, WrappedTimestamp{0, Timestamp{referenceTime}}, true, false},
- }
- for _, tc := range testCases {
- var got Timestamp
- err := json.Unmarshal([]byte(tc.data), &got)
- if gotErr := err != nil; gotErr != tc.wantErr {
- t.Errorf("%s: gotErr=%v, wantErr=%v, err=%v", tc.desc, gotErr, tc.wantErr, err)
- continue
- }
- equal := got.Time.Equal(tc.want.Time.Time)
- if equal != tc.equal {
- t.Errorf("%s: got=%#v, want=%#v, equal=%v, want=%v", tc.desc, got, tc.want, equal, tc.equal)
- }
- }
-}
-
-func TestWrappedTimstamp_MarshalReflexivity(t *testing.T) {
- testCases := []struct {
- desc string
- data WrappedTimestamp
- }{
- {"Reference", WrappedTimestamp{0, Timestamp{referenceTime}}},
- {"Empty", WrappedTimestamp{0, Timestamp{}}},
- }
- for _, tc := range testCases {
- bytes, err := json.Marshal(tc.data)
- if err != nil {
- t.Errorf("%s: Marshal err=%v", tc.desc, err)
- }
- var got WrappedTimestamp
- err = json.Unmarshal(bytes, &got)
- if err != nil {
- t.Errorf("%s: Unmarshal err=%v", tc.desc, err)
- }
- if !got.Time.Equal(tc.data.Time) {
- t.Errorf("%s: %+v != %+v", tc.desc, got, tc.data)
- }
- }
-}
diff --git a/vendor/github.com/google/go-github/github/users_administration_test.go b/vendor/github.com/google/go-github/github/users_administration_test.go
deleted file mode 100644
index 4b0955e9..00000000
--- a/vendor/github.com/google/go-github/github/users_administration_test.go
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2014 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
-
-import (
- "context"
- "net/http"
- "testing"
-)
-
-func TestUsersService_PromoteSiteAdmin(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/site_admin", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Users.PromoteSiteAdmin(context.Background(), "u")
- if err != nil {
- t.Errorf("Users.PromoteSiteAdmin returned error: %v", err)
- }
-}
-
-func TestUsersService_DemoteSiteAdmin(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/site_admin", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Users.DemoteSiteAdmin(context.Background(), "u")
- if err != nil {
- t.Errorf("Users.DemoteSiteAdmin returned error: %v", err)
- }
-}
-
-func TestUsersService_Suspend(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/suspended", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Users.Suspend(context.Background(), "u")
- if err != nil {
- t.Errorf("Users.Suspend returned error: %v", err)
- }
-}
-
-func TestUsersService_Unsuspend(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/suspended", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Users.Unsuspend(context.Background(), "u")
- if err != nil {
- t.Errorf("Users.Unsuspend returned error: %v", err)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/users_blocking_test.go b/vendor/github.com/google/go-github/github/users_blocking_test.go
deleted file mode 100644
index 83e8e30c..00000000
--- a/vendor/github.com/google/go-github/github/users_blocking_test.go
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2017 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestUsersService_ListBlockedUsers(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/blocks", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeBlockUsersPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{
- "login": "octocat"
- }]`)
- })
-
- opt := &ListOptions{Page: 2}
- blockedUsers, _, err := client.Users.ListBlockedUsers(context.Background(), opt)
- if err != nil {
- t.Errorf("Users.ListBlockedUsers returned error: %v", err)
- }
-
- want := []*User{{Login: String("octocat")}}
- if !reflect.DeepEqual(blockedUsers, want) {
- t.Errorf("Users.ListBlockedUsers returned %+v, want %+v", blockedUsers, want)
- }
-}
-
-func TestUsersService_IsBlocked(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/blocks/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeBlockUsersPreview)
- w.WriteHeader(http.StatusNoContent)
- })
-
- isBlocked, _, err := client.Users.IsBlocked(context.Background(), "u")
- if err != nil {
- t.Errorf("Users.IsBlocked returned error: %v", err)
- }
- if want := true; isBlocked != want {
- t.Errorf("Users.IsBlocked returned %+v, want %+v", isBlocked, want)
- }
-}
-
-func TestUsersService_BlockUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/blocks/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- testHeader(t, r, "Accept", mediaTypeBlockUsersPreview)
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Users.BlockUser(context.Background(), "u")
- if err != nil {
- t.Errorf("Users.BlockUser returned error: %v", err)
- }
-}
-
-func TestUsersService_UnblockUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/blocks/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeBlockUsersPreview)
- w.WriteHeader(http.StatusNoContent)
- })
-
- _, err := client.Users.UnblockUser(context.Background(), "u")
- if err != nil {
- t.Errorf("Users.UnblockUser returned error: %v", err)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/users_emails_test.go b/vendor/github.com/google/go-github/github/users_emails_test.go
deleted file mode 100644
index 3f72b409..00000000
--- a/vendor/github.com/google/go-github/github/users_emails_test.go
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestUsersService_ListEmails(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/emails", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{
- "email": "user@example.com",
- "verified": false,
- "primary": true
- }]`)
- })
-
- opt := &ListOptions{Page: 2}
- emails, _, err := client.Users.ListEmails(context.Background(), opt)
- if err != nil {
- t.Errorf("Users.ListEmails returned error: %v", err)
- }
-
- want := []*UserEmail{{Email: String("user@example.com"), Verified: Bool(false), Primary: Bool(true)}}
- if !reflect.DeepEqual(emails, want) {
- t.Errorf("Users.ListEmails returned %+v, want %+v", emails, want)
- }
-}
-
-func TestUsersService_AddEmails(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := []string{"new@example.com"}
-
- mux.HandleFunc("/user/emails", func(w http.ResponseWriter, r *http.Request) {
- var v []string
- json.NewDecoder(r.Body).Decode(&v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `[{"email":"old@example.com"}, {"email":"new@example.com"}]`)
- })
-
- emails, _, err := client.Users.AddEmails(context.Background(), input)
- if err != nil {
- t.Errorf("Users.AddEmails returned error: %v", err)
- }
-
- want := []*UserEmail{
- {Email: String("old@example.com")},
- {Email: String("new@example.com")},
- }
- if !reflect.DeepEqual(emails, want) {
- t.Errorf("Users.AddEmails returned %+v, want %+v", emails, want)
- }
-}
-
-func TestUsersService_DeleteEmails(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := []string{"user@example.com"}
-
- mux.HandleFunc("/user/emails", func(w http.ResponseWriter, r *http.Request) {
- var v []string
- json.NewDecoder(r.Body).Decode(&v)
-
- testMethod(t, r, "DELETE")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
- })
-
- _, err := client.Users.DeleteEmails(context.Background(), input)
- if err != nil {
- t.Errorf("Users.DeleteEmails returned error: %v", err)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/users_followers_test.go b/vendor/github.com/google/go-github/github/users_followers_test.go
deleted file mode 100644
index 777fe801..00000000
--- a/vendor/github.com/google/go-github/github/users_followers_test.go
+++ /dev/null
@@ -1,238 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestUsersService_ListFollowers_authenticatedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/followers", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 2}
- users, _, err := client.Users.ListFollowers(context.Background(), "", opt)
- if err != nil {
- t.Errorf("Users.ListFollowers returned error: %v", err)
- }
-
- want := []*User{{ID: Int64(1)}}
- if !reflect.DeepEqual(users, want) {
- t.Errorf("Users.ListFollowers returned %+v, want %+v", users, want)
- }
-}
-
-func TestUsersService_ListFollowers_specifiedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/followers", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- users, _, err := client.Users.ListFollowers(context.Background(), "u", nil)
- if err != nil {
- t.Errorf("Users.ListFollowers returned error: %v", err)
- }
-
- want := []*User{{ID: Int64(1)}}
- if !reflect.DeepEqual(users, want) {
- t.Errorf("Users.ListFollowers returned %+v, want %+v", users, want)
- }
-}
-
-func TestUsersService_ListFollowers_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Users.ListFollowers(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestUsersService_ListFollowing_authenticatedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/following", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opts := &ListOptions{Page: 2}
- users, _, err := client.Users.ListFollowing(context.Background(), "", opts)
- if err != nil {
- t.Errorf("Users.ListFollowing returned error: %v", err)
- }
-
- want := []*User{{ID: Int64(1)}}
- if !reflect.DeepEqual(users, want) {
- t.Errorf("Users.ListFollowing returned %+v, want %+v", users, want)
- }
-}
-
-func TestUsersService_ListFollowing_specifiedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/following", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- users, _, err := client.Users.ListFollowing(context.Background(), "u", nil)
- if err != nil {
- t.Errorf("Users.ListFollowing returned error: %v", err)
- }
-
- want := []*User{{ID: Int64(1)}}
- if !reflect.DeepEqual(users, want) {
- t.Errorf("Users.ListFollowing returned %+v, want %+v", users, want)
- }
-}
-
-func TestUsersService_ListFollowing_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Users.ListFollowing(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestUsersService_IsFollowing_authenticatedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/following/t", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNoContent)
- })
-
- following, _, err := client.Users.IsFollowing(context.Background(), "", "t")
- if err != nil {
- t.Errorf("Users.IsFollowing returned error: %v", err)
- }
- if want := true; following != want {
- t.Errorf("Users.IsFollowing returned %+v, want %+v", following, want)
- }
-}
-
-func TestUsersService_IsFollowing_specifiedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/following/t", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNoContent)
- })
-
- following, _, err := client.Users.IsFollowing(context.Background(), "u", "t")
- if err != nil {
- t.Errorf("Users.IsFollowing returned error: %v", err)
- }
- if want := true; following != want {
- t.Errorf("Users.IsFollowing returned %+v, want %+v", following, want)
- }
-}
-
-func TestUsersService_IsFollowing_false(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/following/t", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- w.WriteHeader(http.StatusNotFound)
- })
-
- following, _, err := client.Users.IsFollowing(context.Background(), "u", "t")
- if err != nil {
- t.Errorf("Users.IsFollowing returned error: %v", err)
- }
- if want := false; following != want {
- t.Errorf("Users.IsFollowing returned %+v, want %+v", following, want)
- }
-}
-
-func TestUsersService_IsFollowing_error(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/following/t", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- http.Error(w, "BadRequest", http.StatusBadRequest)
- })
-
- following, _, err := client.Users.IsFollowing(context.Background(), "u", "t")
- if err == nil {
- t.Errorf("Expected HTTP 400 response")
- }
- if want := false; following != want {
- t.Errorf("Users.IsFollowing returned %+v, want %+v", following, want)
- }
-}
-
-func TestUsersService_IsFollowing_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Users.IsFollowing(context.Background(), "%", "%")
- testURLParseError(t, err)
-}
-
-func TestUsersService_Follow(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/following/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PUT")
- })
-
- _, err := client.Users.Follow(context.Background(), "u")
- if err != nil {
- t.Errorf("Users.Follow returned error: %v", err)
- }
-}
-
-func TestUsersService_Follow_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Users.Follow(context.Background(), "%")
- testURLParseError(t, err)
-}
-
-func TestUsersService_Unfollow(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/following/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Users.Unfollow(context.Background(), "u")
- if err != nil {
- t.Errorf("Users.Follow returned error: %v", err)
- }
-}
-
-func TestUsersService_Unfollow_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, err := client.Users.Unfollow(context.Background(), "%")
- testURLParseError(t, err)
-}
diff --git a/vendor/github.com/google/go-github/github/users_gpg_keys_test.go b/vendor/github.com/google/go-github/github/users_gpg_keys_test.go
deleted file mode 100644
index ca0207eb..00000000
--- a/vendor/github.com/google/go-github/github/users_gpg_keys_test.go
+++ /dev/null
@@ -1,142 +0,0 @@
-// 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestUsersService_ListGPGKeys_authenticatedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/gpg_keys", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGitSigningPreview)
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1,"primary_key_id":2}]`)
- })
-
- opt := &ListOptions{Page: 2}
- keys, _, err := client.Users.ListGPGKeys(context.Background(), "", opt)
- if err != nil {
- t.Errorf("Users.ListGPGKeys returned error: %v", err)
- }
-
- want := []*GPGKey{{ID: Int64(1), PrimaryKeyID: Int64(2)}}
- if !reflect.DeepEqual(keys, want) {
- t.Errorf("Users.ListGPGKeys = %+v, want %+v", keys, want)
- }
-}
-
-func TestUsersService_ListGPGKeys_specifiedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/gpg_keys", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGitSigningPreview)
- fmt.Fprint(w, `[{"id":1,"primary_key_id":2}]`)
- })
-
- keys, _, err := client.Users.ListGPGKeys(context.Background(), "u", nil)
- if err != nil {
- t.Errorf("Users.ListGPGKeys returned error: %v", err)
- }
-
- want := []*GPGKey{{ID: Int64(1), PrimaryKeyID: Int64(2)}}
- if !reflect.DeepEqual(keys, want) {
- t.Errorf("Users.ListGPGKeys = %+v, want %+v", keys, want)
- }
-}
-
-func TestUsersService_ListGPGKeys_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Users.ListGPGKeys(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestUsersService_GetGPGKey(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/gpg_keys/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeGitSigningPreview)
- fmt.Fprint(w, `{"id":1}`)
- })
-
- key, _, err := client.Users.GetGPGKey(context.Background(), 1)
- if err != nil {
- t.Errorf("Users.GetGPGKey returned error: %v", err)
- }
-
- want := &GPGKey{ID: Int64(1)}
- if !reflect.DeepEqual(key, want) {
- t.Errorf("Users.GetGPGKey = %+v, want %+v", key, want)
- }
-}
-
-func TestUsersService_CreateGPGKey(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := `
------BEGIN PGP PUBLIC KEY BLOCK-----
-Comment: GPGTools - https://gpgtools.org
-
-mQINBFcEd9kBEACo54TDbGhKlXKWMvJgecEUKPPcv7XdnpKdGb3LRw5MvFwT0V0f
-...
-=tqfb
------END PGP PUBLIC KEY BLOCK-----`
-
- mux.HandleFunc("/user/gpg_keys", func(w http.ResponseWriter, r *http.Request) {
- var gpgKey struct {
- ArmoredPublicKey *string `json:"armored_public_key,omitempty"`
- }
- json.NewDecoder(r.Body).Decode(&gpgKey)
-
- testMethod(t, r, "POST")
- testHeader(t, r, "Accept", mediaTypeGitSigningPreview)
- if gpgKey.ArmoredPublicKey == nil || *gpgKey.ArmoredPublicKey != input {
- t.Errorf("gpgKey = %+v, want %q", gpgKey, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- gpgKey, _, err := client.Users.CreateGPGKey(context.Background(), input)
- if err != nil {
- t.Errorf("Users.GetGPGKey returned error: %v", err)
- }
-
- want := &GPGKey{ID: Int64(1)}
- if !reflect.DeepEqual(gpgKey, want) {
- t.Errorf("Users.GetGPGKey = %+v, want %+v", gpgKey, want)
- }
-}
-
-func TestUsersService_DeleteGPGKey(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/gpg_keys/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeGitSigningPreview)
- })
-
- _, err := client.Users.DeleteGPGKey(context.Background(), 1)
- if err != nil {
- t.Errorf("Users.DeleteGPGKey returned error: %v", err)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/users_keys_test.go b/vendor/github.com/google/go-github/github/users_keys_test.go
deleted file mode 100644
index 3115fdb2..00000000
--- a/vendor/github.com/google/go-github/github/users_keys_test.go
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestUsersService_ListKeys_authenticatedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/keys", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"page": "2"})
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- opt := &ListOptions{Page: 2}
- keys, _, err := client.Users.ListKeys(context.Background(), "", opt)
- if err != nil {
- t.Errorf("Users.ListKeys returned error: %v", err)
- }
-
- want := []*Key{{ID: Int64(1)}}
- if !reflect.DeepEqual(keys, want) {
- t.Errorf("Users.ListKeys returned %+v, want %+v", keys, want)
- }
-}
-
-func TestUsersService_ListKeys_specifiedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u/keys", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `[{"id":1}]`)
- })
-
- keys, _, err := client.Users.ListKeys(context.Background(), "u", nil)
- if err != nil {
- t.Errorf("Users.ListKeys returned error: %v", err)
- }
-
- want := []*Key{{ID: Int64(1)}}
- if !reflect.DeepEqual(keys, want) {
- t.Errorf("Users.ListKeys returned %+v, want %+v", keys, want)
- }
-}
-
-func TestUsersService_ListKeys_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Users.ListKeys(context.Background(), "%", nil)
- testURLParseError(t, err)
-}
-
-func TestUsersService_GetKey(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/keys/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id":1}`)
- })
-
- key, _, err := client.Users.GetKey(context.Background(), 1)
- if err != nil {
- t.Errorf("Users.GetKey returned error: %v", err)
- }
-
- want := &Key{ID: Int64(1)}
- if !reflect.DeepEqual(key, want) {
- t.Errorf("Users.GetKey returned %+v, want %+v", key, want)
- }
-}
-
-func TestUsersService_CreateKey(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &Key{Key: String("k"), Title: String("t")}
-
- mux.HandleFunc("/user/keys", func(w http.ResponseWriter, r *http.Request) {
- v := new(Key)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "POST")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- key, _, err := client.Users.CreateKey(context.Background(), input)
- if err != nil {
- t.Errorf("Users.GetKey returned error: %v", err)
- }
-
- want := &Key{ID: Int64(1)}
- if !reflect.DeepEqual(key, want) {
- t.Errorf("Users.GetKey returned %+v, want %+v", key, want)
- }
-}
-
-func TestUsersService_DeleteKey(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/keys/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- })
-
- _, err := client.Users.DeleteKey(context.Background(), 1)
- if err != nil {
- t.Errorf("Users.DeleteKey returned error: %v", err)
- }
-}
diff --git a/vendor/github.com/google/go-github/github/users_test.go b/vendor/github.com/google/go-github/github/users_test.go
deleted file mode 100644
index 750b6733..00000000
--- a/vendor/github.com/google/go-github/github/users_test.go
+++ /dev/null
@@ -1,245 +0,0 @@
-// Copyright 2013 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
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestUser_marshall(t *testing.T) {
- testJSONMarshal(t, &User{}, "{}")
-
- u := &User{
- Login: String("l"),
- ID: Int64(1),
- URL: String("u"),
- AvatarURL: String("a"),
- GravatarID: String("g"),
- Name: String("n"),
- Company: String("c"),
- Blog: String("b"),
- Location: String("l"),
- Email: String("e"),
- Hireable: Bool(true),
- PublicRepos: Int(1),
- Followers: Int(1),
- Following: Int(1),
- CreatedAt: &Timestamp{referenceTime},
- SuspendedAt: &Timestamp{referenceTime},
- }
- want := `{
- "login": "l",
- "id": 1,
- "avatar_url": "a",
- "gravatar_id": "g",
- "name": "n",
- "company": "c",
- "blog": "b",
- "location": "l",
- "email": "e",
- "hireable": true,
- "public_repos": 1,
- "followers": 1,
- "following": 1,
- "created_at": ` + referenceTimeStr + `,
- "suspended_at": ` + referenceTimeStr + `,
- "url": "u"
- }`
- testJSONMarshal(t, u, want)
-}
-
-func TestUsersService_Get_authenticatedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id":1}`)
- })
-
- user, _, err := client.Users.Get(context.Background(), "")
- if err != nil {
- t.Errorf("Users.Get returned error: %v", err)
- }
-
- want := &User{ID: Int64(1)}
- if !reflect.DeepEqual(user, want) {
- t.Errorf("Users.Get returned %+v, want %+v", user, want)
- }
-}
-
-func TestUsersService_Get_specifiedUser(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users/u", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id":1}`)
- })
-
- user, _, err := client.Users.Get(context.Background(), "u")
- if err != nil {
- t.Errorf("Users.Get returned error: %v", err)
- }
-
- want := &User{ID: Int64(1)}
- if !reflect.DeepEqual(user, want) {
- t.Errorf("Users.Get returned %+v, want %+v", user, want)
- }
-}
-
-func TestUsersService_Get_invalidUser(t *testing.T) {
- client, _, _, teardown := setup()
- defer teardown()
-
- _, _, err := client.Users.Get(context.Background(), "%")
- testURLParseError(t, err)
-}
-
-func TestUsersService_GetByID(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- fmt.Fprint(w, `{"id":1}`)
- })
-
- user, _, err := client.Users.GetByID(context.Background(), 1)
- if err != nil {
- t.Fatalf("Users.GetByID returned error: %v", err)
- }
-
- want := &User{ID: Int64(1)}
- if !reflect.DeepEqual(user, want) {
- t.Errorf("Users.GetByID returned %+v, want %+v", user, want)
- }
-}
-
-func TestUsersService_Edit(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- input := &User{Name: String("n")}
-
- mux.HandleFunc("/user", func(w http.ResponseWriter, r *http.Request) {
- v := new(User)
- json.NewDecoder(r.Body).Decode(v)
-
- testMethod(t, r, "PATCH")
- if !reflect.DeepEqual(v, input) {
- t.Errorf("Request body = %+v, want %+v", v, input)
- }
-
- fmt.Fprint(w, `{"id":1}`)
- })
-
- user, _, err := client.Users.Edit(context.Background(), input)
- if err != nil {
- t.Errorf("Users.Edit returned error: %v", err)
- }
-
- want := &User{ID: Int64(1)}
- if !reflect.DeepEqual(user, want) {
- t.Errorf("Users.Edit returned %+v, want %+v", user, want)
- }
-}
-
-func TestUsersService_ListAll(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{"since": "1", "page": "2"})
- fmt.Fprint(w, `[{"id":2}]`)
- })
-
- opt := &UserListOptions{1, ListOptions{Page: 2}}
- users, _, err := client.Users.ListAll(context.Background(), opt)
- if err != nil {
- t.Errorf("Users.Get returned error: %v", err)
- }
-
- want := []*User{{ID: Int64(2)}}
- if !reflect.DeepEqual(users, want) {
- t.Errorf("Users.ListAll returned %+v, want %+v", users, want)
- }
-}
-
-func TestUsersService_ListInvitations(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/repository_invitations", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testHeader(t, r, "Accept", mediaTypeRepositoryInvitationsPreview)
- fmt.Fprintf(w, `[{"id":1}, {"id":2}]`)
- })
-
- got, _, err := client.Users.ListInvitations(context.Background(), nil)
- if err != nil {
- t.Errorf("Users.ListInvitations returned error: %v", err)
- }
-
- want := []*RepositoryInvitation{{ID: Int64(1)}, {ID: Int64(2)}}
- if !reflect.DeepEqual(got, want) {
- t.Errorf("Users.ListInvitations = %+v, want %+v", got, want)
- }
-}
-
-func TestUsersService_ListInvitations_withOptions(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/repository_invitations", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "GET")
- testFormValues(t, r, values{
- "page": "2",
- })
- testHeader(t, r, "Accept", mediaTypeRepositoryInvitationsPreview)
- fmt.Fprintf(w, `[{"id":1}, {"id":2}]`)
- })
-
- _, _, err := client.Users.ListInvitations(context.Background(), &ListOptions{Page: 2})
- if err != nil {
- t.Errorf("Users.ListInvitations returned error: %v", err)
- }
-}
-func TestUsersService_AcceptInvitation(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/repository_invitations/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "PATCH")
- testHeader(t, r, "Accept", mediaTypeRepositoryInvitationsPreview)
- w.WriteHeader(http.StatusNoContent)
- })
-
- if _, err := client.Users.AcceptInvitation(context.Background(), 1); err != nil {
- t.Errorf("Users.AcceptInvitation returned error: %v", err)
- }
-}
-
-func TestUsersService_DeclineInvitation(t *testing.T) {
- client, mux, _, teardown := setup()
- defer teardown()
-
- mux.HandleFunc("/user/repository_invitations/1", func(w http.ResponseWriter, r *http.Request) {
- testMethod(t, r, "DELETE")
- testHeader(t, r, "Accept", mediaTypeRepositoryInvitationsPreview)
- w.WriteHeader(http.StatusNoContent)
- })
-
- if _, err := client.Users.DeclineInvitation(context.Background(), 1); err != nil {
- t.Errorf("Users.DeclineInvitation returned error: %v", err)
- }
-}
diff --git a/vendor/github.com/google/go-github/test/README.md b/vendor/github.com/google/go-github/test/README.md
deleted file mode 100644
index cb3ef551..00000000
--- a/vendor/github.com/google/go-github/test/README.md
+++ /dev/null
@@ -1,62 +0,0 @@
-go-github tests
-===============
-
-This directory contains additional test suites beyond the unit tests already in
-[../github](../github). Whereas the unit tests run very quickly (since they
-don't make any network calls) and are run by Travis on every commit, the tests
-in this directory are only run manually.
-
-The test packages are:
-
-integration
------------
-
-This will exercise the entire go-github library (or at least as much as is
-practical) against the live GitHub API. These tests will verify that the
-library is properly coded against the actual behavior of the API, and will
-(hopefully) fail upon any incompatible change in the API.
-
-Because these tests are running using live data, there is a much higher
-probability of false positives in test failures due to network issues, test
-data having been changed, etc.
-
-These tests send real network traffic to the GitHub API and will exhaust the
-default unregistered rate limit (60 requests per hour) very quickly.
-Additionally, in order to test the methods that modify data, a real OAuth token
-will need to be present. While the tests will try to be well-behaved in terms
-of what data they modify, it is **strongly** recommended that these tests only
-be run using a dedicated test account.
-
-Run tests using:
-
- GITHUB_AUTH_TOKEN=XXX go test -v -tags=integration ./integration
-
-Additionally there are a set of integration tests for the Authorizations API.
-These tests require a GitHub user (username and password), and also that a
-[GitHub Application](https://github.com/settings/applications/new) (with
-attendant Client ID and Client Secret) be available. Then, to execute just the
-Authorization tests:
-
- GITHUB_USERNAME='' GITHUB_PASSWORD='' GITHUB_CLIENT_ID='' GITHUB_CLIENT_SECRET='' go test -v -tags=integration -run=Authorizations ./integration
-
-If some or all of these environment variables are not available, certain of the
-Authorization integration tests will be skipped.
-
-fields
-------
-
-This will identify the fields being returned by the live GitHub API that are
-not currently being mapped into the relevant Go data type. Sometimes fields
-are deliberately not mapped, so the results of this tool should just be taken
-as a hint.
-
-This test sends real network traffic to the GitHub API and will exhaust the
-default unregistered rate limit (60 requests per hour) very quickly.
-Additionally, some data is only returned for authenticated API calls. Unlike
-the integration tests above, these tests only read data, so it's less
-imperitive that these be run using a dedicated test account (though you still
-really should).
-
-Run the fields tool using:
-
- GITHUB_AUTH_TOKEN=XXX go run ./fields/fields.go
diff --git a/vendor/github.com/google/go-github/test/fields/fields.go b/vendor/github.com/google/go-github/test/fields/fields.go
deleted file mode 100644
index 7ee1f6e0..00000000
--- a/vendor/github.com/google/go-github/test/fields/fields.go
+++ /dev/null
@@ -1,148 +0,0 @@
-// Copyright 2014 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.
-
-// This tool tests for the JSON mappings in the go-github data types. It will
-// identify fields that are returned by the live GitHub API, but that are not
-// currently mapped into a struct field of the relevant go-github type. This
-// helps to ensure that all relevant data returned by the API is being made
-// accessible, particularly new fields that are periodically (and sometimes
-// quietly) added to the API over time.
-//
-// These tests simply aid in identifying which fields aren't being mapped; it
-// is not necessarily true that every one of them should always be mapped.
-// Some fields may be undocumented for a reason, either because they aren't
-// actually used yet or should not be relied upon.
-package main
-
-import (
- "context"
- "encoding/json"
- "flag"
- "fmt"
- "os"
- "reflect"
- "strings"
-
- "github.com/google/go-github/github"
- "golang.org/x/oauth2"
-)
-
-var (
- client *github.Client
-
- // auth indicates whether tests are being run with an OAuth token.
- // Tests can use this flag to skip certain tests when run without auth.
- auth bool
-
- skipURLs = flag.Bool("skip_urls", false, "skip url fields")
-)
-
-func main() {
- flag.Parse()
-
- token := os.Getenv("GITHUB_AUTH_TOKEN")
- if token == "" {
- print("!!! No OAuth token. Some tests won't run. !!!\n\n")
- client = github.NewClient(nil)
- } else {
- tc := oauth2.NewClient(context.Background(), oauth2.StaticTokenSource(
- &oauth2.Token{AccessToken: token},
- ))
- client = github.NewClient(tc)
- auth = true
- }
-
- for _, tt := range []struct {
- url string
- typ interface{}
- }{
- //{"rate_limit", &github.RateLimits{}},
- {"users/octocat", &github.User{}},
- {"user", &github.User{}},
- {"users/willnorris/keys", &[]github.Key{}},
- {"orgs/google-test", &github.Organization{}},
- {"repos/google/go-github", &github.Repository{}},
- {"repos/google/go-github/issues/1", &github.Issue{}},
- {"/gists/9257657", &github.Gist{}},
- } {
- err := testType(tt.url, tt.typ)
- if err != nil {
- fmt.Printf("error: %v\n", err)
- }
- }
-}
-
-// testType fetches the JSON resource at urlStr and compares its keys to the
-// struct fields of typ.
-func testType(urlStr string, typ interface{}) error {
- slice := reflect.Indirect(reflect.ValueOf(typ)).Kind() == reflect.Slice
-
- req, err := client.NewRequest("GET", urlStr, nil)
- if err != nil {
- return err
- }
-
- // start with a json.RawMessage so we can decode multiple ways below
- raw := new(json.RawMessage)
- _, err = client.Do(context.Background(), req, raw)
- if err != nil {
- return err
- }
-
- // unmarshal directly to a map
- var m1 map[string]interface{}
- if slice {
- var s []map[string]interface{}
- err = json.Unmarshal(*raw, &s)
- if err != nil {
- return err
- }
- m1 = s[0]
- } else {
- err = json.Unmarshal(*raw, &m1)
- if err != nil {
- return err
- }
- }
-
- // unmarshal to typ first, then re-marshal and unmarshal to a map
- err = json.Unmarshal(*raw, typ)
- if err != nil {
- return err
- }
-
- var byt []byte
- if slice {
- // use first item in slice
- v := reflect.Indirect(reflect.ValueOf(typ))
- byt, err = json.Marshal(v.Index(0).Interface())
- if err != nil {
- return err
- }
- } else {
- byt, err = json.Marshal(typ)
- if err != nil {
- return err
- }
- }
-
- var m2 map[string]interface{}
- err = json.Unmarshal(byt, &m2)
- if err != nil {
- return err
- }
-
- // now compare the two maps
- for k, v := range m1 {
- if *skipURLs && strings.HasSuffix(k, "_url") {
- continue
- }
- if _, ok := m2[k]; !ok {
- fmt.Printf("%v missing field for key: %v (example value: %v)\n", reflect.TypeOf(typ), k, v)
- }
- }
-
- return nil
-}
diff --git a/vendor/github.com/google/go-github/test/integration/activity_test.go b/vendor/github.com/google/go-github/test/integration/activity_test.go
deleted file mode 100644
index df6c34d6..00000000
--- a/vendor/github.com/google/go-github/test/integration/activity_test.go
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2014 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.
-
-// +build integration
-
-package integration
-
-import (
- "context"
- "testing"
-
- "github.com/google/go-github/github"
-)
-
-const (
- owner = "google"
- repo = "go-github"
-)
-
-func TestActivity_Starring(t *testing.T) {
- stargazers, _, err := client.Activity.ListStargazers(context.Background(), owner, repo, nil)
- if err != nil {
- t.Fatalf("Activity.ListStargazers returned error: %v", err)
- }
-
- if len(stargazers) == 0 {
- t.Errorf("Activity.ListStargazers(%q, %q) returned no stargazers", owner, repo)
- }
-
- // the rest of the tests requires auth
- if !checkAuth("TestActivity_Starring") {
- return
- }
-
- // first, check if already starred the target repository
- star, _, err := client.Activity.IsStarred(context.Background(), owner, repo)
- if err != nil {
- t.Fatalf("Activity.IsStarred returned error: %v", err)
- }
- if star {
- t.Fatalf("Already starring %v/%v. Please manually unstar it first.", owner, repo)
- }
-
- // star the target repository
- _, err = client.Activity.Star(context.Background(), owner, repo)
- if err != nil {
- t.Fatalf("Activity.Star returned error: %v", err)
- }
-
- // check again and verify starred
- star, _, err = client.Activity.IsStarred(context.Background(), owner, repo)
- if err != nil {
- t.Fatalf("Activity.IsStarred returned error: %v", err)
- }
- if !star {
- t.Fatalf("Not starred %v/%v after starring it.", owner, repo)
- }
-
- // unstar
- _, err = client.Activity.Unstar(context.Background(), owner, repo)
- if err != nil {
- t.Fatalf("Activity.Unstar returned error: %v", err)
- }
-
- // check again and verify not watching
- star, _, err = client.Activity.IsStarred(context.Background(), owner, repo)
- if err != nil {
- t.Fatalf("Activity.IsStarred returned error: %v", err)
- }
- if star {
- t.Fatalf("Still starred %v/%v after unstarring it.", owner, repo)
- }
-}
-
-func deleteSubscription(t *testing.T) {
- // delete subscription
- _, err := client.Activity.DeleteRepositorySubscription(context.Background(), owner, repo)
- if err != nil {
- t.Fatalf("Activity.DeleteRepositorySubscription returned error: %v", err)
- }
-
- // check again and verify not watching
- sub, _, err := client.Activity.GetRepositorySubscription(context.Background(), owner, repo)
- if err != nil {
- t.Fatalf("Activity.GetRepositorySubscription returned error: %v", err)
- }
- if sub != nil {
- t.Fatalf("Still watching %v/%v after deleting subscription.", owner, repo)
- }
-}
-
-func createSubscription(t *testing.T) {
- // watch the target repository
- sub := &github.Subscription{Subscribed: github.Bool(true)}
- _, _, err := client.Activity.SetRepositorySubscription(context.Background(), owner, repo, sub)
- if err != nil {
- t.Fatalf("Activity.SetRepositorySubscription returned error: %v", err)
- }
-
- // check again and verify watching
- sub, _, err = client.Activity.GetRepositorySubscription(context.Background(), owner, repo)
- if err != nil {
- t.Fatalf("Activity.GetRepositorySubscription returned error: %v", err)
- }
- if sub == nil || !*sub.Subscribed {
- t.Fatalf("Not watching %v/%v after setting subscription.", owner, repo)
- }
-}
-
-func TestActivity_Watching(t *testing.T) {
- watchers, _, err := client.Activity.ListWatchers(context.Background(), owner, repo, nil)
- if err != nil {
- t.Fatalf("Activity.ListWatchers returned error: %v", err)
- }
-
- if len(watchers) == 0 {
- t.Errorf("Activity.ListWatchers(%q, %q) returned no watchers", owner, repo)
- }
-
- // the rest of the tests requires auth
- if !checkAuth("TestActivity_Watching") {
- return
- }
-
- // first, check if already watching the target repository
- sub, _, err := client.Activity.GetRepositorySubscription(context.Background(), owner, repo)
- if err != nil {
- t.Fatalf("Activity.GetRepositorySubscription returned error: %v", err)
- }
-
- switch {
- case sub != nil: // If already subscribing, delete then recreate subscription.
- deleteSubscription(t)
- createSubscription(t)
- case sub == nil: // Otherwise, create subscription and then delete it.
- createSubscription(t)
- deleteSubscription(t)
- }
-}
diff --git a/vendor/github.com/google/go-github/test/integration/authorizations_test.go b/vendor/github.com/google/go-github/test/integration/authorizations_test.go
deleted file mode 100644
index 532ac76f..00000000
--- a/vendor/github.com/google/go-github/test/integration/authorizations_test.go
+++ /dev/null
@@ -1,306 +0,0 @@
-// 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.
-
-// +build integration
-
-package integration
-
-import (
- "context"
- "math/rand"
- "os"
- "strconv"
- "strings"
- "testing"
- "time"
-
- "github.com/google/go-github/github"
-)
-
-const msgEnvMissing = "Skipping test because the required environment variable (%v) is not present."
-const envKeyGitHubUsername = "GITHUB_USERNAME"
-const envKeyGitHubPassword = "GITHUB_PASSWORD"
-const envKeyClientID = "GITHUB_CLIENT_ID"
-const envKeyClientSecret = "GITHUB_CLIENT_SECRET"
-const InvalidTokenValue = "iamnotacroken"
-
-// TestAuthorizationsBasicOperations tests the basic CRUD operations of the API (mostly for
-// the Personal Access Token scenario).
-func TestAuthorizationsBasicOperations(t *testing.T) {
-
- client := getUserPassClient(t)
-
- auths, resp, err := client.Authorizations.List(context.Background(), nil)
- failOnError(t, err)
- failIfNotStatusCode(t, resp, 200)
-
- initialAuthCount := len(auths)
-
- authReq := generatePersonalAuthTokenRequest()
-
- createdAuth, resp, err := client.Authorizations.Create(context.Background(), authReq)
- failOnError(t, err)
- failIfNotStatusCode(t, resp, 201)
-
- if *authReq.Note != *createdAuth.Note {
- t.Fatal("Returned Authorization does not match the requested Authorization.")
- }
-
- auths, resp, err = client.Authorizations.List(context.Background(), nil)
- failOnError(t, err)
- failIfNotStatusCode(t, resp, 200)
-
- if len(auths) != initialAuthCount+1 {
- t.Fatalf("The number of Authorizations should have increased. Expected [%v], was [%v]", initialAuthCount+1, len(auths))
- }
-
- // Test updating the authorization
- authUpdate := new(github.AuthorizationUpdateRequest)
- authUpdate.Note = github.String("Updated note: " + randString())
-
- updatedAuth, resp, err := client.Authorizations.Edit(context.Background(), *createdAuth.ID, authUpdate)
- failOnError(t, err)
- failIfNotStatusCode(t, resp, 200)
-
- if *updatedAuth.Note != *authUpdate.Note {
- t.Fatal("The returned Authorization does not match the requested updated value.")
- }
-
- // Verify that the Get operation also reflects the update
- retrievedAuth, resp, err := client.Authorizations.Get(context.Background(), *createdAuth.ID)
- failOnError(t, err)
- failIfNotStatusCode(t, resp, 200)
-
- if *retrievedAuth.Note != *updatedAuth.Note {
- t.Fatal("The retrieved Authorization does not match the expected (updated) value.")
- }
-
- // Now, let's delete...
- resp, err = client.Authorizations.Delete(context.Background(), *createdAuth.ID)
- failOnError(t, err)
- failIfNotStatusCode(t, resp, 204)
-
- // Verify that we can no longer retrieve the auth
- retrievedAuth, resp, err = client.Authorizations.Get(context.Background(), *createdAuth.ID)
- if err == nil {
- t.Fatal("Should have failed due to 404")
- }
- failIfNotStatusCode(t, resp, 404)
-
- // Verify that our count reset back to the initial value
- auths, resp, err = client.Authorizations.List(context.Background(), nil)
- failOnError(t, err)
- failIfNotStatusCode(t, resp, 200)
-
- if len(auths) != initialAuthCount {
- t.Fatalf("The number of Authorizations should match the initial count Expected [%v], got [%v]", initialAuthCount, len(auths))
- }
-
-}
-
-// TestAuthorizationsAppOperations tests the application/token related operations, such
-// as creating, testing, resetting and revoking application OAuth tokens.
-func TestAuthorizationsAppOperations(t *testing.T) {
-
- userAuthenticatedClient := getUserPassClient(t)
-
- appAuthenticatedClient := getOAuthAppClient(t)
-
- // We know these vars are set because getOAuthAppClient would have
- // skipped the test by now
- clientID := os.Getenv(envKeyClientID)
- clientSecret := os.Getenv(envKeyClientSecret)
-
- authRequest := generateAppAuthTokenRequest(clientID, clientSecret)
-
- createdAuth, resp, err := userAuthenticatedClient.Authorizations.GetOrCreateForApp(context.Background(), clientID, authRequest)
- failOnError(t, err)
- failIfNotStatusCode(t, resp, 201)
-
- // Quick sanity check:
- if *createdAuth.Note != *authRequest.Note {
- t.Fatal("The returned auth does not match expected value.")
- }
-
- // Let's try the same request again, this time it should return the same
- // auth instead of creating a new one
- secondAuth, resp, err := userAuthenticatedClient.Authorizations.GetOrCreateForApp(context.Background(), clientID, authRequest)
- failOnError(t, err)
- failIfNotStatusCode(t, resp, 200)
-
- // Verify that the IDs are the same
- if *createdAuth.ID != *secondAuth.ID {
- t.Fatalf("The ID of the second returned auth should be the same as the first. Expected [%v], got [%v]", createdAuth.ID, secondAuth.ID)
- }
-
- // Verify the token
- appAuth, resp, err := appAuthenticatedClient.Authorizations.Check(context.Background(), clientID, *createdAuth.Token)
- failOnError(t, err)
- failIfNotStatusCode(t, resp, 200)
-
- // Quick sanity check
- if *appAuth.ID != *createdAuth.ID || *appAuth.Token != *createdAuth.Token {
- t.Fatal("The returned auth/token does not match.")
- }
-
- // Let's verify that we get a 404 for a non-existent token
- _, resp, err = appAuthenticatedClient.Authorizations.Check(context.Background(), clientID, InvalidTokenValue)
- if err == nil {
- t.Fatal("An error should have been returned because of the invalid token.")
- }
- failIfNotStatusCode(t, resp, 404)
-
- // Let's reset the token
- resetAuth, resp, err := appAuthenticatedClient.Authorizations.Reset(context.Background(), clientID, *createdAuth.Token)
- failOnError(t, err)
- failIfNotStatusCode(t, resp, 200)
-
- // Let's verify that we get a 404 for a non-existent token
- _, resp, err = appAuthenticatedClient.Authorizations.Reset(context.Background(), clientID, InvalidTokenValue)
- if err == nil {
- t.Fatal("An error should have been returned because of the invalid token.")
- }
- failIfNotStatusCode(t, resp, 404)
-
- // Verify that the token has changed
- if resetAuth.Token == createdAuth.Token {
- t.Fatal("The reset token should be different from the original.")
- }
-
- // Verify that we do have a token value
- if *resetAuth.Token == "" {
- t.Fatal("A token value should have been returned.")
- }
-
- // Verify that the original token is now invalid
- _, resp, err = appAuthenticatedClient.Authorizations.Check(context.Background(), clientID, *createdAuth.Token)
- if err == nil {
- t.Fatal("The original token should be invalid.")
- }
- failIfNotStatusCode(t, resp, 404)
-
- // Check that the reset token is valid
- _, resp, err = appAuthenticatedClient.Authorizations.Check(context.Background(), clientID, *resetAuth.Token)
- failOnError(t, err)
- failIfNotStatusCode(t, resp, 200)
-
- // Let's revoke the token
- resp, err = appAuthenticatedClient.Authorizations.Revoke(context.Background(), clientID, *resetAuth.Token)
- failOnError(t, err)
- failIfNotStatusCode(t, resp, 204)
-
- // Sleep for two seconds... I've seen cases where the revocation appears not
- // to have take place immediately.
- time.Sleep(time.Second * 2)
-
- // Now, the reset token should also be invalid
- _, resp, err = appAuthenticatedClient.Authorizations.Check(context.Background(), clientID, *resetAuth.Token)
- if err == nil {
- t.Fatal("The reset token should be invalid.")
- }
- failIfNotStatusCode(t, resp, 404)
-}
-
-// generatePersonalAuthTokenRequest is a helper function that generates an
-// AuthorizationRequest for a Personal Access Token (no client id).
-func generatePersonalAuthTokenRequest() *github.AuthorizationRequest {
-
- rand := randString()
- auth := github.AuthorizationRequest{
- Note: github.String("Personal token: Note generated by test: " + rand),
- Scopes: []github.Scope{github.ScopePublicRepo},
- Fingerprint: github.String("Personal token: Fingerprint generated by test: " + rand),
- }
-
- return &auth
-}
-
-// generatePersonalAuthTokenRequest is a helper function that generates an
-// AuthorizationRequest for an OAuth application Token (uses client id).
-func generateAppAuthTokenRequest(clientID string, clientSecret string) *github.AuthorizationRequest {
-
- rand := randString()
- auth := github.AuthorizationRequest{
- Note: github.String("App token: Note generated by test: " + rand),
- Scopes: []github.Scope{github.ScopePublicRepo},
- Fingerprint: github.String("App token: Fingerprint generated by test: " + rand),
- ClientID: github.String(clientID),
- ClientSecret: github.String(clientSecret),
- }
-
- return &auth
-}
-
-// randString returns a (kinda) random string for uniqueness purposes.
-func randString() string {
- return strconv.FormatInt(rand.NewSource(time.Now().UnixNano()).Int63(), 10)
-}
-
-// failOnError invokes t.Fatal() if err is present.
-func failOnError(t *testing.T, err error) {
-
- if err != nil {
- t.Fatal(err)
- }
-}
-
-// failIfNotStatusCode invokes t.Fatal() if the response's status code doesn't match the expected code.
-func failIfNotStatusCode(t *testing.T, resp *github.Response, expectedCode int) {
-
- if resp.StatusCode != expectedCode {
- t.Fatalf("Expected HTTP status code [%v] but received [%v]", expectedCode, resp.StatusCode)
- }
-
-}
-
-// getUserPassClient returns a GitHub client for authorization testing. The client
-// uses BasicAuth via GH username and password passed in environment variables
-// (and will skip the calling test if those vars are not present).
-func getUserPassClient(t *testing.T) *github.Client {
- username, ok := os.LookupEnv(envKeyGitHubUsername)
- if !ok {
- t.Skipf(msgEnvMissing, envKeyGitHubUsername)
- }
-
- password, ok := os.LookupEnv(envKeyGitHubPassword)
- if !ok {
- t.Skipf(msgEnvMissing, envKeyGitHubPassword)
- }
-
- tp := github.BasicAuthTransport{
- Username: strings.TrimSpace(username),
- Password: strings.TrimSpace(password),
- }
-
- return github.NewClient(tp.Client())
-}
-
-// getOAuthAppClient returns a GitHub client for authorization testing. The client
-// uses BasicAuth, but instead of username and password, it uses the client id
-// and client secret passed in via environment variables
-// (and will skip the calling test if those vars are not present). Certain API operations (check
-// an authorization; reset an authorization; revoke an authorization for an app)
-// require this authentication mechanism.
-//
-// See GitHub API docs: https://developer.com/v3/oauth_authorizations/#check-an-authorization
-func getOAuthAppClient(t *testing.T) *github.Client {
-
- username, ok := os.LookupEnv(envKeyClientID)
- if !ok {
- t.Skipf(msgEnvMissing, envKeyClientID)
- }
-
- password, ok := os.LookupEnv(envKeyClientSecret)
- if !ok {
- t.Skipf(msgEnvMissing, envKeyClientSecret)
- }
-
- tp := github.BasicAuthTransport{
- Username: strings.TrimSpace(username),
- Password: strings.TrimSpace(password),
- }
-
- return github.NewClient(tp.Client())
-}
diff --git a/vendor/github.com/google/go-github/test/integration/doc.go b/vendor/github.com/google/go-github/test/integration/doc.go
deleted file mode 100644
index 5ee470c5..00000000
--- a/vendor/github.com/google/go-github/test/integration/doc.go
+++ /dev/null
@@ -1,11 +0,0 @@
-// 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 integration contains integration tests.
-//
-// These tests call the live GitHub API, and therefore require a little more
-// setup to run. See https://github.com/google/go-github/tree/master/test#integration
-// for more information.
-package integration
diff --git a/vendor/github.com/google/go-github/test/integration/github_test.go b/vendor/github.com/google/go-github/test/integration/github_test.go
deleted file mode 100644
index 489d38a4..00000000
--- a/vendor/github.com/google/go-github/test/integration/github_test.go
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2014 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.
-
-// +build integration
-
-package integration
-
-import (
- "context"
- "fmt"
- "math/rand"
- "net/http"
- "os"
-
- "github.com/google/go-github/github"
- "golang.org/x/oauth2"
-)
-
-var (
- client *github.Client
-
- // auth indicates whether tests are being run with an OAuth token.
- // Tests can use this flag to skip certain tests when run without auth.
- auth bool
-)
-
-func init() {
- token := os.Getenv("GITHUB_AUTH_TOKEN")
- if token == "" {
- print("!!! No OAuth token. Some tests won't run. !!!\n\n")
- client = github.NewClient(nil)
- } else {
- tc := oauth2.NewClient(context.Background(), oauth2.StaticTokenSource(
- &oauth2.Token{AccessToken: token},
- ))
- client = github.NewClient(tc)
- auth = true
- }
-
- // Environment variables required for Authorization integration tests
- vars := []string{envKeyGitHubUsername, envKeyGitHubPassword, envKeyClientID, envKeyClientSecret}
-
- for _, v := range vars {
- value := os.Getenv(v)
- if value == "" {
- print("!!! " + fmt.Sprintf(msgEnvMissing, v) + " !!!\n\n")
- }
- }
-
-}
-
-func checkAuth(name string) bool {
- if !auth {
- fmt.Printf("No auth - skipping portions of %v\n", name)
- }
- return auth
-}
-
-func createRandomTestRepository(owner string, autoinit bool) (*github.Repository, error) {
- // create random repo name that does not currently exist
- var repoName string
- for {
- repoName = fmt.Sprintf("test-%d", rand.Int())
- _, resp, err := client.Repositories.Get(context.Background(), owner, repoName)
- if err != nil {
- if resp.StatusCode == http.StatusNotFound {
- // found a non-existent repo, perfect
- break
- }
-
- return nil, err
- }
- }
-
- // create the repository
- repo, _, err := client.Repositories.Create(context.Background(), "", &github.Repository{Name: github.String(repoName), AutoInit: github.Bool(autoinit)})
- if err != nil {
- return nil, err
- }
-
- return repo, nil
-}
diff --git a/vendor/github.com/google/go-github/test/integration/issues_test.go b/vendor/github.com/google/go-github/test/integration/issues_test.go
deleted file mode 100644
index a5e48900..00000000
--- a/vendor/github.com/google/go-github/test/integration/issues_test.go
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2014 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.
-
-// +build integration
-
-package integration
-
-import (
- "context"
- "testing"
-)
-
-func TestIssueEvents(t *testing.T) {
- events, _, err := client.Issues.ListRepositoryEvents(context.Background(), "google", "go-github", nil)
- if err != nil {
- t.Fatalf("Issues.ListRepositoryEvents returned error: %v", err)
- }
-
- if len(events) == 0 {
- t.Errorf("ListRepositoryEvents returned no events")
- }
-
- events, _, err = client.Issues.ListIssueEvents(context.Background(), "google", "go-github", 1, nil)
- if err != nil {
- t.Fatalf("Issues.ListIssueEvents returned error: %v", err)
- }
-
- if len(events) == 0 {
- t.Errorf("ListIssueEvents returned no events")
- }
-
- event, _, err := client.Issues.GetEvent(context.Background(), "google", "go-github", *events[0].ID)
- if err != nil {
- t.Fatalf("Issues.GetEvent returned error: %v", err)
- }
-
- if *event.URL != *events[0].URL {
- t.Fatalf("Issues.GetEvent returned event URL: %v, want %v", *event.URL, *events[0].URL)
- }
-}
diff --git a/vendor/github.com/google/go-github/test/integration/misc_test.go b/vendor/github.com/google/go-github/test/integration/misc_test.go
deleted file mode 100644
index 1595cf07..00000000
--- a/vendor/github.com/google/go-github/test/integration/misc_test.go
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2014 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.
-
-// +build integration
-
-package integration
-
-import (
- "context"
- "testing"
- "time"
-)
-
-func TestEmojis(t *testing.T) {
- emoji, _, err := client.ListEmojis(context.Background())
- if err != nil {
- t.Fatalf("ListEmojis returned error: %v", err)
- }
-
- if len(emoji) == 0 {
- t.Errorf("ListEmojis returned no emojis")
- }
-
- if _, ok := emoji["+1"]; !ok {
- t.Errorf("ListEmojis missing '+1' emoji")
- }
-}
-
-func TestAPIMeta(t *testing.T) {
- meta, _, err := client.APIMeta(context.Background())
- if err != nil {
- t.Fatalf("APIMeta returned error: %v", err)
- }
-
- if len(meta.Hooks) == 0 {
- t.Errorf("APIMeta returned no hook addresses")
- }
-
- if len(meta.Git) == 0 {
- t.Errorf("APIMeta returned no git addresses")
- }
-
- if !*meta.VerifiablePasswordAuthentication {
- t.Errorf("APIMeta VerifiablePasswordAuthentication is false")
- }
-}
-
-func TestRateLimits(t *testing.T) {
- limits, _, err := client.RateLimits(context.Background())
- if err != nil {
- t.Fatalf("RateLimits returned error: %v", err)
- }
-
- // do some sanity checks
- if limits.Core.Limit == 0 {
- t.Errorf("RateLimits returned 0 core limit")
- }
-
- if limits.Core.Limit < limits.Core.Remaining {
- t.Errorf("Core.Limits is less than Core.Remaining.")
- }
-
- if limits.Core.Reset.Time.Before(time.Now().Add(-1 * time.Minute)) {
- t.Errorf("Core.Reset is more than 1 minute in the past; that doesn't seem right.")
- }
-}
-
-func TestListServiceHooks(t *testing.T) {
- hooks, _, err := client.ListServiceHooks(context.Background())
- if err != nil {
- t.Fatalf("ListServiceHooks returned error: %v", err)
- }
-
- if len(hooks) == 0 {
- t.Fatalf("ListServiceHooks returned no hooks")
- }
-}
diff --git a/vendor/github.com/google/go-github/test/integration/pulls_test.go b/vendor/github.com/google/go-github/test/integration/pulls_test.go
deleted file mode 100644
index 4aadfbd7..00000000
--- a/vendor/github.com/google/go-github/test/integration/pulls_test.go
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2014 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.
-
-// +build integration
-
-package integration
-
-import (
- "context"
- "testing"
-)
-
-func TestPullRequests_ListCommits(t *testing.T) {
- commits, _, err := client.PullRequests.ListCommits(context.Background(), "google", "go-github", 2, nil)
- if err != nil {
- t.Fatalf("PullRequests.ListCommits() returned error: %v", err)
- }
-
- if got, want := len(commits), 3; got != want {
- t.Fatalf("PullRequests.ListCommits() returned %d commits, want %d", got, want)
- }
-
- if got, want := *commits[0].Author.Login, "sqs"; got != want {
- t.Fatalf("PullRequests.ListCommits()[0].Author.Login returned %v, want %v", got, want)
- }
-}
diff --git a/vendor/github.com/google/go-github/test/integration/repos_test.go b/vendor/github.com/google/go-github/test/integration/repos_test.go
deleted file mode 100644
index 9f3d2322..00000000
--- a/vendor/github.com/google/go-github/test/integration/repos_test.go
+++ /dev/null
@@ -1,190 +0,0 @@
-// Copyright 2014 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.
-
-// +build integration
-
-package integration
-
-import (
- "context"
- "net/http"
- "reflect"
- "testing"
-
- "github.com/google/go-github/github"
-)
-
-func TestRepositories_CRUD(t *testing.T) {
- if !checkAuth("TestRepositories_CRUD") {
- return
- }
-
- // get authenticated user
- me, _, err := client.Users.Get(context.Background(), "")
- if err != nil {
- t.Fatalf("Users.Get('') returned error: %v", err)
- }
-
- repo, err := createRandomTestRepository(*me.Login, false)
- if err != nil {
- t.Fatalf("createRandomTestRepository returned error: %v", err)
- }
-
- // update the repository description
- repo.Description = github.String("description")
- repo.DefaultBranch = nil // FIXME: this shouldn't be necessary
- _, _, err = client.Repositories.Edit(context.Background(), *repo.Owner.Login, *repo.Name, repo)
- if err != nil {
- t.Fatalf("Repositories.Edit() returned error: %v", err)
- }
-
- // delete the repository
- _, err = client.Repositories.Delete(context.Background(), *repo.Owner.Login, *repo.Name)
- if err != nil {
- t.Fatalf("Repositories.Delete() returned error: %v", err)
- }
-
- // verify that the repository was deleted
- _, resp, err := client.Repositories.Get(context.Background(), *repo.Owner.Login, *repo.Name)
- if err == nil {
- t.Fatalf("Test repository still exists after deleting it.")
- }
- if err != nil && resp.StatusCode != http.StatusNotFound {
- t.Fatalf("Repositories.Get() returned error: %v", err)
- }
-}
-
-func TestRepositories_BranchesTags(t *testing.T) {
- // branches
- branches, _, err := client.Repositories.ListBranches(context.Background(), "git", "git", nil)
- if err != nil {
- t.Fatalf("Repositories.ListBranches() returned error: %v", err)
- }
-
- if len(branches) == 0 {
- t.Fatalf("Repositories.ListBranches('git', 'git') returned no branches")
- }
-
- _, _, err = client.Repositories.GetBranch(context.Background(), "git", "git", *branches[0].Name)
- if err != nil {
- t.Fatalf("Repositories.GetBranch() returned error: %v", err)
- }
-
- // tags
- tags, _, err := client.Repositories.ListTags(context.Background(), "git", "git", nil)
- if err != nil {
- t.Fatalf("Repositories.ListTags() returned error: %v", err)
- }
-
- if len(tags) == 0 {
- t.Fatalf("Repositories.ListTags('git', 'git') returned no tags")
- }
-}
-
-func TestRepositories_EditBranches(t *testing.T) {
- if !checkAuth("TestRepositories_EditBranches") {
- return
- }
-
- // get authenticated user
- me, _, err := client.Users.Get(context.Background(), "")
- if err != nil {
- t.Fatalf("Users.Get('') returned error: %v", err)
- }
-
- repo, err := createRandomTestRepository(*me.Login, true)
- if err != nil {
- t.Fatalf("createRandomTestRepository returned error: %v", err)
- }
-
- branch, _, err := client.Repositories.GetBranch(context.Background(), *repo.Owner.Login, *repo.Name, "master")
- if err != nil {
- t.Fatalf("Repositories.GetBranch() returned error: %v", err)
- }
-
- if *branch.Protected {
- t.Fatalf("Branch %v of repo %v is already protected", "master", *repo.Name)
- }
-
- // TODO: This test fails with 422 Validation Failed [{Resource: Field: Code: Message:}].
- // Someone familiar with protection requests needs to come up with
- // a valid protection request that doesn't give 422 error.
- protectionRequest := &github.ProtectionRequest{
- RequiredStatusChecks: &github.RequiredStatusChecks{
- Strict: true,
- Contexts: []string{"continuous-integration"},
- },
- RequiredPullRequestReviews: &github.PullRequestReviewsEnforcementRequest{
- DismissalRestrictionsRequest: &github.DismissalRestrictionsRequest{
- Users: []string{},
- Teams: []string{},
- },
- DismissStaleReviews: true,
- },
- EnforceAdmins: true,
- // TODO: Only organization repositories can have users and team restrictions.
- // In order to be able to test these Restrictions, need to add support
- // for creating temporary organization repositories.
- Restrictions: nil,
- }
-
- protection, _, err := client.Repositories.UpdateBranchProtection(context.Background(), *repo.Owner.Login, *repo.Name, "master", protectionRequest)
- if err != nil {
- t.Fatalf("Repositories.UpdateBranchProtection() returned error: %v", err)
- }
-
- want := &github.Protection{
- RequiredStatusChecks: &github.RequiredStatusChecks{
- Strict: true,
- Contexts: []string{"continuous-integration"},
- },
- RequiredPullRequestReviews: &github.PullRequestReviewsEnforcement{
- DismissalRestrictions: github.DismissalRestrictions{
- Users: []*github.User{},
- Teams: []*github.Team{},
- },
- DismissStaleReviews: true,
- },
- EnforceAdmins: &github.AdminEnforcement{
- Enabled: true,
- },
- Restrictions: nil,
- }
- if !reflect.DeepEqual(protection, want) {
- t.Errorf("Repositories.UpdateBranchProtection() returned %+v, want %+v", protection, want)
- }
-
- _, err = client.Repositories.Delete(context.Background(), *repo.Owner.Login, *repo.Name)
- if err != nil {
- t.Fatalf("Repositories.Delete() returned error: %v", err)
- }
-}
-
-func TestRepositories_List(t *testing.T) {
- if !checkAuth("TestRepositories_List") {
- return
- }
-
- _, _, err := client.Repositories.List(context.Background(), "", nil)
- if err != nil {
- t.Fatalf("Repositories.List('') returned error: %v", err)
- }
-
- _, _, err = client.Repositories.List(context.Background(), "google", nil)
- if err != nil {
- t.Fatalf("Repositories.List('google') returned error: %v", err)
- }
-
- opt := github.RepositoryListOptions{Sort: "created"}
- repos, _, err := client.Repositories.List(context.Background(), "google", &opt)
- if err != nil {
- t.Fatalf("Repositories.List('google') with Sort opt returned error: %v", err)
- }
- for i, repo := range repos {
- if i > 0 && (*repos[i-1].CreatedAt).Time.Before((*repo.CreatedAt).Time) {
- t.Fatalf("Repositories.List('google') with default descending Sort returned incorrect order")
- }
- }
-}
diff --git a/vendor/github.com/google/go-github/test/integration/users_test.go b/vendor/github.com/google/go-github/test/integration/users_test.go
deleted file mode 100644
index 3c47c369..00000000
--- a/vendor/github.com/google/go-github/test/integration/users_test.go
+++ /dev/null
@@ -1,244 +0,0 @@
-// Copyright 2014 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.
-
-// +build integration
-
-package integration
-
-import (
- "context"
- "fmt"
- "math/rand"
- "testing"
-
- "github.com/google/go-github/github"
-)
-
-func TestUsers_Get(t *testing.T) {
- // list all users
- users, _, err := client.Users.ListAll(context.Background(), nil)
- if err != nil {
- t.Fatalf("Users.ListAll returned error: %v", err)
- }
-
- if len(users) == 0 {
- t.Errorf("Users.ListAll returned no users")
- }
-
- // mojombo is user #1
- if want := "mojombo"; want != *users[0].Login {
- t.Errorf("user[0].Login was %q, wanted %q", *users[0].Login, want)
- }
-
- // get individual user
- u, _, err := client.Users.Get(context.Background(), "octocat")
- if err != nil {
- t.Fatalf("Users.Get('octocat') returned error: %v", err)
- }
-
- if want := "octocat"; want != *u.Login {
- t.Errorf("user.Login was %q, wanted %q", *u.Login, want)
- }
- if want := "The Octocat"; want != *u.Name {
- t.Errorf("user.Name was %q, wanted %q", *u.Name, want)
- }
-}
-
-func TestUsers_Update(t *testing.T) {
- if !checkAuth("TestUsers_Get") {
- return
- }
-
- u, _, err := client.Users.Get(context.Background(), "")
- if err != nil {
- t.Fatalf("Users.Get('') returned error: %v", err)
- }
-
- if *u.Login == "" {
- t.Errorf("wanted non-empty values for user.Login")
- }
-
- // save original location
- var location string
- if u.Location != nil {
- location = *u.Location
- }
-
- // update location to test value
- testLoc := fmt.Sprintf("test-%d", rand.Int())
- u.Location = &testLoc
-
- _, _, err = client.Users.Edit(context.Background(), u)
- if err != nil {
- t.Fatalf("Users.Update returned error: %v", err)
- }
-
- // refetch user and check location value
- u, _, err = client.Users.Get(context.Background(), "")
- if err != nil {
- t.Fatalf("Users.Get('') returned error: %v", err)
- }
-
- if testLoc != *u.Location {
- t.Errorf("Users.Get('') has location: %v, want: %v", *u.Location, testLoc)
- }
-
- // set location back to the original value
- u.Location = &location
- _, _, err = client.Users.Edit(context.Background(), u)
- if err != nil {
- t.Fatalf("Users.Edit returned error: %v", err)
- }
-}
-
-func TestUsers_Emails(t *testing.T) {
- if !checkAuth("TestUsers_Emails") {
- return
- }
-
- emails, _, err := client.Users.ListEmails(context.Background(), nil)
- if err != nil {
- t.Fatalf("Users.ListEmails() returned error: %v", err)
- }
-
- // create random address not currently in user's emails
- var email string
-EmailLoop:
- for {
- email = fmt.Sprintf("test-%d@example.com", rand.Int())
- for _, e := range emails {
- if e.Email != nil && *e.Email == email {
- continue EmailLoop
- }
- }
- break
- }
-
- // Add new address
- _, _, err = client.Users.AddEmails(context.Background(), []string{email})
- if err != nil {
- t.Fatalf("Users.AddEmails() returned error: %v", err)
- }
-
- // List emails again and verify new email is present
- emails, _, err = client.Users.ListEmails(context.Background(), nil)
- if err != nil {
- t.Fatalf("Users.ListEmails() returned error: %v", err)
- }
-
- var found bool
- for _, e := range emails {
- if e.Email != nil && *e.Email == email {
- found = true
- break
- }
- }
-
- if !found {
- t.Fatalf("Users.ListEmails() does not contain new address: %v", email)
- }
-
- // Remove new address
- _, err = client.Users.DeleteEmails(context.Background(), []string{email})
- if err != nil {
- t.Fatalf("Users.DeleteEmails() returned error: %v", err)
- }
-
- // List emails again and verify new email was removed
- emails, _, err = client.Users.ListEmails(context.Background(), nil)
- if err != nil {
- t.Fatalf("Users.ListEmails() returned error: %v", err)
- }
-
- for _, e := range emails {
- if e.Email != nil && *e.Email == email {
- t.Fatalf("Users.ListEmails() still contains address %v after removing it", email)
- }
- }
-}
-
-func TestUsers_Keys(t *testing.T) {
- keys, _, err := client.Users.ListKeys(context.Background(), "willnorris", nil)
- if err != nil {
- t.Fatalf("Users.ListKeys('willnorris') returned error: %v", err)
- }
-
- if len(keys) == 0 {
- t.Errorf("Users.ListKeys('willnorris') returned no keys")
- }
-
- // the rest of the tests requires auth
- if !checkAuth("TestUsers_Keys") {
- return
- }
-
- // TODO: make this integration test work for any authenticated user.
- keys, _, err = client.Users.ListKeys(context.Background(), "", nil)
- if err != nil {
- t.Fatalf("Users.ListKeys('') returned error: %v", err)
- }
-
- // ssh public key for testing (fingerprint: a7:22:ad:8c:36:9f:68:65:eb:ae:a1:e4:59:73:c1:76)
- key := "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCy/RIqaMFj2wjkOEjx9EAU0ReLAIhodga82/feo5nnT9UUkHLbL9xrIavfdLHx28lD3xYgPfAoSicUMaAeNwuQhmuerr2c2LFGxzrdXP8pVsQ+Ol7y7OdmFPfe0KrzoZaLJs9aSiZ4VKyY4z5Se/k2UgcJTdgQVlLfw/P96aqCx8yUu94BiWqkDqYEvgWKRNHrTiIo1EXeVBCCcfgNZe1suFfNJUJSUU2T3EG2bpwBbSOCjE3FyH8+Lz3K3BOGzm3df8E7Regj9j4YIcD8cWJYO86jLJoGgQ0L5MSOq+ishNaHQXech22Ix03D1lVMjCvDT7S/C94Z1LzhI2lhvyff"
- for _, k := range keys {
- if k.Key != nil && *k.Key == key {
- t.Fatalf("Test key already exists for user. Please manually remove it first.")
- }
- }
-
- // Add new key
- _, _, err = client.Users.CreateKey(context.Background(), &github.Key{
- Title: github.String("go-github test key"),
- Key: github.String(key),
- })
- if err != nil {
- t.Fatalf("Users.CreateKey() returned error: %v", err)
- }
-
- // List keys again and verify new key is present
- keys, _, err = client.Users.ListKeys(context.Background(), "", nil)
- if err != nil {
- t.Fatalf("Users.ListKeys('') returned error: %v", err)
- }
-
- var id int64
- for _, k := range keys {
- if k.Key != nil && *k.Key == key {
- id = *k.ID
- break
- }
- }
-
- if id == 0 {
- t.Fatalf("Users.ListKeys('') does not contain added test key")
- }
-
- // Verify that fetching individual key works
- k, _, err := client.Users.GetKey(context.Background(), id)
- if err != nil {
- t.Fatalf("Users.GetKey(%q) returned error: %v", id, err)
- }
- if *k.Key != key {
- t.Fatalf("Users.GetKey(%q) returned key %v, want %v", id, *k.Key, key)
- }
-
- // Remove test key
- _, err = client.Users.DeleteKey(context.Background(), id)
- if err != nil {
- t.Fatalf("Users.DeleteKey(%d) returned error: %v", id, err)
- }
-
- // List keys again and verify test key was removed
- keys, _, err = client.Users.ListKeys(context.Background(), "", nil)
- if err != nil {
- t.Fatalf("Users.ListKeys('') returned error: %v", err)
- }
-
- for _, k := range keys {
- if k.Key != nil && *k.Key == key {
- t.Fatalf("Users.ListKeys('') still contains test key after removing it")
- }
- }
-}
diff --git a/vendor/github.com/google/go-querystring/.gitignore b/vendor/github.com/google/go-querystring/.gitignore
deleted file mode 100644
index 9ed3b07c..00000000
--- a/vendor/github.com/google/go-querystring/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.test
diff --git a/vendor/github.com/google/go-querystring/CONTRIBUTING.md b/vendor/github.com/google/go-querystring/CONTRIBUTING.md
deleted file mode 100644
index 51cf5cd1..00000000
--- a/vendor/github.com/google/go-querystring/CONTRIBUTING.md
+++ /dev/null
@@ -1,67 +0,0 @@
-# How to contribute #
-
-We'd love to accept your patches and contributions to this project. There are
-a just a few small guidelines you need to follow.
-
-
-## Contributor License Agreement ##
-
-Contributions to any Google project must be accompanied by a Contributor
-License Agreement. This is not a copyright **assignment**, it simply gives
-Google permission to use and redistribute your contributions as part of the
-project.
-
- * If you are an individual writing original source code and you're sure you
- own the intellectual property, then you'll need to sign an [individual
- CLA][].
-
- * If you work for a company that wants to allow you to contribute your work,
- then you'll need to sign a [corporate CLA][].
-
-You generally only need to submit a CLA once, so if you've already submitted
-one (even if it was for a different project), you probably don't need to do it
-again.
-
-[individual CLA]: https://developers.google.com/open-source/cla/individual
-[corporate CLA]: https://developers.google.com/open-source/cla/corporate
-
-
-## Submitting a patch ##
-
- 1. It's generally best to start by opening a new issue describing the bug or
- feature you're intending to fix. Even if you think it's relatively minor,
- it's helpful to know what people are working on. Mention in the initial
- issue that you are planning to work on that bug or feature so that it can
- be assigned to you.
-
- 1. Follow the normal process of [forking][] the project, and setup a new
- branch to work in. It's important that each group of changes be done in
- separate branches in order to ensure that a pull request only includes the
- commits related to that bug or feature.
-
- 1. Go makes it very simple to ensure properly formatted code, so always run
- `go fmt` on your code before committing it. You should also run
- [golint][] over your code. As noted in the [golint readme][], it's not
- strictly necessary that your code be completely "lint-free", but this will
- help you find common style issues.
-
- 1. Any significant changes should almost always be accompanied by tests. The
- project already has good test coverage, so look at some of the existing
- tests if you're unsure how to go about it. [gocov][] and [gocov-html][]
- are invaluable tools for seeing which parts of your code aren't being
- exercised by your tests.
-
- 1. Do your best to have [well-formed commit messages][] for each change.
- This provides consistency throughout the project, and ensures that commit
- messages are able to be formatted properly by various git tools.
-
- 1. Finally, push the commits to your fork and submit a [pull request][].
-
-[forking]: https://help.github.com/articles/fork-a-repo
-[golint]: https://github.com/golang/lint
-[golint readme]: https://github.com/golang/lint/blob/master/README
-[gocov]: https://github.com/axw/gocov
-[gocov-html]: https://github.com/matm/gocov-html
-[well-formed commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
-[squash]: http://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits
-[pull request]: https://help.github.com/articles/creating-a-pull-request
diff --git a/vendor/github.com/google/go-querystring/README.md b/vendor/github.com/google/go-querystring/README.md
deleted file mode 100644
index 03e93703..00000000
--- a/vendor/github.com/google/go-querystring/README.md
+++ /dev/null
@@ -1,39 +0,0 @@
-# go-querystring #
-
-go-querystring is Go library for encoding structs into URL query parameters.
-
-
-**Documentation:**
-**Build Status:** [](https://drone.io/github.com/google/go-querystring/latest)
-
-## Usage ##
-
-```go
-import "github.com/google/go-querystring/query"
-```
-
-go-querystring is designed to assist in scenarios where you want to construct a
-URL using a struct that represents the URL query parameters. You might do this
-to enforce the type safety of your parameters, for example, as is done in the
-[go-github][] library.
-
-The query package exports a single `Values()` function. A simple example:
-
-```go
-type Options struct {
- Query string `url:"q"`
- ShowAll bool `url:"all"`
- Page int `url:"page"`
-}
-
-opt := Options{ "foo", true, 2 }
-v, _ := query.Values(opt)
-fmt.Print(v.Encode()) // will output: "q=foo&all=true&page=2"
-```
-
-[go-github]: https://github.com/google/go-github/commit/994f6f8405f052a117d2d0b500054341048fbb08
-
-## License ##
-
-This library is distributed under the BSD-style license found in the [LICENSE](./LICENSE)
-file.
diff --git a/vendor/github.com/google/go-querystring/query/encode_test.go b/vendor/github.com/google/go-querystring/query/encode_test.go
deleted file mode 100644
index 0f26a775..00000000
--- a/vendor/github.com/google/go-querystring/query/encode_test.go
+++ /dev/null
@@ -1,328 +0,0 @@
-// Copyright 2013 The Go 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 query
-
-import (
- "fmt"
- "net/url"
- "reflect"
- "testing"
- "time"
-)
-
-type Nested struct {
- A SubNested `url:"a"`
- B *SubNested `url:"b"`
- Ptr *SubNested `url:"ptr,omitempty"`
-}
-
-type SubNested struct {
- Value string `url:"value"`
-}
-
-func TestValues_types(t *testing.T) {
- str := "string"
- strPtr := &str
- timeVal := time.Date(2000, 1, 1, 12, 34, 56, 0, time.UTC)
-
- tests := []struct {
- in interface{}
- want url.Values
- }{
- {
- // basic primitives
- struct {
- A string
- B int
- C uint
- D float32
- E bool
- }{},
- url.Values{
- "A": {""},
- "B": {"0"},
- "C": {"0"},
- "D": {"0"},
- "E": {"false"},
- },
- },
- {
- // pointers
- struct {
- A *string
- B *int
- C **string
- D *time.Time
- }{
- A: strPtr,
- C: &strPtr,
- D: &timeVal,
- },
- url.Values{
- "A": {str},
- "B": {""},
- "C": {str},
- "D": {"2000-01-01T12:34:56Z"},
- },
- },
- {
- // slices and arrays
- struct {
- A []string
- B []string `url:",comma"`
- C []string `url:",space"`
- D [2]string
- E [2]string `url:",comma"`
- F [2]string `url:",space"`
- G []*string `url:",space"`
- H []bool `url:",int,space"`
- I []string `url:",brackets"`
- J []string `url:",semicolon"`
- K []string `url:",numbered"`
- }{
- A: []string{"a", "b"},
- B: []string{"a", "b"},
- C: []string{"a", "b"},
- D: [2]string{"a", "b"},
- E: [2]string{"a", "b"},
- F: [2]string{"a", "b"},
- G: []*string{&str, &str},
- H: []bool{true, false},
- I: []string{"a", "b"},
- J: []string{"a", "b"},
- K: []string{"a", "b"},
- },
- url.Values{
- "A": {"a", "b"},
- "B": {"a,b"},
- "C": {"a b"},
- "D": {"a", "b"},
- "E": {"a,b"},
- "F": {"a b"},
- "G": {"string string"},
- "H": {"1 0"},
- "I[]": {"a", "b"},
- "J": {"a;b"},
- "K0": {"a"},
- "K1": {"b"},
- },
- },
- {
- // other types
- struct {
- A time.Time
- B time.Time `url:",unix"`
- C bool `url:",int"`
- D bool `url:",int"`
- }{
- A: time.Date(2000, 1, 1, 12, 34, 56, 0, time.UTC),
- B: time.Date(2000, 1, 1, 12, 34, 56, 0, time.UTC),
- C: true,
- D: false,
- },
- url.Values{
- "A": {"2000-01-01T12:34:56Z"},
- "B": {"946730096"},
- "C": {"1"},
- "D": {"0"},
- },
- },
- {
- struct {
- Nest Nested `url:"nest"`
- }{
- Nested{
- A: SubNested{
- Value: "that",
- },
- },
- },
- url.Values{
- "nest[a][value]": {"that"},
- "nest[b]": {""},
- },
- },
- {
- struct {
- Nest Nested `url:"nest"`
- }{
- Nested{
- Ptr: &SubNested{
- Value: "that",
- },
- },
- },
- url.Values{
- "nest[a][value]": {""},
- "nest[b]": {""},
- "nest[ptr][value]": {"that"},
- },
- },
- {
- nil,
- url.Values{},
- },
- }
-
- for i, tt := range tests {
- v, err := Values(tt.in)
- if err != nil {
- t.Errorf("%d. Values(%q) returned error: %v", i, tt.in, err)
- }
-
- if !reflect.DeepEqual(tt.want, v) {
- t.Errorf("%d. Values(%q) returned %v, want %v", i, tt.in, v, tt.want)
- }
- }
-}
-
-func TestValues_omitEmpty(t *testing.T) {
- str := ""
- s := struct {
- a string
- A string
- B string `url:",omitempty"`
- C string `url:"-"`
- D string `url:"omitempty"` // actually named omitempty, not an option
- E *string `url:",omitempty"`
- }{E: &str}
-
- v, err := Values(s)
- if err != nil {
- t.Errorf("Values(%q) returned error: %v", s, err)
- }
-
- want := url.Values{
- "A": {""},
- "omitempty": {""},
- "E": {""}, // E is included because the pointer is not empty, even though the string being pointed to is
- }
- if !reflect.DeepEqual(want, v) {
- t.Errorf("Values(%q) returned %v, want %v", s, v, want)
- }
-}
-
-type A struct {
- B
-}
-
-type B struct {
- C string
-}
-
-type D struct {
- B
- C string
-}
-
-type e struct {
- B
- C string
-}
-
-type F struct {
- e
-}
-
-func TestValues_embeddedStructs(t *testing.T) {
- tests := []struct {
- in interface{}
- want url.Values
- }{
- {
- A{B{C: "foo"}},
- url.Values{"C": {"foo"}},
- },
- {
- D{B: B{C: "bar"}, C: "foo"},
- url.Values{"C": {"foo", "bar"}},
- },
- {
- F{e{B: B{C: "bar"}, C: "foo"}}, // With unexported embed
- url.Values{"C": {"foo", "bar"}},
- },
- }
-
- for i, tt := range tests {
- v, err := Values(tt.in)
- if err != nil {
- t.Errorf("%d. Values(%q) returned error: %v", i, tt.in, err)
- }
-
- if !reflect.DeepEqual(tt.want, v) {
- t.Errorf("%d. Values(%q) returned %v, want %v", i, tt.in, v, tt.want)
- }
- }
-}
-
-func TestValues_invalidInput(t *testing.T) {
- _, err := Values("")
- if err == nil {
- t.Errorf("expected Values() to return an error on invalid input")
- }
-}
-
-type EncodedArgs []string
-
-func (m EncodedArgs) EncodeValues(key string, v *url.Values) error {
- for i, arg := range m {
- v.Set(fmt.Sprintf("%s.%d", key, i), arg)
- }
- return nil
-}
-
-func TestValues_Marshaler(t *testing.T) {
- s := struct {
- Args EncodedArgs `url:"arg"`
- }{[]string{"a", "b", "c"}}
- v, err := Values(s)
- if err != nil {
- t.Errorf("Values(%q) returned error: %v", s, err)
- }
-
- want := url.Values{
- "arg.0": {"a"},
- "arg.1": {"b"},
- "arg.2": {"c"},
- }
- if !reflect.DeepEqual(want, v) {
- t.Errorf("Values(%q) returned %v, want %v", s, v, want)
- }
-}
-
-func TestValues_MarshalerWithNilPointer(t *testing.T) {
- s := struct {
- Args *EncodedArgs `url:"arg"`
- }{}
- v, err := Values(s)
- if err != nil {
- t.Errorf("Values(%q) returned error: %v", s, err)
- }
-
- want := url.Values{}
- if !reflect.DeepEqual(want, v) {
- t.Errorf("Values(%q) returned %v, want %v", s, v, want)
- }
-}
-
-func TestTagParsing(t *testing.T) {
- name, opts := parseTag("field,foobar,foo")
- if name != "field" {
- t.Fatalf("name = %q, want field", name)
- }
- for _, tt := range []struct {
- opt string
- want bool
- }{
- {"foobar", true},
- {"foo", true},
- {"bar", false},
- {"field", false},
- } {
- if opts.Contains(tt.opt) != tt.want {
- t.Errorf("Contains(%q) = %v", tt.opt, !tt.want)
- }
- }
-}
diff --git a/vendor/github.com/google/gopacket/afpacket/afpacket.go b/vendor/github.com/google/gopacket/afpacket/afpacket.go
deleted file mode 100644
index 13937c1d..00000000
--- a/vendor/github.com/google/gopacket/afpacket/afpacket.go
+++ /dev/null
@@ -1,476 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-// +build linux
-
-// Package afpacket provides Go bindings for MMap'd AF_PACKET socket reading.
-package afpacket
-
-// Couldn't have done this without:
-// http://lxr.free-electrons.com/source/Documentation/networking/packet_mmap.txt
-// http://codemonkeytips.blogspot.co.uk/2011/07/asynchronous-packet-socket-reading-with.html
-
-import (
- "errors"
- "fmt"
- "net"
- "runtime"
- "sync"
- "sync/atomic"
- "time"
- "unsafe"
-
- "golang.org/x/net/bpf"
- "golang.org/x/sys/unix"
-
- "github.com/google/gopacket"
-)
-
-/*
-#include // AF_PACKET, sockaddr_ll
-#include // ETH_P_ALL
-#include // socket()
-#include // close()
-#include // htons()
-#include // mmap(), munmap()
-#include // poll()
-*/
-import "C"
-
-var pageSize = unix.Getpagesize()
-var tpacketAlignment = uint(C.TPACKET_ALIGNMENT)
-
-// ErrPoll returned by poll
-var ErrPoll = errors.New("packet poll failed")
-
-// ErrTimeout returned on poll timeout
-var ErrTimeout = errors.New("packet poll timeout expired")
-
-func tpacketAlign(v int) int {
- return int((uint(v) + tpacketAlignment - 1) & ((^tpacketAlignment) - 1))
-}
-
-// Stats is a set of counters detailing the work TPacket has done so far.
-type Stats struct {
- // Packets is the total number of packets returned to the caller.
- Packets int64
- // Polls is the number of blocking syscalls made waiting for packets.
- // This should always be <= Packets, since with TPacket one syscall
- // can (and often does) return many results.
- Polls int64
-}
-
-// SocketStats is a struct where socket stats are stored
-type SocketStats C.struct_tpacket_stats
-
-// SocketStatsV3 is a struct where socket stats for TPacketV3 are stored
-type SocketStatsV3 C.struct_tpacket_stats_v3
-
-// TPacket implements packet receiving for Linux AF_PACKET versions 1, 2, and 3.
-type TPacket struct {
- // fd is the C file descriptor.
- fd int
- // ring points to the memory space of the ring buffer shared by tpacket and the kernel.
- ring []byte
- // rawring is the unsafe pointer that we use to poll for packets
- rawring unsafe.Pointer
- // opts contains read-only options for the TPacket object.
- opts options
- mu sync.Mutex // guards below
- // offset is the offset into the ring of the current header.
- offset int
- // current is the current header.
- current header
- // pollset is used by TPacket for its poll() call.
- pollset unix.PollFd
- // shouldReleasePacket is set to true whenever we return packet data, to make sure we remember to release that data back to the kernel.
- shouldReleasePacket bool
- // headerNextNeeded is set to true when header need to move to the next packet. No need to move it case of poll error.
- headerNextNeeded bool
- // tpVersion is the version of TPacket actually in use, set by setRequestedTPacketVersion.
- tpVersion OptTPacketVersion
- // Hackity hack hack hack. We need to return a pointer to the header with
- // getTPacketHeader, and we don't want to allocate a v3wrapper every time,
- // so we leave it in the TPacket object and return a pointer to it.
- v3 v3wrapper
-
- statsMu sync.Mutex // guards stats below
- // stats is simple statistics on TPacket's run.
- stats Stats
- // socketStats contains stats from the socket
- socketStats SocketStats
- // same as socketStats, but with an extra field freeze_q_cnt
- socketStatsV3 SocketStatsV3
-}
-
-var _ gopacket.ZeroCopyPacketDataSource = &TPacket{}
-
-// bindToInterface binds the TPacket socket to a particular named interface.
-func (h *TPacket) bindToInterface(ifaceName string) error {
- ifIndex := 0
- // An empty string here means to listen to all interfaces
- if ifaceName != "" {
- iface, err := net.InterfaceByName(ifaceName)
- if err != nil {
- return fmt.Errorf("InterfaceByName: %v", err)
- }
- ifIndex = iface.Index
- }
- s := &unix.SockaddrLinklayer{
- Protocol: htons(uint16(unix.ETH_P_ALL)),
- Ifindex: ifIndex,
- }
- return unix.Bind(h.fd, s)
-}
-
-// setTPacketVersion asks the kernel to set TPacket to a particular version, and returns an error on failure.
-func (h *TPacket) setTPacketVersion(version OptTPacketVersion) error {
- if err := unix.SetsockoptInt(h.fd, unix.SOL_PACKET, unix.PACKET_VERSION, int(version)); err != nil {
- return fmt.Errorf("setsockopt packet_version: %v", err)
- }
- return nil
-}
-
-// setRequestedTPacketVersion tries to set TPacket to the requested version or versions.
-func (h *TPacket) setRequestedTPacketVersion() error {
- switch {
- case (h.opts.version == TPacketVersionHighestAvailable || h.opts.version == TPacketVersion3) && h.setTPacketVersion(TPacketVersion3) == nil:
- h.tpVersion = TPacketVersion3
- case (h.opts.version == TPacketVersionHighestAvailable || h.opts.version == TPacketVersion2) && h.setTPacketVersion(TPacketVersion2) == nil:
- h.tpVersion = TPacketVersion2
- case (h.opts.version == TPacketVersionHighestAvailable || h.opts.version == TPacketVersion1) && h.setTPacketVersion(TPacketVersion1) == nil:
- h.tpVersion = TPacketVersion1
- default:
- return errors.New("no known tpacket versions work on this machine")
- }
- return nil
-}
-
-// setUpRing sets up the shared-memory ring buffer between the user process and the kernel.
-func (h *TPacket) setUpRing() (err error) {
- totalSize := int(h.opts.framesPerBlock * h.opts.numBlocks * h.opts.frameSize)
- switch h.tpVersion {
- case TPacketVersion1, TPacketVersion2:
- var tp C.struct_tpacket_req
- tp.tp_block_size = C.uint(h.opts.blockSize)
- tp.tp_block_nr = C.uint(h.opts.numBlocks)
- tp.tp_frame_size = C.uint(h.opts.frameSize)
- tp.tp_frame_nr = C.uint(h.opts.framesPerBlock * h.opts.numBlocks)
- if err := setsockopt(h.fd, unix.SOL_PACKET, unix.PACKET_RX_RING, unsafe.Pointer(&tp), unsafe.Sizeof(tp)); err != nil {
- return fmt.Errorf("setsockopt packet_rx_ring: %v", err)
- }
- case TPacketVersion3:
- var tp C.struct_tpacket_req3
- tp.tp_block_size = C.uint(h.opts.blockSize)
- tp.tp_block_nr = C.uint(h.opts.numBlocks)
- tp.tp_frame_size = C.uint(h.opts.frameSize)
- tp.tp_frame_nr = C.uint(h.opts.framesPerBlock * h.opts.numBlocks)
- tp.tp_retire_blk_tov = C.uint(h.opts.blockTimeout / time.Millisecond)
- if err := setsockopt(h.fd, unix.SOL_PACKET, unix.PACKET_RX_RING, unsafe.Pointer(&tp), unsafe.Sizeof(tp)); err != nil {
- return fmt.Errorf("setsockopt packet_rx_ring v3: %v", err)
- }
- default:
- return errors.New("invalid tpVersion")
- }
- h.ring, err = unix.Mmap(h.fd, 0, totalSize, unix.PROT_READ|unix.PROT_WRITE, unix.MAP_SHARED)
- if err != nil {
- return err
- }
- if h.ring == nil {
- return errors.New("no ring")
- }
- h.rawring = unsafe.Pointer(&h.ring[0])
- return nil
-}
-
-// Close cleans up the TPacket. It should not be used after the Close call.
-func (h *TPacket) Close() {
- if h.fd == -1 {
- return // already closed.
- }
- if h.ring != nil {
- unix.Munmap(h.ring)
- }
- h.ring = nil
- unix.Close(h.fd)
- h.fd = -1
- runtime.SetFinalizer(h, nil)
-}
-
-// NewTPacket returns a new TPacket object for reading packets off the wire.
-// Its behavior may be modified by passing in any/all of afpacket.Opt* to this
-// function.
-// If this function succeeds, the user should be sure to Close the returned
-// TPacket when finished with it.
-func NewTPacket(opts ...interface{}) (h *TPacket, err error) {
- h = &TPacket{}
- if h.opts, err = parseOptions(opts...); err != nil {
- return nil, err
- }
- fd, err := unix.Socket(unix.AF_PACKET, int(h.opts.socktype), int(htons(unix.ETH_P_ALL)))
- if err != nil {
- return nil, err
- }
- h.fd = fd
- if err = h.bindToInterface(h.opts.iface); err != nil {
- goto errlbl
- }
- if err = h.setRequestedTPacketVersion(); err != nil {
- goto errlbl
- }
- if err = h.setUpRing(); err != nil {
- goto errlbl
- }
- // Clear stat counter from socket
- if err = h.InitSocketStats(); err != nil {
- goto errlbl
- }
- runtime.SetFinalizer(h, (*TPacket).Close)
- return h, nil
-errlbl:
- h.Close()
- return nil, err
-}
-
-// SetBPF attaches a BPF filter to the underlying socket
-func (h *TPacket) SetBPF(filter []bpf.RawInstruction) error {
- var p unix.SockFprog
- if len(filter) > int(^uint16(0)) {
- return errors.New("filter too large")
- }
- p.Len = uint16(len(filter))
- p.Filter = (*unix.SockFilter)(unsafe.Pointer(&filter[0]))
-
- return setsockopt(h.fd, unix.SOL_SOCKET, unix.SO_ATTACH_FILTER, unsafe.Pointer(&p), unix.SizeofSockFprog)
-}
-
-func (h *TPacket) releaseCurrentPacket() error {
- h.current.clearStatus()
- h.offset++
- h.shouldReleasePacket = false
- return nil
-}
-
-// ZeroCopyReadPacketData reads the next packet off the wire, and returns its data.
-// The slice returned by ZeroCopyReadPacketData points to bytes owned by the
-// TPacket. Each call to ZeroCopyReadPacketData invalidates any data previously
-// returned by ZeroCopyReadPacketData. Care must be taken not to keep pointers
-// to old bytes when using ZeroCopyReadPacketData... if you need to keep data past
-// the next time you call ZeroCopyReadPacketData, use ReadPacketData, which copies
-// the bytes into a new buffer for you.
-// tp, _ := NewTPacket(...)
-// data1, _, _ := tp.ZeroCopyReadPacketData()
-// // do everything you want with data1 here, copying bytes out of it if you'd like to keep them around.
-// data2, _, _ := tp.ZeroCopyReadPacketData() // invalidates bytes in data1
-func (h *TPacket) ZeroCopyReadPacketData() (data []byte, ci gopacket.CaptureInfo, err error) {
- h.mu.Lock()
-retry:
- if h.current == nil || !h.headerNextNeeded || !h.current.next() {
- if h.shouldReleasePacket {
- h.releaseCurrentPacket()
- }
- h.current = h.getTPacketHeader()
- if err = h.pollForFirstPacket(h.current); err != nil {
- h.headerNextNeeded = false
- h.mu.Unlock()
- return
- }
- // We received an empty block
- if h.current.getLength() == 0 {
- goto retry
- }
- }
- data = h.current.getData()
- ci.Timestamp = h.current.getTime()
- ci.CaptureLength = len(data)
- ci.Length = h.current.getLength()
- ci.InterfaceIndex = h.current.getIfaceIndex()
- atomic.AddInt64(&h.stats.Packets, 1)
- h.headerNextNeeded = true
- h.mu.Unlock()
-
- return
-}
-
-// Stats returns statistics on the packets the TPacket has seen so far.
-func (h *TPacket) Stats() (Stats, error) {
- return Stats{
- Polls: atomic.LoadInt64(&h.stats.Polls),
- Packets: atomic.LoadInt64(&h.stats.Packets),
- }, nil
-}
-
-// InitSocketStats clears socket counters and return empty stats.
-func (h *TPacket) InitSocketStats() error {
- if h.tpVersion == TPacketVersion3 {
- socklen := unsafe.Sizeof(h.socketStatsV3)
- slt := C.socklen_t(socklen)
- var ssv3 SocketStatsV3
-
- err := getsockopt(h.fd, unix.SOL_PACKET, unix.PACKET_STATISTICS, unsafe.Pointer(&ssv3), uintptr(unsafe.Pointer(&slt)))
- if err != nil {
- return err
- }
- h.socketStatsV3 = SocketStatsV3{}
- } else {
- socklen := unsafe.Sizeof(h.socketStats)
- slt := C.socklen_t(socklen)
- var ss SocketStats
-
- err := getsockopt(h.fd, unix.SOL_PACKET, unix.PACKET_STATISTICS, unsafe.Pointer(&ss), uintptr(unsafe.Pointer(&slt)))
- if err != nil {
- return err
- }
- h.socketStats = SocketStats{}
- }
- return nil
-}
-
-// SocketStats saves stats from the socket to the TPacket instance.
-func (h *TPacket) SocketStats() (SocketStats, SocketStatsV3, error) {
- h.statsMu.Lock()
- defer h.statsMu.Unlock()
- // We need to save the counters since asking for the stats will clear them
- if h.tpVersion == TPacketVersion3 {
- socklen := unsafe.Sizeof(h.socketStatsV3)
- slt := C.socklen_t(socklen)
- var ssv3 SocketStatsV3
-
- err := getsockopt(h.fd, unix.SOL_PACKET, unix.PACKET_STATISTICS, unsafe.Pointer(&ssv3), uintptr(unsafe.Pointer(&slt)))
- if err != nil {
- return SocketStats{}, SocketStatsV3{}, err
- }
-
- h.socketStatsV3.tp_packets += ssv3.tp_packets
- h.socketStatsV3.tp_drops += ssv3.tp_drops
- h.socketStatsV3.tp_freeze_q_cnt += ssv3.tp_freeze_q_cnt
- return h.socketStats, h.socketStatsV3, nil
- }
- socklen := unsafe.Sizeof(h.socketStats)
- slt := C.socklen_t(socklen)
- var ss SocketStats
-
- err := getsockopt(h.fd, unix.SOL_PACKET, unix.PACKET_STATISTICS, unsafe.Pointer(&ss), uintptr(unsafe.Pointer(&slt)))
- if err != nil {
- return SocketStats{}, SocketStatsV3{}, err
- }
-
- h.socketStats.tp_packets += ss.tp_packets
- h.socketStats.tp_drops += ss.tp_drops
- return h.socketStats, h.socketStatsV3, nil
-}
-
-// ReadPacketDataTo reads packet data into a user-supplied buffer.
-// This function reads up to the length of the passed-in slice.
-// The number of bytes read into data will be returned in ci.CaptureLength,
-// which is the minimum of the size of the passed-in buffer and the size of
-// the captured packet.
-func (h *TPacket) ReadPacketDataTo(data []byte) (ci gopacket.CaptureInfo, err error) {
- var d []byte
- d, ci, err = h.ZeroCopyReadPacketData()
- if err != nil {
- return
- }
- ci.CaptureLength = copy(data, d)
- return
-}
-
-// ReadPacketData reads the next packet, copies it into a new buffer, and returns
-// that buffer. Since the buffer is allocated by ReadPacketData, it is safe for long-term
-// use. This implements gopacket.PacketDataSource.
-func (h *TPacket) ReadPacketData() (data []byte, ci gopacket.CaptureInfo, err error) {
- var d []byte
- d, ci, err = h.ZeroCopyReadPacketData()
- if err != nil {
- return
- }
- data = make([]byte, len(d))
- copy(data, d)
- return
-}
-
-func (h *TPacket) getTPacketHeader() header {
- switch h.tpVersion {
- case TPacketVersion1:
- if h.offset >= h.opts.framesPerBlock*h.opts.numBlocks {
- h.offset = 0
- }
- position := uintptr(h.rawring) + uintptr(h.opts.frameSize*h.offset)
- return (*v1header)(unsafe.Pointer(position))
- case TPacketVersion2:
- if h.offset >= h.opts.framesPerBlock*h.opts.numBlocks {
- h.offset = 0
- }
- position := uintptr(h.rawring) + uintptr(h.opts.frameSize*h.offset)
- return (*v2header)(unsafe.Pointer(position))
- case TPacketVersion3:
- // TPacket3 uses each block to return values, instead of each frame. Hence we need to rotate when we hit #blocks, not #frames.
- if h.offset >= h.opts.numBlocks {
- h.offset = 0
- }
- position := uintptr(h.rawring) + uintptr(h.opts.frameSize*h.offset*h.opts.framesPerBlock)
- h.v3 = initV3Wrapper(unsafe.Pointer(position))
- return &h.v3
- }
- panic("handle tpacket version is invalid")
-}
-
-func (h *TPacket) pollForFirstPacket(hdr header) error {
- tm := int(h.opts.pollTimeout / time.Millisecond)
- for hdr.getStatus()&C.TP_STATUS_USER == 0 {
- h.pollset.Fd = int32(h.fd)
- h.pollset.Events = unix.POLLIN
- h.pollset.Revents = 0
- n, err := unix.Poll([]unix.PollFd{h.pollset}, tm)
- if n == 0 {
- return ErrTimeout
- }
-
- atomic.AddInt64(&h.stats.Polls, 1)
- if h.pollset.Revents&unix.POLLERR > 0 {
- return ErrPoll
- }
- if err != nil {
- return err
- }
- }
-
- h.shouldReleasePacket = true
- return nil
-}
-
-// FanoutType determines the type of fanout to use with a TPacket SetFanout call.
-type FanoutType int
-
-// FanoutType values.
-const (
- FanoutHash FanoutType = 0
- // It appears that defrag only works with FanoutHash, see:
- // http://lxr.free-electrons.com/source/net/packet/af_packet.c#L1204
- FanoutHashWithDefrag FanoutType = 0x8000
- FanoutLoadBalance FanoutType = 1
- FanoutCPU FanoutType = 2
-)
-
-// SetFanout activates TPacket's fanout ability.
-// Use of Fanout requires creating multiple TPacket objects and the same id/type to
-// a SetFanout call on each. Note that this can be done cross-process, so if two
-// different processes both call SetFanout with the same type/id, they'll share
-// packets between them. The same should work for multiple TPacket objects within
-// the same process.
-func (h *TPacket) SetFanout(t FanoutType, id uint16) error {
- h.mu.Lock()
- defer h.mu.Unlock()
- arg := C.int(t) << 16
- arg |= C.int(id)
- return setsockopt(h.fd, unix.SOL_PACKET, unix.PACKET_FANOUT, unsafe.Pointer(&arg), unsafe.Sizeof(arg))
-}
-
-// WritePacketData transmits a raw packet.
-func (h *TPacket) WritePacketData(pkt []byte) error {
- _, err := unix.Write(h.fd, pkt)
- return err
-}
diff --git a/vendor/github.com/google/gopacket/afpacket/afpacket_test.go b/vendor/github.com/google/gopacket/afpacket/afpacket_test.go
deleted file mode 100644
index 57f6480d..00000000
--- a/vendor/github.com/google/gopacket/afpacket/afpacket_test.go
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-// +build linux
-
-package afpacket
-
-import (
- "reflect"
- "testing"
-)
-
-func TestParseOptions(t *testing.T) {
- wanted1 := defaultOpts
- wanted1.frameSize = 1 << 10
- wanted1.framesPerBlock = wanted1.blockSize / wanted1.frameSize
- for i, test := range []struct {
- opts []interface{}
- want options
- err bool
- }{
- {opts: []interface{}{OptBlockSize(2)}, err: true},
- {opts: []interface{}{OptFrameSize(333)}, err: true},
- {opts: []interface{}{OptTPacketVersion(-3)}, err: true},
- {opts: []interface{}{OptTPacketVersion(5)}, err: true},
- {opts: []interface{}{OptFrameSize(1 << 10)}, want: wanted1},
- } {
- got, err := parseOptions(test.opts...)
- t.Logf("got: %#v\nerr: %v", got, err)
- if test.err && err == nil || !test.err && err != nil {
- t.Errorf("%d error mismatch, want error? %v. error: %v", i, test.err, err)
- }
- if !test.err && !reflect.DeepEqual(test.want, got) {
- t.Errorf("%d opts mismatch, want\n%#v", i, test.want)
- }
- }
-}
diff --git a/vendor/github.com/google/gopacket/afpacket/header.go b/vendor/github.com/google/gopacket/afpacket/header.go
deleted file mode 100644
index 0b9918ec..00000000
--- a/vendor/github.com/google/gopacket/afpacket/header.go
+++ /dev/null
@@ -1,158 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-// +build linux
-
-package afpacket
-
-import (
- "reflect"
- "time"
- "unsafe"
-)
-
-// #include
-import "C"
-
-// Our model of handling all TPacket versions is a little hacky, to say the
-// least. We use the header interface to handle interactions with the
-// tpacket1/tpacket2 packet header AND the tpacket3 block header. The big
-// difference is that tpacket3's block header implements the next() call to get
-// the next packet within the block, while v1/v2 just always return false.
-
-type header interface {
- // getStatus returns the TPacket status of the current header.
- getStatus() int
- // clearStatus clears the status of the current header, releasing its
- // underlying data back to the kernel for future use with new packets.
- // Using the header after calling clearStatus is an error. clearStatus
- // should only be called after next() returns false.
- clearStatus()
- // getTime returns the timestamp for the current packet pointed to by
- // the header.
- getTime() time.Time
- // getData returns the packet data pointed to by the current header.
- getData() []byte
- // getLength returns the total length of the packet.
- getLength() int
- // getIfaceIndex returns the index of the network interface
- // where the packet was seen. The index can later be translated to a name.
- getIfaceIndex() int
- // next moves this header to point to the next packet it contains,
- // returning true on success (in which case getTime and getData will
- // return values for the new packet) or false if there are no more
- // packets (in which case clearStatus should be called).
- next() bool
-}
-
-func tpAlign(x int) int {
- return int((uint(x) + tpacketAlignment - 1) &^ (tpacketAlignment - 1))
-}
-
-type v1header C.struct_tpacket_hdr
-type v2header C.struct_tpacket2_hdr
-
-func makeSlice(start uintptr, length int) (data []byte) {
- slice := (*reflect.SliceHeader)(unsafe.Pointer(&data))
- slice.Data = start
- slice.Len = length
- slice.Cap = length
- return
-}
-
-func (h *v1header) getStatus() int {
- return int(h.tp_status)
-}
-func (h *v1header) clearStatus() {
- h.tp_status = 0
-}
-func (h *v1header) getTime() time.Time {
- return time.Unix(int64(h.tp_sec), int64(h.tp_usec)*1000)
-}
-func (h *v1header) getData() []byte {
- return makeSlice(uintptr(unsafe.Pointer(h))+uintptr(h.tp_mac), int(h.tp_snaplen))
-}
-func (h *v1header) getLength() int {
- return int(h.tp_len)
-}
-func (h *v1header) getIfaceIndex() int {
- ll := (*C.struct_sockaddr_ll)(unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(tpAlign(int(C.sizeof_struct_tpacket_hdr)))))
- return int(ll.sll_ifindex)
-}
-func (h *v1header) next() bool {
- return false
-}
-
-func (h *v2header) getStatus() int {
- return int(h.tp_status)
-}
-func (h *v2header) clearStatus() {
- h.tp_status = 0
-}
-func (h *v2header) getTime() time.Time {
- return time.Unix(int64(h.tp_sec), int64(h.tp_nsec))
-}
-func (h *v2header) getData() []byte {
- return makeSlice(uintptr(unsafe.Pointer(h))+uintptr(h.tp_mac), int(h.tp_snaplen))
-}
-func (h *v2header) getLength() int {
- return int(h.tp_len)
-}
-func (h *v2header) getIfaceIndex() int {
- ll := (*C.struct_sockaddr_ll)(unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(tpAlign(int(C.sizeof_struct_tpacket2_hdr)))))
- return int(ll.sll_ifindex)
-}
-func (h *v2header) next() bool {
- return false
-}
-
-type v3wrapper struct {
- block *C.struct_tpacket_block_desc
- blockhdr *C.struct_tpacket_hdr_v1
- packet *C.struct_tpacket3_hdr
- used C.__u32
-}
-
-func initV3Wrapper(block unsafe.Pointer) (w v3wrapper) {
- w.block = (*C.struct_tpacket_block_desc)(block)
- w.blockhdr = (*C.struct_tpacket_hdr_v1)(unsafe.Pointer(&w.block.hdr[0]))
- w.packet = (*C.struct_tpacket3_hdr)(unsafe.Pointer(uintptr(block) + uintptr(w.blockhdr.offset_to_first_pkt)))
- return
-}
-func (w *v3wrapper) getStatus() int {
- return int(w.blockhdr.block_status)
-}
-func (w *v3wrapper) clearStatus() {
- w.blockhdr.block_status = 0
-}
-func (w *v3wrapper) getTime() time.Time {
- return time.Unix(int64(w.packet.tp_sec), int64(w.packet.tp_nsec))
-}
-func (w *v3wrapper) getData() []byte {
- return makeSlice(uintptr(unsafe.Pointer(w.packet))+uintptr(w.packet.tp_mac), int(w.packet.tp_snaplen))
-}
-func (w *v3wrapper) getLength() int {
- return int(w.packet.tp_len)
-}
-func (w *v3wrapper) getIfaceIndex() int {
- ll := (*C.struct_sockaddr_ll)(unsafe.Pointer(uintptr(unsafe.Pointer(w.packet)) + uintptr(tpAlign(int(C.sizeof_struct_tpacket3_hdr)))))
- return int(ll.sll_ifindex)
-}
-func (w *v3wrapper) next() bool {
- w.used++
- if w.used >= w.blockhdr.num_pkts {
- return false
- }
-
- next := uintptr(unsafe.Pointer(w.packet))
- if w.packet.tp_next_offset != 0 {
- next += uintptr(w.packet.tp_next_offset)
- } else {
- next += uintptr(tpacketAlign(int(w.packet.tp_snaplen) + int(w.packet.tp_mac)))
- }
- w.packet = (*C.struct_tpacket3_hdr)(unsafe.Pointer(next))
- return true
-}
diff --git a/vendor/github.com/google/gopacket/afpacket/options.go b/vendor/github.com/google/gopacket/afpacket/options.go
deleted file mode 100644
index c5ab7719..00000000
--- a/vendor/github.com/google/gopacket/afpacket/options.go
+++ /dev/null
@@ -1,171 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-// +build linux
-
-package afpacket
-
-import (
- "errors"
- "fmt"
- "time"
-)
-
-// #include
-// #include
-import "C"
-
-// OptTPacketVersion is the version of TPacket to use.
-// It can be passed into NewTPacket.
-type OptTPacketVersion int
-
-// String returns a string representation of the version, generally of the form V#.
-func (t OptTPacketVersion) String() string {
- switch t {
- case TPacketVersion1:
- return "V1"
- case TPacketVersion2:
- return "V2"
- case TPacketVersion3:
- return "V3"
- case TPacketVersionHighestAvailable:
- return "HighestAvailable"
- }
- return "InvalidVersion"
-}
-
-// OptSocketType is the socket type used to open the TPacket socket.
-type OptSocketType int
-
-func (t OptSocketType) String() string {
- switch t {
- case SocketRaw:
- return "SOCK_RAW"
- case SocketDgram:
- return "SOCK_DGRAM"
- }
- return "UnknownSocketType"
-}
-
-// TPacket version numbers for use with NewHandle.
-const (
- // TPacketVersionHighestAvailable tells NewHandle to use the highest available version of tpacket the kernel has available.
- // This is the default, should a version number not be given in NewHandle's options.
- TPacketVersionHighestAvailable = OptTPacketVersion(-1)
- TPacketVersion1 = OptTPacketVersion(C.TPACKET_V1)
- TPacketVersion2 = OptTPacketVersion(C.TPACKET_V2)
- TPacketVersion3 = OptTPacketVersion(C.TPACKET_V3)
- tpacketVersionMax = TPacketVersion3
- tpacketVersionMin = -1
- // SocketRaw is the default socket type. It returns packet data
- // including the link layer (ethernet headers, etc).
- SocketRaw = OptSocketType(C.SOCK_RAW)
- // SocketDgram strips off the link layer when reading packets, and adds
- // the link layer back automatically on packet writes (coming soon...)
- SocketDgram = OptSocketType(C.SOCK_DGRAM)
-)
-
-// OptInterface is the specific interface to bind to.
-// It can be passed into NewTPacket.
-type OptInterface string
-
-// OptFrameSize is TPacket's tp_frame_size
-// It can be passed into NewTPacket.
-type OptFrameSize int
-
-// OptBlockSize is TPacket's tp_block_size
-// It can be passed into NewTPacket.
-type OptBlockSize int
-
-// OptNumBlocks is TPacket's tp_block_nr
-// It can be passed into NewTPacket.
-type OptNumBlocks int
-
-// OptBlockTimeout is TPacket v3's tp_retire_blk_tov. Note that it has only millisecond granularity, so must be >= 1 ms.
-// It can be passed into NewTPacket.
-type OptBlockTimeout time.Duration
-
-// OptPollTimeout is the number of milliseconds that poll() should block waiting for a file
-// descriptor to become ready. Specifying a negative value in timeâ€out means an infinite timeout.
-type OptPollTimeout time.Duration
-
-// Default constants used by options.
-const (
- DefaultFrameSize = 4096 // Default value for OptFrameSize.
- DefaultBlockSize = DefaultFrameSize * 128 // Default value for OptBlockSize.
- DefaultNumBlocks = 128 // Default value for OptNumBlocks.
- DefaultBlockTimeout = 64 * time.Millisecond // Default value for OptBlockTimeout.
- DefaultPollTimeout = -1 * time.Millisecond // Default value for OptPollTimeout. This blocks forever.
-)
-
-type options struct {
- frameSize int
- framesPerBlock int
- blockSize int
- numBlocks int
- blockTimeout time.Duration
- pollTimeout time.Duration
- version OptTPacketVersion
- socktype OptSocketType
- iface string
-}
-
-var defaultOpts = options{
- frameSize: DefaultFrameSize,
- blockSize: DefaultBlockSize,
- numBlocks: DefaultNumBlocks,
- blockTimeout: DefaultBlockTimeout,
- pollTimeout: DefaultPollTimeout,
- version: TPacketVersionHighestAvailable,
- socktype: SocketRaw,
-}
-
-func parseOptions(opts ...interface{}) (ret options, err error) {
- ret = defaultOpts
- for _, opt := range opts {
- switch v := opt.(type) {
- case OptFrameSize:
- ret.frameSize = int(v)
- case OptBlockSize:
- ret.blockSize = int(v)
- case OptNumBlocks:
- ret.numBlocks = int(v)
- case OptBlockTimeout:
- ret.blockTimeout = time.Duration(v)
- case OptPollTimeout:
- ret.pollTimeout = time.Duration(v)
- case OptTPacketVersion:
- ret.version = v
- case OptInterface:
- ret.iface = string(v)
- case OptSocketType:
- ret.socktype = v
- default:
- err = errors.New("unknown type in options")
- return
- }
- }
- if err = ret.check(); err != nil {
- return
- }
- ret.framesPerBlock = ret.blockSize / ret.frameSize
- return
-}
-func (o options) check() error {
- switch {
- case o.blockSize%pageSize != 0:
- return fmt.Errorf("block size %d must be divisible by page size %d", o.blockSize, pageSize)
- case o.blockSize%o.frameSize != 0:
- return fmt.Errorf("block size %d must be divisible by frame size %d", o.blockSize, o.frameSize)
- case o.numBlocks < 1:
- return fmt.Errorf("num blocks %d must be >= 1", o.numBlocks)
- case o.blockTimeout < time.Millisecond:
- return fmt.Errorf("block timeout %v must be > %v", o.blockTimeout, time.Millisecond)
- case o.version < tpacketVersionMin || o.version > tpacketVersionMax:
- return fmt.Errorf("tpacket version %v is invalid", o.version)
- }
- return nil
-}
diff --git a/vendor/github.com/google/gopacket/afpacket/sockopt_linux.go b/vendor/github.com/google/gopacket/afpacket/sockopt_linux.go
deleted file mode 100644
index c53e1cce..00000000
--- a/vendor/github.com/google/gopacket/afpacket/sockopt_linux.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-// +build linux
-
-package afpacket
-
-import (
- "unsafe"
-
- "golang.org/x/sys/unix"
-)
-
-// setsockopt provides access to the setsockopt syscall.
-func setsockopt(fd, level, name int, val unsafe.Pointer, vallen uintptr) error {
- _, _, errno := unix.Syscall6(
- unix.SYS_SETSOCKOPT,
- uintptr(fd),
- uintptr(level),
- uintptr(name),
- uintptr(val),
- vallen,
- 0,
- )
- if errno != 0 {
- return error(errno)
- }
-
- return nil
-}
-
-// getsockopt provides access to the getsockopt syscall.
-func getsockopt(fd, level, name int, val unsafe.Pointer, vallen uintptr) error {
- _, _, errno := unix.Syscall6(
- unix.SYS_GETSOCKOPT,
- uintptr(fd),
- uintptr(level),
- uintptr(name),
- uintptr(val),
- vallen,
- 0,
- )
- if errno != 0 {
- return error(errno)
- }
-
- return nil
-}
-
-// htons converts a short (uint16) from host-to-network byte order.
-// Thanks to mikioh for this neat trick:
-// https://github.com/mikioh/-stdyng/blob/master/afpacket.go
-func htons(i uint16) uint16 {
- return (i<<8)&0xff00 | i>>8
-}
diff --git a/vendor/github.com/google/gopacket/afpacket/sockopt_linux_386.go b/vendor/github.com/google/gopacket/afpacket/sockopt_linux_386.go
deleted file mode 100644
index 8c3eb424..00000000
--- a/vendor/github.com/google/gopacket/afpacket/sockopt_linux_386.go
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-// +build linux,386
-
-package afpacket
-
-import (
- "unsafe"
-
- "golang.org/x/sys/unix"
-)
-
-const (
- sysSETSOCKOPT = 0xe
- sysGETSOCKOPT = 0xf
-)
-
-func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, unix.Errno)
-
-// setsockopt provides access to the setsockopt syscall.
-func setsockopt(fd, level, name int, v unsafe.Pointer, l uintptr) error {
- _, errno := socketcall(
- sysSETSOCKOPT,
- uintptr(fd),
- uintptr(level),
- uintptr(name),
- uintptr(v),
- l,
- 0,
- )
- if errno != 0 {
- return error(errno)
- }
-
- return nil
-}
-
-func getsockopt(fd, level, name int, v unsafe.Pointer, l uintptr) error {
- _, errno := socketcall(
- sysGETSOCKOPT,
- uintptr(fd),
- uintptr(level),
- uintptr(name),
- uintptr(v),
- l,
- 0,
- )
- if errno != 0 {
- return error(errno)
- }
-
- return nil
-}
diff --git a/vendor/github.com/google/gopacket/afpacket/sockopt_linux_386.s b/vendor/github.com/google/gopacket/afpacket/sockopt_linux_386.s
deleted file mode 100644
index 7d0336a1..00000000
--- a/vendor/github.com/google/gopacket/afpacket/sockopt_linux_386.s
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-TEXT ·socketcall(SB),4,$0-36
- JMP syscall·socketcall(SB)
\ No newline at end of file
diff --git a/vendor/github.com/google/gopacket/benchmark_test.go b/vendor/github.com/google/gopacket/benchmark_test.go
deleted file mode 100644
index 74a1d28d..00000000
--- a/vendor/github.com/google/gopacket/benchmark_test.go
+++ /dev/null
@@ -1,194 +0,0 @@
-// Copyright 2012, Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package gopacket
-
-import (
- "runtime"
- "testing"
-)
-
-// A few benchmarks for figuring out exactly how fast some underlying Go
-// things are.
-
-type testError struct{}
-
-func (t *testError) Error() string { return "abc" }
-
-func BenchmarkTypeAssertion(b *testing.B) {
- var e error = &testError{}
- for i := 0; i < b.N; i++ {
- _, _ = e.(*testError)
- }
-}
-
-func BenchmarkMapLookup(b *testing.B) {
- m := map[LayerType]bool{
- LayerTypePayload: true,
- }
- for i := 0; i < b.N; i++ {
- _ = m[LayerTypePayload]
- }
-}
-
-func BenchmarkNilMapLookup(b *testing.B) {
- var m map[LayerType]bool
- for i := 0; i < b.N; i++ {
- _ = m[LayerTypePayload]
- }
-}
-
-func BenchmarkNilMapLookupWithNilCheck(b *testing.B) {
- var m map[LayerType]bool
- for i := 0; i < b.N; i++ {
- if m != nil {
- _ = m[LayerTypePayload]
- }
- }
-}
-
-func BenchmarkArrayLookup(b *testing.B) {
- m := make([]bool, 100)
- for i := 0; i < b.N; i++ {
- _ = m[LayerTypePayload]
- }
-}
-
-var testError1 = &testError{}
-var testError2 error = testError1
-
-func BenchmarkTypeToInterface1(b *testing.B) {
- var e error
- for i := 0; i < b.N; i++ {
- e = testError1
- }
- // Have to do someting with 'e' or the compiler complains about an unused
- // variable.
- testError2 = e
-}
-func BenchmarkTypeToInterface2(b *testing.B) {
- var e error
- for i := 0; i < b.N; i++ {
- e = testError2
- }
- // Have to do someting with 'e' or the compiler complains about an unused
- // variable.
- testError2 = e
-}
-
-var decodeOpts DecodeOptions
-
-func decodeOptsByValue(_ DecodeOptions) {}
-func decodeOptsByPointer(_ *DecodeOptions) {}
-func BenchmarkPassDecodeOptionsByValue(b *testing.B) {
- for i := 0; i < b.N; i++ {
- decodeOptsByValue(decodeOpts)
- }
-}
-func BenchmarkPassDecodeOptionsByPointer(b *testing.B) {
- for i := 0; i < b.N; i++ {
- decodeOptsByPointer(&decodeOpts)
- }
-}
-
-func BenchmarkLockOSThread(b *testing.B) {
- for i := 0; i < b.N; i++ {
- runtime.LockOSThread()
- }
-}
-func BenchmarkUnlockOSThread(b *testing.B) {
- for i := 0; i < b.N; i++ {
- runtime.UnlockOSThread()
- }
-}
-func lockUnlock() {
- runtime.LockOSThread()
- runtime.UnlockOSThread()
-}
-func lockDeferUnlock() {
- runtime.LockOSThread()
- defer runtime.UnlockOSThread()
-}
-func BenchmarkLockUnlockOSThread(b *testing.B) {
- for i := 0; i < b.N; i++ {
- lockUnlock()
- }
-}
-func BenchmarkLockDeferUnlockOSThread(b *testing.B) {
- for i := 0; i < b.N; i++ {
- lockDeferUnlock()
- }
-}
-
-func BenchmarkUnbufferedChannel(b *testing.B) {
- ca := make(chan bool)
- cb := make(chan bool)
- defer close(ca)
- go func() {
- defer close(cb)
- for _ = range ca {
- cb <- true
- }
- }()
- for i := 0; i < b.N; i++ {
- ca <- true
- <-cb
- }
-}
-func BenchmarkSmallBufferedChannel(b *testing.B) {
- ca := make(chan bool, 1)
- cb := make(chan bool, 1)
- defer close(ca)
- go func() {
- defer close(cb)
- for _ = range ca {
- cb <- true
- }
- }()
- for i := 0; i < b.N; i++ {
- ca <- true
- <-cb
- }
-}
-func BenchmarkLargeBufferedChannel(b *testing.B) {
- ca := make(chan bool, 1000)
- cb := make(chan bool, 1000)
- defer close(ca)
- go func() {
- defer close(cb)
- for _ = range ca {
- cb <- true
- }
- }()
- for i := 0; i < b.N; i++ {
- ca <- true
- <-cb
- }
-}
-func BenchmarkEndpointFastHashShort(b *testing.B) {
- e := Endpoint{typ: 1, len: 2}
- for i := 0; i < b.N; i++ {
- e.FastHash()
- }
-}
-func BenchmarkEndpointFastHashLong(b *testing.B) {
- e := Endpoint{typ: 1, len: 16}
- for i := 0; i < b.N; i++ {
- e.FastHash()
- }
-}
-func BenchmarkFlowFastHashShort(b *testing.B) {
- e := Flow{typ: 1, slen: 2, dlen: 2}
- for i := 0; i < b.N; i++ {
- e.FastHash()
- }
-}
-func BenchmarkFlowFastHashLong(b *testing.B) {
- e := Flow{typ: 1, slen: 16, dlen: 16}
- for i := 0; i < b.N; i++ {
- e.FastHash()
- }
-}
diff --git a/vendor/github.com/google/gopacket/bsdbpf/bsd_bpf_sniffer.go b/vendor/github.com/google/gopacket/bsdbpf/bsd_bpf_sniffer.go
deleted file mode 100644
index 3e1da0b9..00000000
--- a/vendor/github.com/google/gopacket/bsdbpf/bsd_bpf_sniffer.go
+++ /dev/null
@@ -1,215 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-// +build darwin dragonfly freebsd netbsd openbsd
-
-package bsdbpf
-
-import (
- "errors"
- "fmt"
- "syscall"
- "time"
- "unsafe"
-
- "github.com/google/gopacket"
- "golang.org/x/sys/unix"
-)
-
-const wordSize = int(unsafe.Sizeof(uintptr(0)))
-
-func bpfWordAlign(x int) int {
- return (((x) + (wordSize - 1)) &^ (wordSize - 1))
-}
-
-// Options is used to configure various properties of the BPF sniffer.
-// Default values are used when a nil Options pointer is passed to NewBPFSniffer.
-type Options struct {
- // BPFDeviceName is name of the bpf device to use for sniffing
- // the network device. The default value of BPFDeviceName is empty string
- // which causes the first available BPF device file /dev/bpfX to be used.
- BPFDeviceName string
- // ReadBufLen specifies the size of the buffer used to read packets
- // off the wire such that multiple packets are buffered with each read syscall.
- // Note that an individual packet larger than the buffer size is necessarily truncated.
- // A larger buffer should increase performance because fewer read syscalls would be made.
- // If zero is used, the system's default buffer length will be used which depending on the
- // system may default to 4096 bytes which is not big enough to accomodate some link layers
- // such as WLAN (802.11).
- // ReadBufLen defaults to 32767... however typical BSD manual pages for BPF indicate that
- // if the requested buffer size cannot be accommodated, the closest allowable size will be
- // set and returned... hence our GetReadBufLen method.
- ReadBufLen int
- // Timeout is the length of time to wait before timing out on a read request.
- // Timeout defaults to nil which means no timeout is used.
- Timeout *syscall.Timeval
- // Promisc is set to true for promiscuous mode ethernet sniffing.
- // Promisc defaults to true.
- Promisc bool
- // Immediate is set to true to make our read requests return as soon as a packet becomes available.
- // Otherwise, a read will block until either the kernel buffer becomes full or a timeout occurs.
- // The default is true.
- Immediate bool
- // PreserveLinkAddr is set to false if the link level source address should be filled in automatically
- // by the interface output routine. Set to true if the link level source address will be written,
- // as provided, to the wire.
- // The default is true.
- PreserveLinkAddr bool
-}
-
-var defaultOptions = Options{
- BPFDeviceName: "",
- ReadBufLen: 32767,
- Timeout: nil,
- Promisc: true,
- Immediate: true,
- PreserveLinkAddr: true,
-}
-
-// BPFSniffer is a struct used to track state of a BSD BPF ethernet sniffer
-// such that gopacket's PacketDataSource interface is implemented.
-type BPFSniffer struct {
- options *Options
- sniffDeviceName string
- fd int
- readBuffer []byte
- lastReadLen int
- readBytesConsumed int
-}
-
-// NewBPFSniffer is used to create BSD-only BPF ethernet sniffer
-// iface is the network interface device name that you wish to sniff
-// options can set to nil in order to utilize default values for everything.
-// Each field of Options also have a default setting if left unspecified by
-// the user's custome Options struct.
-func NewBPFSniffer(iface string, options *Options) (*BPFSniffer, error) {
- var err error
- enable := 1
- sniffer := BPFSniffer{
- sniffDeviceName: iface,
- }
- if options == nil {
- sniffer.options = &defaultOptions
- } else {
- sniffer.options = options
- }
-
- if sniffer.options.BPFDeviceName == "" {
- sniffer.pickBpfDevice()
- }
-
- // setup our read buffer
- if sniffer.options.ReadBufLen == 0 {
- sniffer.options.ReadBufLen, err = syscall.BpfBuflen(sniffer.fd)
- if err != nil {
- return nil, err
- }
- } else {
- sniffer.options.ReadBufLen, err = syscall.SetBpfBuflen(sniffer.fd, sniffer.options.ReadBufLen)
- if err != nil {
- return nil, err
- }
- }
- sniffer.readBuffer = make([]byte, sniffer.options.ReadBufLen)
-
- err = syscall.SetBpfInterface(sniffer.fd, sniffer.sniffDeviceName)
- if err != nil {
- return nil, err
- }
-
- if sniffer.options.Immediate {
- // turn immediate mode on. This makes the snffer non-blocking.
- err = syscall.SetBpfImmediate(sniffer.fd, enable)
- if err != nil {
- return nil, err
- }
- }
-
- // the above call to syscall.SetBpfImmediate needs to be made
- // before setting a timer otherwise the reads will block for the
- // entire timer duration even if there are packets to return.
- if sniffer.options.Timeout != nil {
- err = syscall.SetBpfTimeout(sniffer.fd, sniffer.options.Timeout)
- if err != nil {
- return nil, err
- }
- }
-
- if sniffer.options.PreserveLinkAddr {
- // preserves the link level source address...
- // higher level protocol analyzers will not need this
- err = syscall.SetBpfHeadercmpl(sniffer.fd, enable)
- if err != nil {
- return nil, err
- }
- }
-
- if sniffer.options.Promisc {
- // forces the interface into promiscuous mode
- err = syscall.SetBpfPromisc(sniffer.fd, enable)
- if err != nil {
- return nil, err
- }
- }
-
- return &sniffer, nil
-}
-
-// Close is used to close the file-descriptor of the BPF device file.
-func (b *BPFSniffer) Close() error {
- return syscall.Close(b.fd)
-}
-
-func (b *BPFSniffer) pickBpfDevice() {
- var err error
- b.options.BPFDeviceName = ""
- for i := 0; i < 99; i++ {
- b.options.BPFDeviceName = fmt.Sprintf("/dev/bpf%d", i)
- b.fd, err = syscall.Open(b.options.BPFDeviceName, syscall.O_RDWR, 0)
- if err == nil {
- return
- }
- }
- panic("failed to acquire a BPF device for read-write access")
-}
-
-func (b *BPFSniffer) ReadPacketData() ([]byte, gopacket.CaptureInfo, error) {
- var err error
- if b.readBytesConsumed >= b.lastReadLen {
- b.readBytesConsumed = 0
- b.readBuffer = make([]byte, b.options.ReadBufLen)
- b.lastReadLen, err = syscall.Read(b.fd, b.readBuffer)
- if err != nil {
- b.lastReadLen = 0
- return nil, gopacket.CaptureInfo{}, err
- }
- }
- hdr := (*unix.BpfHdr)(unsafe.Pointer(&b.readBuffer[b.readBytesConsumed]))
- frameStart := b.readBytesConsumed + int(hdr.Hdrlen)
- b.readBytesConsumed += bpfWordAlign(int(hdr.Hdrlen) + int(hdr.Caplen))
-
- if frameStart+int(hdr.Caplen) > len(b.readBuffer) {
- captureInfo := gopacket.CaptureInfo{
- Timestamp: time.Unix(int64(hdr.Tstamp.Sec), int64(hdr.Tstamp.Usec)*1000),
- CaptureLength: 0,
- Length: 0,
- }
- return nil, captureInfo, errors.New("BPF captured frame received with corrupted BpfHdr struct.")
- }
-
- rawFrame := b.readBuffer[frameStart : frameStart+int(hdr.Caplen)]
- captureInfo := gopacket.CaptureInfo{
- Timestamp: time.Unix(int64(hdr.Tstamp.Sec), int64(hdr.Tstamp.Usec)*1000),
- CaptureLength: len(rawFrame),
- Length: len(rawFrame),
- }
- return rawFrame, captureInfo, nil
-}
-
-// GetReadBufLen returns the BPF read buffer length
-func (b *BPFSniffer) GetReadBufLen() int {
- return b.options.ReadBufLen
-}
diff --git a/vendor/github.com/google/gopacket/bytediff/bytediff.go b/vendor/github.com/google/gopacket/bytediff/bytediff.go
deleted file mode 100644
index 63addd94..00000000
--- a/vendor/github.com/google/gopacket/bytediff/bytediff.go
+++ /dev/null
@@ -1,217 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-// Package bytediff provides a simple diff utility for looking at differences in byte
-// slices. It's slow, clunky, and not particularly good by any measure, but
-// it does provide very useful visualizations for diffs between small byte
-// slices.
-//
-// Our diff algorithm uses a dynamic programming implementation of longest common
-// substring to find matching parts of slices, then recursively calls itself on
-// the prefix/suffix of that matching part for each packet. This is a Bad Idea
-// (tm) for normal (especially large) input, but for packets where large portions
-// repeat frequently and we expect minor changes between results, it's actually
-// quite useful.
-package bytediff
-
-import (
- "bytes"
- "fmt"
-)
-
-// OutputFormat tells a Differences.String call how to format the set of
-// differences into a human-readable string. Its internals are currently
-// unexported because we may want to change them drastically in the future. For
-// the moment, please just use one of the provided OutputFormats that comes with
-// this library.
-type OutputFormat struct {
- start, finish, add, remove, change, reset string
-}
-
-var (
- // BashOutput uses bash escape sequences to color output.
- BashOutput = &OutputFormat{
- reset: "\033[0m",
- remove: "\033[32m",
- add: "\033[31m",
- change: "\033[33m",
- }
- // HTMLOutput uses a to wrap output, and s to color it.
- // HTMLOutput is pretty experimental, so use at your own risk ;)
- HTMLOutput = &OutputFormat{
- start: "",
- finish: "
",
- reset: "",
- remove: "",
- add: "",
- change: "",
- }
-)
-
-// longestCommonSubstring uses a O(MN) dynamic programming approach to find the
-// longest common substring in a set of slices. It returns the index in each
-// slice at which the substring begins, plus the length of the commonality.
-func longestCommonSubstring(strA, strB []byte) (indexA, indexB, length int) {
- lenA, lenB := len(strA), len(strB)
- if lenA == 0 || lenB == 0 {
- return 0, 0, 0
- }
- arr := make([][]int, lenA)
- for i := 0; i < lenA; i++ {
- arr[i] = make([]int, lenB)
- }
- var maxLength int
- var maxA, maxB int
- for a := 0; a < lenA; a++ {
- for b := 0; b < lenB; b++ {
- if strA[a] == strB[b] {
- length := 1
- if a > 0 && b > 0 {
- length = arr[a-1][b-1] + 1
- }
- arr[a][b] = length
- if length > maxLength {
- maxLength = length
- maxA = a
- maxB = b
- }
- }
- }
- }
- a, b := maxA, maxB
- for a >= 0 && b >= 0 && strA[a] == strB[b] {
- indexA = a
- indexB = b
- a--
- b--
- length++
- }
- return
-}
-
-func intMax(a, b int) int {
- if a > b {
- return a
- }
- return b
-}
-
-// Difference represents a single part of the data being diffed, containing
-// information about both the original and new values.
-// From and To are the sets of bytes in the original and the new byte slice.
-// !Replace implies From == To (no change)
-// len(To) == 0 implies From is being deleted
-// len(From) == 0 implies To is being inserted
-// else implies From is being replaced by To
-type Difference struct {
- Replace bool
- From, To []byte
-}
-
-// color returns the bash color for a given difference.
-func (c *OutputFormat) color(d Difference) string {
- switch {
- case !d.Replace:
- return ""
- case len(d.From) == 0:
- return c.remove
- case len(d.To) == 0:
- return c.add
- default:
- return c.change
- }
-}
-
-// Diff diffs strA and strB, returning a list of differences which
-// can be used to construct either the original or new string.
-//
-// Diff is optimized for comparing VERY SHORT slices. It's meant for comparing
-// things like packets off the wire, not large files or the like.
-// As such, its runtime can be catastrophic if large inputs are passed in.
-// You've been warned.
-func Diff(strA, strB []byte) Differences {
- if len(strA) == 0 && len(strB) == 0 {
- return nil
- }
- ia, ib, l := longestCommonSubstring(strA, strB)
- if l == 0 {
- return Differences{
- Difference{true, strA, strB},
- }
- }
- beforeA, match, afterA := strA[:ia], strA[ia:ia+l], strA[ia+l:]
- beforeB, afterB := strB[:ib], strB[ib+l:]
- var diffs Differences
- diffs = append(diffs, Diff(beforeA, beforeB)...)
- diffs = append(diffs, Difference{false, match, match})
- diffs = append(diffs, Diff(afterA, afterB)...)
- return diffs
-}
-
-// Differences is a set of differences for a given diff'd pair of byte slices.
-type Differences []Difference
-
-// String outputs a previously diff'd set of strings, showing differences
-// between them, highlighted by colors.
-//
-// The output format of this function is NOT guaranteed consistent, and may be
-// changed at any time by the library authors. It's meant solely for human
-// consumption.
-func (c *OutputFormat) String(diffs Differences) string {
- var buf bytes.Buffer
- count := 0
- fmt.Fprintf(&buf, "%s", c.start)
- fmt.Fprintf(&buf, "00000000 ")
- for i := 0; i < len(diffs); i++ {
- diff := diffs[i]
- color := c.color(diff)
- reset := ""
- if color != "" {
- reset = c.reset
- }
- fmt.Fprint(&buf, color)
- for _, b := range diff.From {
- fmt.Fprintf(&buf, " %02x", b)
- count++
- switch count % 16 {
- case 0:
- fmt.Fprintf(&buf, "%v\n%08x%v ", reset, count, color)
- case 8:
- fmt.Fprintf(&buf, " ")
- }
- }
- fmt.Fprint(&buf, reset)
- }
- fmt.Fprintf(&buf, "\n\n00000000 ")
- count = 0
- for i := 0; i < len(diffs); i++ {
- diff := diffs[i]
- str := diff.From
- if diff.Replace {
- str = diff.To
- }
- color := c.color(diff)
- reset := ""
- if color != "" {
- reset = c.reset
- }
- fmt.Fprint(&buf, color)
- for _, b := range str {
- fmt.Fprintf(&buf, " %02x", b)
- count++
- switch count % 16 {
- case 0:
- fmt.Fprintf(&buf, "%v\n%08x%v ", reset, count, color)
- case 8:
- fmt.Fprintf(&buf, " ")
- }
- }
- fmt.Fprint(&buf, reset)
- }
- fmt.Fprint(&buf, "\n")
- fmt.Fprintf(&buf, "%s", c.finish)
- return string(buf.Bytes())
-}
diff --git a/vendor/github.com/google/gopacket/bytediff/bytediff_test.go b/vendor/github.com/google/gopacket/bytediff/bytediff_test.go
deleted file mode 100644
index 022ad4bc..00000000
--- a/vendor/github.com/google/gopacket/bytediff/bytediff_test.go
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-package bytediff
-
-import (
- "reflect"
- "testing"
-)
-
-func TestLCS(t *testing.T) {
- for i, test := range []struct {
- a, b []byte
- indexA, indexB, length int
- }{
- {[]byte{1, 2, 3}, []byte{1, 2, 3}, 0, 0, 3},
- {[]byte{0, 1, 2, 3}, []byte{1, 2, 3, 4}, 1, 0, 3},
- {[]byte{0, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3}, []byte{1, 2, 3, 4}, 4, 0, 4},
- {[]byte{1, 2, 2, 3, 4}, []byte{1, 2, 3, 4}, 2, 1, 3},
- {[]byte{0, 1, 2, 3, 4}, []byte{1, 1, 2, 2, 3, 4}, 2, 3, 3},
- } {
- ia, ib, l := longestCommonSubstring(test.a, test.b)
- if ia != test.indexA || ib != test.indexB || l != test.length {
- t.Errorf("%d: want (%d %d %d) got (%d %d %d)", i, test.indexA, test.indexB, test.length, ia, ib, l)
- }
- }
-}
-
-func TestDiff(t *testing.T) {
- for i, test := range []struct {
- a, b []byte
- d Differences
- }{
- {
- []byte{0, 1, 2, 3, 4},
- []byte{1, 1, 2, 2, 3, 4},
- Differences{
- Difference{true, []byte{0}, []byte{}},
- Difference{false, []byte{1}, []byte{1}},
- Difference{true, []byte{}, []byte{1, 2}},
- Difference{false, []byte{2, 3, 4}, []byte{2, 3, 4}},
- },
- },
- } {
- diffs := Diff(test.a, test.b)
- if !reflect.DeepEqual(diffs, test.d) {
- t.Errorf("%d want %v got %v", i, test.d, diffs)
- }
- }
-}
diff --git a/vendor/github.com/google/gopacket/dumpcommand/tcpdump.go b/vendor/github.com/google/gopacket/dumpcommand/tcpdump.go
deleted file mode 100644
index 2d357220..00000000
--- a/vendor/github.com/google/gopacket/dumpcommand/tcpdump.go
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-// Package dumpcommand implements a run function for pfdump and pcapdump
-// with many similar flags/features to tcpdump. This code is split out seperate
-// from data sources (pcap/pfring) so it can be used by both.
-package dumpcommand
-
-import (
- "flag"
- "fmt"
- "log"
- "os"
- "time"
-
- "github.com/google/gopacket"
- "github.com/google/gopacket/ip4defrag"
- "github.com/google/gopacket/layers" // pulls in all layers decoders
-)
-
-var (
- print = flag.Bool("print", true, "Print out packets, if false only prints out statistics")
- maxcount = flag.Int("c", -1, "Only grab this many packets, then exit")
- decoder = flag.String("decoder", "Ethernet", "Name of the decoder to use")
- dump = flag.Bool("X", false, "If true, dump very verbose info on each packet")
- statsevery = flag.Int("stats", 1000, "Output statistics every N packets")
- printErrors = flag.Bool("errors", false, "Print out packet dumps of decode errors, useful for checking decoders against live traffic")
- lazy = flag.Bool("lazy", false, "If true, do lazy decoding")
- defrag = flag.Bool("defrag", false, "If true, do IPv4 defrag")
-)
-
-func Run(src gopacket.PacketDataSource) {
- if !flag.Parsed() {
- log.Fatalln("Run called without flags.Parse() being called")
- }
- var dec gopacket.Decoder
- var ok bool
- if dec, ok = gopacket.DecodersByLayerName[*decoder]; !ok {
- log.Fatalln("No decoder named", *decoder)
- }
- source := gopacket.NewPacketSource(src, dec)
- source.Lazy = *lazy
- source.NoCopy = true
- source.DecodeStreamsAsDatagrams = true
- fmt.Fprintln(os.Stderr, "Starting to read packets")
- count := 0
- bytes := int64(0)
- start := time.Now()
- errors := 0
- truncated := 0
- layertypes := map[gopacket.LayerType]int{}
- defragger := ip4defrag.NewIPv4Defragmenter()
-
- for packet := range source.Packets() {
- count++
- bytes += int64(len(packet.Data()))
-
- // defrag the IPv4 packet if required
- if *defrag {
- ip4Layer := packet.Layer(layers.LayerTypeIPv4)
- if ip4Layer == nil {
- continue
- }
- ip4 := ip4Layer.(*layers.IPv4)
- l := ip4.Length
-
- newip4, err := defragger.DefragIPv4(ip4)
- if err != nil {
- log.Fatalln("Error while de-fragmenting", err)
- } else if newip4 == nil {
- continue // packet fragment, we don't have whole packet yet.
- }
- if newip4.Length != l {
- fmt.Printf("Decoding re-assembled packet: %s\n", newip4.NextLayerType())
- pb, ok := packet.(gopacket.PacketBuilder)
- if !ok {
- panic("Not a PacketBuilder")
- }
- nextDecoder := newip4.NextLayerType()
- nextDecoder.Decode(newip4.Payload, pb)
- }
- }
-
- if *dump {
- fmt.Println(packet.Dump())
- } else if *print {
- fmt.Println(packet)
- }
- if !*lazy || *print || *dump { // if we've already decoded all layers...
- for _, layer := range packet.Layers() {
- layertypes[layer.LayerType()]++
- }
- if packet.Metadata().Truncated {
- truncated++
- }
- if errLayer := packet.ErrorLayer(); errLayer != nil {
- errors++
- if *printErrors {
- fmt.Println("Error:", errLayer.Error())
- fmt.Println("--- Packet ---")
- fmt.Println(packet.Dump())
- }
- }
- }
- done := *maxcount > 0 && count >= *maxcount
- if count%*statsevery == 0 || done {
- fmt.Fprintf(os.Stderr, "Processed %v packets (%v bytes) in %v, %v errors and %v truncated packets\n", count, bytes, time.Since(start), errors, truncated)
- if len(layertypes) > 0 {
- fmt.Fprintf(os.Stderr, "Layer types seen: %+v\n", layertypes)
- }
- }
- if done {
- break
- }
- }
-}
diff --git a/vendor/github.com/google/gopacket/examples/arpscan/arpscan.go b/vendor/github.com/google/gopacket/examples/arpscan/arpscan.go
deleted file mode 100644
index 1a0e33e5..00000000
--- a/vendor/github.com/google/gopacket/examples/arpscan/arpscan.go
+++ /dev/null
@@ -1,188 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-// arpscan implements ARP scanning of all interfaces' local networks using
-// gopacket and its subpackages. This example shows, among other things:
-// * Generating and sending packet data
-// * Reading in packet data and interpreting it
-// * Use of the 'pcap' subpackage for reading/writing
-package main
-
-import (
- "bytes"
- "encoding/binary"
- "errors"
- "log"
- "net"
- "sync"
- "time"
-
- "github.com/google/gopacket"
- "github.com/google/gopacket/layers"
- "github.com/google/gopacket/pcap"
-)
-
-func main() {
- // Get a list of all interfaces.
- ifaces, err := net.Interfaces()
- if err != nil {
- panic(err)
- }
-
- var wg sync.WaitGroup
- for _, iface := range ifaces {
- wg.Add(1)
- // Start up a scan on each interface.
- go func(iface net.Interface) {
- defer wg.Done()
- if err := scan(&iface); err != nil {
- log.Printf("interface %v: %v", iface.Name, err)
- }
- }(iface)
- }
- // Wait for all interfaces' scans to complete. They'll try to run
- // forever, but will stop on an error, so if we get past this Wait
- // it means all attempts to write have failed.
- wg.Wait()
-}
-
-// scan scans an individual interface's local network for machines using ARP requests/replies.
-//
-// scan loops forever, sending packets out regularly. It returns an error if
-// it's ever unable to write a packet.
-func scan(iface *net.Interface) error {
- // We just look for IPv4 addresses, so try to find if the interface has one.
- var addr *net.IPNet
- if addrs, err := iface.Addrs(); err != nil {
- return err
- } else {
- for _, a := range addrs {
- if ipnet, ok := a.(*net.IPNet); ok {
- if ip4 := ipnet.IP.To4(); ip4 != nil {
- addr = &net.IPNet{
- IP: ip4,
- Mask: ipnet.Mask[len(ipnet.Mask)-4:],
- }
- break
- }
- }
- }
- }
- // Sanity-check that the interface has a good address.
- if addr == nil {
- return errors.New("no good IP network found")
- } else if addr.IP[0] == 127 {
- return errors.New("skipping localhost")
- } else if addr.Mask[0] != 0xff || addr.Mask[1] != 0xff {
- return errors.New("mask means network is too large")
- }
- log.Printf("Using network range %v for interface %v", addr, iface.Name)
-
- // Open up a pcap handle for packet reads/writes.
- handle, err := pcap.OpenLive(iface.Name, 65536, true, pcap.BlockForever)
- if err != nil {
- return err
- }
- defer handle.Close()
-
- // Start up a goroutine to read in packet data.
- stop := make(chan struct{})
- go readARP(handle, iface, stop)
- defer close(stop)
- for {
- // Write our scan packets out to the handle.
- if err := writeARP(handle, iface, addr); err != nil {
- log.Printf("error writing packets on %v: %v", iface.Name, err)
- return err
- }
- // We don't know exactly how long it'll take for packets to be
- // sent back to us, but 10 seconds should be more than enough
- // time ;)
- time.Sleep(10 * time.Second)
- }
-}
-
-// readARP watches a handle for incoming ARP responses we might care about, and prints them.
-//
-// readARP loops until 'stop' is closed.
-func readARP(handle *pcap.Handle, iface *net.Interface, stop chan struct{}) {
- src := gopacket.NewPacketSource(handle, layers.LayerTypeEthernet)
- in := src.Packets()
- for {
- var packet gopacket.Packet
- select {
- case <-stop:
- return
- case packet = <-in:
- arpLayer := packet.Layer(layers.LayerTypeARP)
- if arpLayer == nil {
- continue
- }
- arp := arpLayer.(*layers.ARP)
- if arp.Operation != layers.ARPReply || bytes.Equal([]byte(iface.HardwareAddr), arp.SourceHwAddress) {
- // This is a packet I sent.
- continue
- }
- // Note: we might get some packets here that aren't responses to ones we've sent,
- // if for example someone else sends US an ARP request. Doesn't much matter, though...
- // all information is good information :)
- log.Printf("IP %v is at %v", net.IP(arp.SourceProtAddress), net.HardwareAddr(arp.SourceHwAddress))
- }
- }
-}
-
-// writeARP writes an ARP request for each address on our local network to the
-// pcap handle.
-func writeARP(handle *pcap.Handle, iface *net.Interface, addr *net.IPNet) error {
- // Set up all the layers' fields we can.
- eth := layers.Ethernet{
- SrcMAC: iface.HardwareAddr,
- DstMAC: net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
- EthernetType: layers.EthernetTypeARP,
- }
- arp := layers.ARP{
- AddrType: layers.LinkTypeEthernet,
- Protocol: layers.EthernetTypeIPv4,
- HwAddressSize: 6,
- ProtAddressSize: 4,
- Operation: layers.ARPRequest,
- SourceHwAddress: []byte(iface.HardwareAddr),
- SourceProtAddress: []byte(addr.IP),
- DstHwAddress: []byte{0, 0, 0, 0, 0, 0},
- }
- // Set up buffer and options for serialization.
- buf := gopacket.NewSerializeBuffer()
- opts := gopacket.SerializeOptions{
- FixLengths: true,
- ComputeChecksums: true,
- }
- // Send one packet for every address.
- for _, ip := range ips(addr) {
- arp.DstProtAddress = []byte(ip)
- gopacket.SerializeLayers(buf, opts, ð, &arp)
- if err := handle.WritePacketData(buf.Bytes()); err != nil {
- return err
- }
- }
- return nil
-}
-
-// ips is a simple and not very good method for getting all IPv4 addresses from a
-// net.IPNet. It returns all IPs it can over the channel it sends back, closing
-// the channel when done.
-func ips(n *net.IPNet) (out []net.IP) {
- num := binary.BigEndian.Uint32([]byte(n.IP))
- mask := binary.BigEndian.Uint32([]byte(n.Mask))
- num &= mask
- for mask < 0xffffffff {
- var buf [4]byte
- binary.BigEndian.PutUint32(buf[:], num)
- out = append(out, net.IP(buf[:]))
- mask += 1
- num += 1
- }
- return
-}
diff --git a/vendor/github.com/google/gopacket/examples/bidirectional/main.go b/vendor/github.com/google/gopacket/examples/bidirectional/main.go
deleted file mode 100644
index 4b0b240d..00000000
--- a/vendor/github.com/google/gopacket/examples/bidirectional/main.go
+++ /dev/null
@@ -1,192 +0,0 @@
-// Copyright 2012 Google, Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the LICENSE file in the root of the source
-// tree.
-
-// This binary provides an example of connecting up bidirectional streams from
-// the unidirectional streams provided by gopacket/tcpassembly.
-package main
-
-import (
- "flag"
- "fmt"
- "github.com/google/gopacket"
- "github.com/google/gopacket/examples/util"
- "github.com/google/gopacket/layers"
- "github.com/google/gopacket/pcap"
- "github.com/google/gopacket/tcpassembly"
- "log"
- "time"
-)
-
-var iface = flag.String("i", "eth0", "Interface to get packets from")
-var snaplen = flag.Int("s", 16<<10, "SnapLen for pcap packet capture")
-var filter = flag.String("f", "tcp", "BPF filter for pcap")
-var logAllPackets = flag.Bool("v", false, "Logs every packet in great detail")
-
-// key is used to map bidirectional streams to each other.
-type key struct {
- net, transport gopacket.Flow
-}
-
-// String prints out the key in a human-readable fashion.
-func (k key) String() string {
- return fmt.Sprintf("%v:%v", k.net, k.transport)
-}
-
-// timeout is the length of time to wait befor flushing connections and
-// bidirectional stream pairs.
-const timeout time.Duration = time.Minute * 5
-
-// myStream implements tcpassembly.Stream
-type myStream struct {
- bytes int64 // total bytes seen on this stream.
- bidi *bidi // maps to my bidirectional twin.
- done bool // if true, we've seen the last packet we're going to for this stream.
-}
-
-// bidi stores each unidirectional side of a bidirectional stream.
-//
-// When a new stream comes in, if we don't have an opposite stream, a bidi is
-// created with 'a' set to the new stream. If we DO have an opposite stream,
-// 'b' is set to the new stream.
-type bidi struct {
- key key // Key of the first stream, mostly for logging.
- a, b *myStream // the two bidirectional streams.
- lastPacketSeen time.Time // last time we saw a packet from either stream.
-}
-
-// myFactory implements tcpassmebly.StreamFactory
-type myFactory struct {
- // bidiMap maps keys to bidirectional stream pairs.
- bidiMap map[key]*bidi
-}
-
-// New handles creating a new tcpassembly.Stream.
-func (f *myFactory) New(netFlow, tcpFlow gopacket.Flow) tcpassembly.Stream {
- // Create a new stream.
- s := &myStream{}
-
- // Find the bidi bidirectional struct for this stream, creating a new one if
- // one doesn't already exist in the map.
- k := key{netFlow, tcpFlow}
- bd := f.bidiMap[k]
- if bd == nil {
- bd = &bidi{a: s, key: k}
- log.Printf("[%v] created first side of bidirectional stream", bd.key)
- // Register bidirectional with the reverse key, so the matching stream going
- // the other direction will find it.
- f.bidiMap[key{netFlow.Reverse(), tcpFlow.Reverse()}] = bd
- } else {
- log.Printf("[%v] found second side of bidirectional stream", bd.key)
- bd.b = s
- // Clear out the bidi we're using from the map, just in case.
- delete(f.bidiMap, k)
- }
- s.bidi = bd
- return s
-}
-
-// emptyStream is used to finish bidi that only have one stream, in
-// collectOldStreams.
-var emptyStream = &myStream{done: true}
-
-// collectOldStreams finds any streams that haven't received a packet within
-// 'timeout', and sets/finishes the 'b' stream inside them. The 'a' stream may
-// still receive packets after this.
-func (f *myFactory) collectOldStreams() {
- cutoff := time.Now().Add(-timeout)
- for k, bd := range f.bidiMap {
- if bd.lastPacketSeen.Before(cutoff) {
- log.Printf("[%v] timing out old stream", bd.key)
- bd.b = emptyStream // stub out b with an empty stream.
- delete(f.bidiMap, k) // remove it from our map.
- bd.maybeFinish() // if b was the last stream we were waiting for, finish up.
- }
- }
-}
-
-// Reassembled handles reassembled TCP stream data.
-func (s *myStream) Reassembled(rs []tcpassembly.Reassembly) {
- for _, r := range rs {
- // For now, we'll simply count the bytes on each side of the TCP stream.
- s.bytes += int64(len(r.Bytes))
- if r.Skip > 0 {
- s.bytes += int64(r.Skip)
- }
- // Mark that we've received new packet data.
- // We could just use time.Now, but by using r.Seen we handle the case
- // where packets are being read from a file and could be very old.
- if s.bidi.lastPacketSeen.After(r.Seen) {
- s.bidi.lastPacketSeen = r.Seen
- }
- }
-}
-
-// ReassemblyComplete marks this stream as finished.
-func (s *myStream) ReassemblyComplete() {
- s.done = true
- s.bidi.maybeFinish()
-}
-
-// maybeFinish will wait until both directions are complete, then print out
-// stats.
-func (bd *bidi) maybeFinish() {
- switch {
- case bd.a == nil:
- log.Fatalf("[%v] a should always be non-nil, since it's set when bidis are created", bd.key)
- case !bd.a.done:
- log.Printf("[%v] still waiting on first stream", bd.key)
- case bd.b == nil:
- log.Printf("[%v] no second stream yet", bd.key)
- case !bd.b.done:
- log.Printf("[%v] still waiting on second stream", bd.key)
- default:
- log.Printf("[%v] FINISHED, bytes: %d tx, %d rx", bd.key, bd.a.bytes, bd.b.bytes)
- }
-}
-
-func main() {
- defer util.Run()()
- log.Printf("starting capture on interface %q", *iface)
- // Set up pcap packet capture
- handle, err := pcap.OpenLive(*iface, int32(*snaplen), true, pcap.BlockForever)
- if err != nil {
- panic(err)
- }
- if err := handle.SetBPFFilter(*filter); err != nil {
- panic(err)
- }
-
- // Set up assembly
- streamFactory := &myFactory{bidiMap: make(map[key]*bidi)}
- streamPool := tcpassembly.NewStreamPool(streamFactory)
- assembler := tcpassembly.NewAssembler(streamPool)
-
- log.Println("reading in packets")
- // Read in packets, pass to assembler.
- packetSource := gopacket.NewPacketSource(handle, handle.LinkType())
- packets := packetSource.Packets()
- ticker := time.Tick(timeout / 4)
- for {
- select {
- case packet := <-packets:
- if *logAllPackets {
- log.Println(packet)
- }
- if packet.NetworkLayer() == nil || packet.TransportLayer() == nil || packet.TransportLayer().LayerType() != layers.LayerTypeTCP {
- log.Println("Unusable packet")
- continue
- }
- tcp := packet.TransportLayer().(*layers.TCP)
- assembler.AssembleWithTimestamp(packet.NetworkLayer().NetworkFlow(), tcp, packet.Metadata().Timestamp)
-
- case <-ticker:
- // Every minute, flush connections that haven't seen activity in the past minute.
- log.Println("---- FLUSHING ----")
- assembler.FlushOlderThan(time.Now().Add(-timeout))
- streamFactory.collectOldStreams()
- }
- }
-}
diff --git a/vendor/github.com/google/gopacket/examples/bytediff/bytediff.png b/vendor/github.com/google/gopacket/examples/bytediff/bytediff.png
deleted file mode 100644
index 5aa3c8a446797cb3491c6e8cbf47328062d4cf18..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 47462
zcmbTd2T)UOxGfx-6s3qXDFV`ajWj_J>4=oj2|Y+hO6VvNjnburA|fS(-a$Y}AWAj#
z4$=e+(m{$e!5jR(GymMV=ltj1!wl@%o8-x!o%KFtt@TD58fZ~du~Gp50BRlW2gU#Z
zi8}y5s!BmjxI#BA_ndGb@;BDH52zeqUn87QKGC-H2LNbaU;Yv?^`PK{i{t@14>ic=
zuP_3LMUuB}NfIvI4A8I$Q1|ijf_Mi2)cqh10T5@dAh!TlE-jshhUPFDW&nT-pz}Zt
z6#R7)6E+3WfPMq-tVOBXx#oV1eXBZZFE=NK9?A{(OM1{zJnZYZ#77k0F?^Tu?bREP
z_w@CDkCFO(k$WWGA;6>fg;^tqWlY}5nbc?~QcSMpWuY2ds-E2%ym4`B=Iq?}^GU*)
zaf|zS>DLc~C+D{=T;~@Z(%9vtJ{#<((J@b%ZwH^V+)GqKSzK)Ye<)ZB`ar
z0n-IF!pvPZshQfujEctIO-P{y&pTPG=esBB2YNgzT-&@RIwBfn1UBYI_tx$7&%#xY
zSy&mV-_cjOdp1g)3IPBV;bo71KWA_69uDfbpJ5stA=+_<(2454D$SO%8A5jF^WH)5
zB7VwvVh%Nrkcor}I{ez`m$`m4Bdba5RV>Hh8bkOLcx;+_G
zT*buZQ{+Vv@ceruTlODa(b=)fdsd8&?7r95D?Af;+Fo;Op%X}tv!>3SMU4uWqe9AK`n(_MGbMXlF<6&R3=lF3pK`iP`x6TJSwH
zbEHASl-KMJyY|>Owc^hE>CF!xiAtutH*Ufw|;KZazCbFmmezgFX2AvGbUXDHam!q#CYMqfj+*LId)n$;LjAA9hVH1`EBc+
zvgZYyc7Saoj31w{+yPx*%@1E1_|!TInq*A~5o*Bg8eq#r1A((L^q?4x*Qb4zVGAO4
z;nJ_tmACmELIIq
zZBX5Tw05q_u`FM76l4aXSqqNK9!=w{Hg$~#dxyj3ND8rqMdCw~IZ&lnsvI2?PbTl7
zO{sJ%#+N@H+_43liFkz^s6#7YT$;38;vYPzu)SVgQ}Eo*u`z}q+amav5CGuR_GfiG
zH8=ThrYbem&qVy)yWS~z)Flk%L{1Awj_N&p;TFGF|ABPDVsrl%ngq)&J9f(
zNAz{Tn=P&^v#=J5A}jX-)xYHb_-zfzrRLa)TnptPj(oQUY{fBe>#lnnAKRBCo9n{X
zH4<23>s{NK)GPI6`#R*pc^J=H9=^Z)D63C4KUl8=oHaOa#L3kR>ZDPEa%znmP4V~Z
zM2{u}d`N>Pze*G%9(DrP>24`?soH!eT~xYEodqnOHt?Li;OUQ!@T)iH-U(DYfZ5Yj
zRO>}`akDM~;<^nV>PPsW12>w>pyL>G!|xqW#e>xeB_o_P5oRc9n^5T3Pkxv(`3y0J#-Zi<@d7sR|j85#`cx)?1P(9rJ
zHjQL%P!6|KDL_W53VkBaq)?FQ5yAjaRXJc?P}B0M!ts8w_`$K&_=~JHspuoMna6weIo5T2
zvYTLF)-@pM;hm9*&S@iMDgc+rsnZ?5fcw;E9JppD)8p{yiF4@5tB0h4i}NDEx?I&Q
zHBP*}y}#~TyiXpNCX{iPhx`$l6Uuc~B9?fCxKABj#ZNwE6iEZ`Z(5jJ*0e_)V(-_?smC+68z&=
z17hCBtUp@Z7yC;0hdfe|kmRd<7FuoRvVtIu2p!|)dYEGs$C=5-t`s)ntA04E&6tsH
zW15U_WGbr_yXqa(I^JkqWkJ_@dTFyMw2VDVmx!?Ztpd=SZ|m5$$mcLc0|7W`+|
zEK>&sz`hvTI6OUnx-jz5Ig4S>p)mM`SzqUcP?_q}O%o&sBa=tj)B3|HkBljz&)J{$
zQdQeo;M6|w#fP@N@CpzWK%aup3hl4-FAsQJB6v4)_xk0Lg7dOb`>#&`?t>Ba>~Ch)
zc%`JAt@ez+p!N>zgTCNzzoGz@S7`znMD)zQtM)#|=WI`U@-s~ZXS7Z2EwXC*4YOq1
zf_+kIyGbIYC^@ely=M%?Z1b1I<<>~Zj$)QH%H1JJVo_;RkE=~;0f%jFJYQROPuU0?dD4sEd=Y=GQjyxwa0!p7W|`+qlgsH5Umny^u$d6gRC_Gay=)(DORN{q)Ff
z;v!0@K(q)ooYkZrhw^igL>i2i
zg&9?Du1M=hKeR6Sx{j2|j1w(aX;g8H_Lv@aTqK_P;E+oa%%}jd{rSAKqyO&j@Y~(n
zA`l*2HySXcaT-6TmABl(?Y7(9{75&&>r{Mals+!JaK+I3=(YtZQ?eC1i8IYN3uh?I
z$Vvn62~7e{XbikIg(x0_CWJVW8b+0T;8TexeZXYxzV9&Z@%Xq&kU-|t0Y(rINB(Cop7VUZ
zJrb`XpTpl^HNHQ|A5?P`tacCXRS-T|Nr1VmyJEN$N%Zxa<>No^Y3oXgc{@f
zZzApuDK_gDqQM}`lPSP{2bQ-
zamqikLw-~LIZJ!$wBY>FyR3q@7vRRsGH=o%V)sfkl*yym*4Z+!`HsHm(Ch6}6J|mX
z2H-zI9+cG!zR}Sl1*BkKdKjR;ZT|Shy5R9o^2Th`-{lMIO?O)b#(q;$Le%zTPD!Fv
zd9s7X7zrWrLsR>t7vly0n7J8or6f=Q_+OQjlsuj6m8=A3nSJaq-%vDgi92t~-?kT0
zo+uMu4gocO^&TSVCK;mEDXrq{Dn?mWwcG&mnhXv&2g5=
z;0St0t%@{yC~m>LU3=68;Z8wX>JwJIk@9802#`T~nqlvkPu|X)8mR^S#iyXTNde$O
znjfuzr$r#i&LLOL|8$rZIuuO5-2M0hd;76tdn)mGEIUuNYcK2KE!5J!u!AoMxJe8R
z$^rm*a~G!Om_t$Q$yCUs7VPe#g1hZ6KLwhnf$Ef9XLr3a^zFH~eVNO|CCNRC!&0Yy
zAmQKEIZ38zCyYY2;*K=#0wO(*U3Vh_{IY
zTd}u=CK@+Z>w7NmFp`y`-Q9JvzB_#cs9p=QCAoyK^PhiT5NsH>jl>r(>L+VH
zGYLwvI{pYj6y1LH+LYO~2Ci$nNIaLbhuM+u@IsT~oJ&1ct?g>jV;dqE>;wlE)$_c}
zk^acj#)Sm%bkT|1QShKwf!9(|Exiamw52MR^g?$vH_QCwXk9D3H{fajn*>ZcbDfni
zR-~neMxYonqDW-#D65rCLbF&{iLu{@Jl+9VFpeTAyk`&emQ5`4Sd?XB_WDKevr#)}
zr`I#VlprC4Cb%?PVV}qiSf+d=xYcuB%AcCZK7TdH{E%I-2^;1jwh`A#T*oos^c}Hh
ztUH}J8s>tcCRc->>OU^Z7KoH36Z&&+F8xq6J;$8deD&okbJ-BgqxC@x7~xi^Co*F
z?eSuV$Ft@b89Pv$^r3Ug$i?gMR98q+j(o^{?CeV#0DF}2HVgp9ttDc>8*9(5B?P+)$GGPO
zWV=rnTrdVEfe*)
z((Oz*p+-y%Svn^>pFG@*Y9*2JV=jhbwZ5sceCUyS%750%{TRk=S;l#T=gm6{dzwT1
z@wuf4K0c2dpwBQH@_!CnThelJTK~*ll{L#3=Vz3Edkbtdq21b?Y5X@A-z5wlmxyn~
z)=X|3oqhPBVr3BPrChQnxrO6&<*;87G<+iV;`F*lS{7~Rq-~gKCK#mV;$(VCl{)@f
zKmLuCSwLj!O8*1k`d2UImNrTJ4Y}8;k*#I$GSNRSAdBbT-Qniz68ev()3b@K;cxn73%iH&&NKc*k-Ji(u6~}1^3$ru!S1f{IJMrOE$BfBcD3}U+Cpjh
z%pnVl?TbO$5A;d~-^P%!Bowx~S7~x*UJEb4tlb_!S!4cw`U}w&Bhs7?2EkfY-qe;T
zLuN5}?-Vkg(leG;dln8Mq8kc=1dm0uDZk}5T1E>1Q-Hd&(JdKKIYj^CYz)S+U2O%!(HNglo%SkxEEBF
zU~Qg@zn%$nKID6I^8ytcBhZv?j{o+aMZGo@0TGcj-hX6f3(XlUBD|UV$q(QqV*gvV
z@}Cz(l3!waAg*8R%UBMs3>sj07lxD;8ALMKR4hU?GqJ-tC+@C)FwLr#Ti-2(77r0w
zs?dELX=TOfazMXCQFbi4!S<__hd41I|9WKMt^&SYS7Cw=4iCt+^9JEfpHqTiztjeP
zPTXuUBR(Im66$R;UiWP>{V8Z`9z%Kb(8)`vgFT>fI*JOJ%A
z;ICd}qd7kFJE6K)7l}*$PS3u|AzjXJRNH7Ow9KmHGVa-_kjDN|2!U-_oV04p9gPt8ulQqPMVuK&8cBTKHUDww
zBv4U@T^aP$%WA&(M+P_>P6pe?Z7@yisjFeri&VR{QJuP!jqv7Jm(_hom=RCU+NrCj
zm3nR^d^DVplxuf~=eGzUBqd`_$Y@KiGV}(F4SApkZF2Kpq>8_tLUvi?>b;Y#;Pz5{
z9y(e|9L-FGrTL#UAsx#TDZ;eRD}SpUuZ1Ee#a?j6xF}qh2TDJ|t95Xjn~YI1SgRY^
zFPp&byz@S_)J}@m+_GRTH&O(R+#YI-_$X%~ffvbf@9WjbJwJNxQCz<*Q7oEX-m`uQ
zpqgMxi#(){@)vr@S2C)Mz*ulNPhB&GPle#IN!zQSieDk0n~Ap&^xo|sbbTnkc*9KE
z-VQ#cE$}(>^QjhQ#p&nG_;k<}hf!fRfwutms#P_1w=krlDZEGCioXXG4^_Rq&d=>V
zvMOmjlmq)78$Ng$%_4)|2p>7dQbQ45Lj83gBs*{&1w
zyo4y2$6SuF3sYnU%CWjp2%(*0(EBW!A5U551ScAM;xVolY;r_g%6%&Ca8?hJ_b;!B
zFmQd+llXKK5RhQI+~VSZ;C;n=#Ejov`|@Gnx@PdEJop(Pp6txzxlWbahJw7Nsd}br
z4e+y5_lKl$x^MV>@uV0+zx@j}-*=S^v?Dhwpamtf!tsgJib?1?lfO^-
zzB&pWJzNM(O<^B=Ep?dV`6xC4-EbEuc6tZWd{IX`oi4sk44I$<#gwOsxtCX*2HAhw
z2ygY9Q>eaP@(f-+(|1)Pf!mNy4SuygRnNv*%@zP?*d5kREPj~jtTVo~Q<$9sqS?-z
zF!8gpw%5)@iW?fO)IVCU*F+T~=b0R3#le|gjME~#rVPblo=xYL_ca04?f(-Zu%~fU
zM_QP6xZ>_+qf~cSkuy$7g|A69fA4xGyBJ#`1IxB#VCH(z3)hgR=wIW(5(&ByAwoB2
z;Dr|lP)nJ~^;!8_>;T#J?$7ZSFTWMG=q%kb`x)ujD=%PXi|P60VERPEC)+I0gSU(U
z+Mu{E(>Df4LZP#a!f_v8W#U7s~Xz*}914rl9u<0qSp(
z$+ztm*i}{@<+XEUJvBU9Z`k9F*^$n~y**^%YPr*l_|zh5mK$CmTq)wWd1x{RbWOqE
zu4;y#Fy91xMJ*U%w0=m^2Y5k4$P&V>vasv#g(Z}(2s6nidN40p+aBtcFj(AtLw059
zr(<`Q@aWgyr7TJ~o3RH|OEyKNQ*Z=p+QL)ofMIPFTEcjcne6wgM!c$6*)w?4HSwd<
ztE)8|dKly65YXL4#73`z>xOtogj-8xD?E|*V%TwLv`IpvtY>NRE))ikteg!WrCz2}
z>6+P^oPt{IC2x`FF)5wKj38!R)fYs^L^M2}_MnW%`aOhdoA)xqK=#+RjO~QQS&zrF
zb&Jw#naLuzji+S}YV=k<`JN`dhl-@9jZ*I4@qXEX%>POUu)j9ds02u8Dh
z%uD%Fp@4J}^3TA&ZVjj7y8wOS|E%S&X#b>q*%}RDM<60s{$#v;d;6d6Uf_p3mrjjZA5kl#T7%OhiI0yiR1?K3u*ur89nTt2_VJqX!xr0CR?`OusZy^6h
zS*v9n&lzA)EFmldgbCT4ZVZFc={#w1W!@=Eim|$-?K;g+zE)=-02a&7RP52Nx(`nu
z5D8>xDOMEPp(c+ssPk=CBs_>UC7UWO(i;N8lXNYE{m#XCmDta#mC}~QDr(-ehki^J
zfx-w6MyPeb1+%KZ1`xnon6l^;0x+0R@&E%kmQigZG&Rh%?MGM$q+J(=95t%_oF?(m
zY~j7No9*G2uhg%Zms-U}N5wCW!@+Ib+pWT6R~m4Nl%z<2r1xc@gpvv}O@grV*9*X^
zR`^bY_578OCcd);tJc{u?Twgm#F#gI%gCPFOS-E&hjt_F${2_f<_(vtC_jstydDxF
z0nitXf@}~tAfbh5o-L3_uhGp4!ejge8}EPCF(kP^WmFzM)}Q*bFRKk3oO0BhBa4V-
zZ`#rDB`d5cSf>F1oB&~*Gu(f+r|6>+%BXMh2sB)WMzm75kwtbKtj_~Q!bbFyMUk)1
zOt#N!D^+he95xs<1>e`GZqX~un?nD(IWa-jC0NTurZt`zF%10vAs;SAC96`TX-#@6JRJjXw{xGncvpU%tf8v8Wenr(
zG&uVM;>~kob=xyRBaM=jFcCdoTObG7+K&@%`P=t15Qhn0zPlh@aiv2nF~<9wA;=i4
z-lBR&Cr;BdBAbu>WqR_u>fP@M+s!FySi;4Mg?pwffF&$V-1_JAhKe1V3R5AGW>}wo
z@~pre(Cr?@lXccoLC(uyGHT%V-IIpYTa1GmJk#9jIp#r|Ox9F{ZV~%tFnp!?{Ol-e
zdpqLYnVZ#cp5z<(z*-?C$4vP4VsH~yR@2qIy|@Oc1J!tZ5tw^M40zrD7WnwtNw3}7
zlVb}DYn@TD^jFPl6C?~rFi5_`9FrgzhD4Tl0wyXP#i+%IkzM-8&%KLJt;MYbc;A0#
zCpBw+=s^87NDVzg3+exa7b?6(WS?pm(aTnK(y`Fr-+x&1azZ=h2gv3%yglOJr4NM_
zv&BbX1syl_#iGYNsfGcQQW}r;r&zPGsic8VBJj!^u5L87nxp{3?r4Gc$LJr~$K%g1
zuuhK?Iu<8R3p3WV9Ajn+maflaG(o4YJWmo!^Mv|OSD&hyWVZCNO06u8Fes42*0ZWP
z$V!_8rT742KRwz`SK3ZDJQNkqEN%)wF%**A58fWG>2kf?CjkV!-M8Ianx3AvUG^xB
z5HS_e!TSzqoUr&tic0i~CROf9!w}XVnr|Dj3qvaNbP2L+?8>Mxlq^&kAKU=SR?V#A
z3p4_-2(+HIwT}60mTp>?Sm_8?iA|jQY|*598H>E3DD0N;;-J%Ge&Lc}XNJ3OR~cDkmBZ|H)8
z*i_g`>es{akl!Y+c9MS>^?&)C|N5j@`DoZr-+MzR
zo|(6plg&1y)f*4KZYv;Tu0mfNzNko5L&g9MkV{Sf90)|G*1HOpL7=d;{g{9|!6?>R
zv@=+jpqy8Xj2KJ1ApnxYi%3*mFK@}*d&MVXjdoa;eDuWJLNlw?6{niLKwvnc-lN!W
zuR+iCwmLZEP}6zR5R>`%wjsvUiWDcy&}K;lIAB$OHQZ7mt>c#%#-5W*W^BYG1KYDI
z?HV1ry%02S)R?wka=@PYh>&$%-bZ6o580|(GlEDX6;J0(BYul}Qrmp0Cl$9!Pf6E{aC4iAo*M3juUFI>(o!G#6JxtnB|8k=>Ve8;4H%5MR6
z4Ior`+Bg~ifL^thSz%u2rrvBm)LX?|)gX_%_-PI;CQ8uDq6Ut_M$h!|Oqzx0qEV+KG
z`m^Fw^}8Ynvk75-i^Kdiq5zPy5tGUiVbdB>&;IFvR7tWLJuPd$YyY!io-Ab`6XzSe
zl>Q<5d!4f9k9hM4&|M^N5kUtTjg?CTWUw+uZM!2g{l1==s}E&R__dptW{I**aCpg*KY<>uiG?
zmQ8LZh&w7QY9xS#zBqQ@1%k9Nt+RUEufyoGxFKS^NdPIT=0_^)w%5dNUF*17
zD^480|MGJ)T=(win}b6)pqE=yxe-m)#nw3^uYyAU@lA?YM}vWb$xroI}jG5k#M?_A{yv9#~ObN
zcpMv}3MOX(^Q2KqFzc@D6XqZ;xKn%f=>)gtau_odmed8%fUR4XY!Vl}=d-4U?i*KC
zX)+)7>&>xxQC^eS8%z8I}?v{aA}HN9ou*@15oY$tQD4?q@KJ@e%ltAd-ex@l|h?A
zPGgxzdcQO$FI)4QB;BA|d+H(Hk%?W^GsF%Cc3UBkrn~>3_y3hNWs|&hU$m9
zzRz&IRq||q$K?BOK&zVm+J1?<3@x2qXGWiQSQrF-%z0+v!n%d%GV`<~jA5&W_W^aM
zi1=1WXEnSMt|03VrG`j+;l9PUTNVuF1L!**TdZnbX*8!^$hr(A%%0=7<1U8r59UJU
zqaoUFrX}5r3A~&}V-1?QvxyhnDKAu!WGyo}VmQ05P8xb*>d8j1kJSWB$9%fCGMKZl
z<9ai|hnj{n*)(+iKJ6_h0}YNjXnTXEL{&J6`m5ro`ZP|(3G*i4-lQbjv@j%Mub;1!
zpqbfBH#uZWxwyDo4h?e#-AqnezI~w9eMM)vZaZ5lM3w!si
zXf|^hCy9+-*)gv?DcNgoh+nsRpAWO#DsxpQ^nXmE7DJp-jvdzIvMOwIpaw6Exu!MX
zYqL_R`u%U5i^QF#mI9LDQ)RKP5wW8C@mM(B4C^{8f1qb3oV&sp(*uF6&oBZ2n*q>Y
zQd0QDTf!|?NB!!}Gs@tu$Tu%5jDQ_Zd8gtcTCl}Cpqm#a-lDPY)JUnQ;#MAoQn+v!
zsYni$)cp`0Fdl3)OfX}mU2D8YuM+w~h$G_RV|OBTAuArv8~7@RiwK50qyUL4VVpT3
zE19-)VP23w$vVk+jp=hC#IW9wM;U{HyLLe(yj&PU+&L;~G#KpOOMAnj9fcEhf1NGn
zPffrwTx*RmgY&;qr%@
z%!rzAH~zjTJx~Jbkt(9Si(}Z{Kk*RUW>2OBH4YGP`Six5eD
ztgX@{QS@MHi0Msn$?EELX(#z2Z^$&~a79FB-)~^tB4|6w!}<!Y=LjcMqYxGkf_!`eWvPR^pD*fycx8hYxVpwjFI6acD4r^WfY
z&xWb$$xf3cev9uTR`)Oiz2b(s=w`T-aOe3oFDotiAgog}FS-+K&mH18uIuX)W945Y{_3ofCGrSP|9V`x
zV=V}!h9VVP%xXg>YO!>tqnn@N*NbE7-a~QBE^;%}xgw0OF>kg|&q9(EH8(9jj+;uo
zcX49_ba97!zFh1IukaodH++-S4CfyhGeGIv;Z3$ldL3xJmr4U{h?vWRCps0Qp1n9j
z$30a;f5b=9}&uiQE2?m#>Fn25*r>JmJ*U&zubm#fu&zvAOXKD2E}I}e?;cYrD6>m2
zBS907e{?dD-ojcN=3D17k#6L4R
zzkfcPY48ebtEsD=EuC~s<{Q6AJ(U-0O8j*04%S-yLduGg$=vYP^KYX!Y;^B{`_<>A
zJ8ir*H_O-Y2l)E%)H%R4t^l4q{*ufS79W9IjW^BY{TTE*X3|S&Kxy6f^Gv?#VUwI@YVJyEj8iYAab5G^7ts_oYh0CUlq&8A%a+Mg1
z#MNeJcxQf>+V%OM`KA@yt?2y{??9943YAB&B;u0hhh(tKv~*^r
z>q^2_JeedQZ_;ZA#dPGw@7Ni`j36KPg#2E!UaEMN%HB9)&7AQp;$ynV-N1LM%v%ql#`~=>kM%5j
z9dpPdzvTVZrcVtrzfXyE%`;hEH2Q?QD17EY_nc7l<+aYfG7d}PpnW4v&@6r!IFc}z`Im{m3@S!-7C9<)#bX{z2Wi;r@)
z5Jzk6Zx|cawc~RKLJWH748df_25txdmJD*l1D`w%2?JlzZ;`UP9kx
zK99Zg^zE4&v6tXPwLxxhnPV--cYx$m$+IaM^pN_b9g4p@z7tZANrG(}Dccm;PAceqCByBNvWo?fGcpql5eAv*%_JQS4oz^fh_AH{OS>YOAuUsV)@}%)u)mZ}ymIVW
zn)_VA{XeG1Fwv^r`H#NT15&rk!wvZjJ=MV;yiCQ`LV-Z%A{`}nmT|ZgyDBCP+Mo4I
z=8>oEv`M%k2_TuEAVUgt=-(mPst#694@ryvO!7|I3)$RFdxKeWZ&{IJR_VffTjKc#;^k9?M
z3By?~{zZI+tj%
zv&xFzRNraK)fTRKLBqmoNF7Yo{^STbs!$sbnXApqX9f!AIJo8u8WJk4r$uqADm7#v
zv*~YyvPCBWeua)2WN&!Z87}vX)YhIr{shu4SWGCemA28KW*=udY?zctbn`(q5?Oz1
z%>AgN`bn4>7QemE6^DA09<7lcf_;-3rui~L=yy
z$!R!0wHc-reOK5}eR_NGci0_*LzBQR8?mXdZcJYLl1wFV9Cv|Db|zNo)Mi&p1B!}j
zhg7(KqzI7J#`~F~LQF+P%c{1&5&&9=#-Iwys~Xs`;6e@R%=VTRSNMl(0DI1Fr)ia?
za|LfOyHd>tbNXUAp*_xuRM$k;BmpBI^7QSsyfQ}ajSq&=GR(w~#9^@7AK1siM7bOP
zlOZ%Ahad~D@0inFWw2LRF;7cBpS6eS&mqxZ;ZEf$TvUt5pt4!L1M<&<4|%8_De>fn
ztVuZ&W|(cVlagwa^8REsBaHn%4Z&lHTxPVcNzp$?`8&dDZ%sfp$C?WaxMVaRI94%8
zP>cQa@Z)jFMtF1^@c}rC3@Lp
zk+2ca3&}Rl_w=QSR233C5f<5eN-yglL~TubNH`M6nRn$=!xoR(ArT(gsz1M#0tLRh
z&SMwbeCJV~ww9>kNx!D6d`}055C3>p3^z%s>Z#W>xcypl8Sf)FNs^{&_P@()5*4fw
z?fsl_u0bxt7zsg#^8ea}+Y0pQ6WOIvr%5s*R^gPiogTHH1m}Ap>a>+)%EP$)9d%G>|6*E-1`t{|EgfW2=Bu}+k%HN
zYv-d3CBKx~62W;nE1Nq?#R<*oG26fx>G8HgOqg?O_3vmQqV8YO4J{6H11^2?6S{@QV
zd(xJpxO?Ru6sEbBx}%!tCz@_PUJyX2W-_7ibE~V27D6d;gB(@R?A)_#XhM{36LzZV
zFm3g&IyGeFp`}oWdj`KmXNcBZSiUvGRGLw}&$j3GDk}>W=;?RvyOVXhsicW>8V=O4#}}
zyl#Ds7m-0gaJ}
zi3T$eSoRr8sg!=HRTof6xS7Oh{K_GCH^#`0QkZX@spc9pwUcbICfn($rZj9FW(7Zl
zq+^@!0OG8V<-fM@S&)MM6h1IN(bhDS^Vz(;VHOi1ru58tLhxAx>ex5A6TZFDZ)aa%
zwzjmt<$h_69vXtQgbUCJiF8(*icD$j=lGCRoaXxxscKejA2!!M)5+w`Vojn1tvSpM
zlGjiSas!|_UnnGMn_AINGi}w6it1N%N57*g^E|(bK7$D#j!#^*;3u%M3Zp)o->A;@
zY76euDxF5%|FiKvT|TY!cld{L`0^ORNvC-@!yJ@l5%3!9T=jYgWy}ug+AVG_a=z2Y
zE0L)c;#O??y@8Z!Pxnt+@l@UAW*YUPH2yF1W$=R2z=Q3Qgp;q21eiqZjt(QeOQ5l$
zqcWOXMX5q{4%Q)V5noZkfE-q{oS5r6iN~C7Ote-49hntok*vUL^?8o33TK3gxYSme
z*3=|Uq34~e+2EJG_Q`zFPFk_56;r;E`c0=m$adqs7CRZ&VMBX|^qiBfgtW2~Qkpl<
zP-A)Gk_Dd%Ycw}+zY0qQw?ARyZ%IH*U5}g^28N3s2t~1#T_JpDvicv|m}Vs2h*4bI
zaYrT?*N_RrL!~r@g7y^?4z@1?6$D87MtSwJu4~X72_E%4a%tav{}5wJ9GQK^aj5P;
zyZ~%I=o%4Ps`hSu*Uh=H?m6~7`q{}@@9PZe`|rR~#wgw=plRxF+1p4ZkewB^m}ZiU
z4+3zbSA!WW`}+u=ZZ|(Msc-^M%zn+G73L)o0jHf1yL!r0XKX*WN-r+yY{;BGtYIHQ
ztTdx5^;6Eg*uvWPLIn=QJzASEf34NIQOe|I(q0PUqH$pCXdln8RSRa=ForJdJj%@zT(E|j%kCIx`-a4yhttQ??YF*Fs)wQFB
zE)N8uJ6O5|Vy2h=s?YPF@U`ia2I-DH~S^p(Hp$rTy
zc3z5j6Ole0yVz#JAFb5tTqc=D@~~buAj$1|hHAT+a3|Ovju^@3gm)*@`l0IK1oz@C
z#&*``HqRPk06+WmKqszf#OJw9v!{mFv8!%a1VON6?_O4+b^fAv&H?_lrk@SRdzmIk
zbCAJ3iXF?Qh-Io$Q=eKG_}xvN8GF_zB4Qppu^Yq1sH{85nx^|@fskC^5t3_!-X(G;
zdw8Fk4egXUe?L|*fD?C0k0-{h)l)+;W0+cyJ2#v}5XT^A3?(;Az4;}bf00W7@S5l!
zrzh`{NzQ5N4$sRLXLuMpS^hukqq!qqZeH*h3pq%N6>oM8=ykI0h94E{UDk(xMBYfj
ze>PbU-L#tB)BbDqAChuz5%|aGuLuvuNuEckEh6#q)2TXLCrq_Cp6(9@qGfmGnvAIJ
zVDUNxqD!Lz6oV9ONp`GhCipj1V_CUbuPCbWuY5R0r*p99>@}BbG%i$ca5b&+Jw!e5
zGm6wHe6nXSKzrq7VgmC*r-AfgP=dm|P?6t_bdA@9Rfcd~XHEdlfBnJNzxSDoiS2_i
zNWAa{T1BH&LSsJ$5p)nTjR{{TY^GIv85Xvr8@-qhxG}JbAIrSA$`bX9?JRY;%*ceF
z+C&|Wd5+a4*)Ql!Xhkfk+_-Towz!yK`%aArm`(*E`$
zQ9(1sNJ+l?q0zRx1u5>1eTmOZOfzktN_(EQvmJi4>b$eEO21EJ=KLLHEdbE;KlxBNzzca#Fd*D0Xvv!Nf06dqVQqE&wrHqOp+JQeCk0Azg1hzQ1zKo}
zySq2IL#RQE7K#)oR@~jaxVsYqh2Rh%KnRlDMf-mDIp1^l-ru?B@CWcDizQ^vpNu)i
zm;gq3lZ+jelUD!oS!RWBLZDXfVx)rJXNPrRdwDk%-vvKZdYyC}=0@>5=KN?1uG^po
z_W)orl>Y^N3M2>PQOB$vLOf9yxEW*<)UCzgEbb9(B3Bya5MOPOg1MdTdR7;=Ow*|(H^!N8)CB^MUt0`TAj`8u7X8l>ONI4Cvej(!;Z1>J;YioxLF<2wdi7m|{
z$t~c;O%#3!9JJ;@yeb@or!?DbKosRi--GfgzXb|(CIr?&fksQ=%UV%*
z1nhhpcF`u~y>u}4=3+7|&d|H(40nRZ^;<~^vF#n2m_YSupoyD04Zret`w0T7b#eOkCUp4Bzj?ypwV4f;js#i|%Nr|#hvw0@of
zovVbu$Z0`bz+k71nzwgL?OYL?P&4zr$SB#di77X*&X^QSkh2ntvfRV<6)Ed#f2m>4?1DT77FyVSp>D&WPykea)W&ri>r(9--hfq
z!MidA#wl;PjPTEn1Rz#4o(+2C-)
zZuJ7QT@2g(d9g+k>@ASB6S5wLiq&hru!5bwJwh}u?}|Z%I`6!D4*Z7^I8C#Dg#Ry8
zC=a=j??}lEol8GY=Qq73>`@r?Br&eu3~B0BO7V&e!p9#&AiNpH#$5ozM5vmg_eo+|t>bTz{qf%EJ9CL8i-
zaB$FnB^@T2a2Tv;=>N+lMeGFQh@7Qx!CF9hI(^rbq{_^?!sFxPq4VbheF%5iq;rpp
z)flN7Ow-tF1NQ|l2u~-C?_TSY=$enCk{MoXd;I?4IKVS5y8rZ>%5aiAYjNwxu5i}^5&lue15BxP}rQ_
zma}ggwIS>%NXmQ407K(C{A}&J%drn0jf!wNVF|a1LdL*IseNeqI_naRW7PbD?2@mv
zAzIBty5YP~<9wQPZNKK?(`4cphP6c?hjl#G=5RTlvGUsp!K-7&^EBAQc*wuwN8gi(
zS|6f{{U_LsF7mYMR-BivuNir^V(Tn6Y)`Zo#L0?LK#$9em79TX5ovlQlkc&Xn;3oKDiEjjX*kSK(DF+<%dEYc|-ljAXb?a)q|mY
z^o*_fH31B1
z+_vB%ff1|On2LwqVdgJBKJdLQ^#%EmS2O1NBX^wa0J~Ga3fda;7pf
z@TU#2Z2~XFgPypIn6D0GXy_(KVH+~PUkd&*U}>?}JQT2AGQmgnViA
zRRmJ!AK0qwIj$DR))a+?ct_G`FW~{V9y?g*P(33Oaau_Cy9znh8oA?k$CoOC5BZz0bG|{&Nm?
zLXvx_JeC_h%t_^z-oUu&ymb4RKiHY0^IZ&5Ys{U_L%p=G-4K-tx(A+Uae?+
zF?w(ZBk;aXt8r5UaXMMOsfxaEeL5txe9-+w?`ipV&;xrxTVFQw)izagom`DzeP-^z
zWz?EESRQFpA~HTFYVa$~e^TGHdu$#65c5pi>IPpuE-wT`u!EOK5CSp<&T@0on)_iYf#KP0Zt<&HH>KHc^G$!G@mzY5wE
zKImp7=lX{4HcJ$8@IG0TAu+6To#D1=yCBu~-e6LUr8!y|+_4*!G=rZW$+m$L@1iwUdmwPtg%ONg~0DOcbcKA2se&h7bHyViHu3*58LZ`X-dN%2i~Q(xN<
z5dD%xsYY~?Je|(|+rF!q;s}FaLwLQVg;WeLt2y0Y)nDE4#v+clp9$8dat&kR=wleh
zhVx@-r5Y-8BC)@c>WSM7)aRRAB@_$*NM^n|di{3jerzUyG_)icd0#*by^v6hcO&rZ
zRJi@l0lUXvoF(>9NKo4(OeK
z4dg+$a45Y5u}Uu89IT%-z+fRX!j6l;JvaV(7$b#>Qv*uj3f2S@)dAjYD&AarG9;jsI~8YtB{6+7+}N*3JGCG
zb*p5r&R-q!hos(v3lct6&^i6Mkl?)6e-J4aRS{O;tn>5plbjI_@B{6o
z8!j#`dV*4Q7U=Z%ct6vwDwEMc<|>r0X}uyBTOP^MBHd+{_@7)!6!(yqBAS*JXY?zf
zoR1N)%T||5x?-fjlCC=44?VBx;zipqX@Hi{L*nJG(uN^)AQ!l%rO$8ZNvq0APiG!UVrbjuW
zYC?u97T{vZ?vGf11b{>KDGbgN3!X5js~l#RlaXt#}_U~BO5JWNp5%h?GUno9EObZKt`4VP0p(T
zWI37f-Os+?t_GoB(l2oeJ(A{Z%e`5DEhf_huE0a(1MY&p6W2>2jb79%nl$U`6{3lg
zTQS8_Oo9OOAAQ1~Kl`dh!@X+r0nAS|RJA(u<@eklf#J3vw1TH+RO_tMy)0^lBxACN
zf@-WYsp!8t_5im*-T@d$asBdfCtZ_##~t;C$GsnxAhtU$Vjw1^I5vca;#nSW
zw}HG}uYsPwpSo?$t&hn?r5-tBX-RSs_NZx2!Q_chq-tmx7*mu@t||>Mwmr
z``GumE?p8r0BtkT0jLFsGcCL%jAA42!Koy-e2z=b-on#t3nD<2Spt%rr2ZqLFVm
zeGr8i&|FXYqXy3e?dR(~Q1Mm;hLz4Az1&Cl6O{DrLTfkk@Y{w)w%e==WahI&WBzBj(RP;`|VYtAgxoo
z%KPyhG55x!10x@d&w@m~6{3-vj)vpPykpy|e68a1B!m|R=7sW!5W{`&X@Vhua7Gxp
zo*v=g-$Ri>)_CT0GrzbA_!gIf`;p0v-%gK!g2j)z86#+Y
z`bSc5XG8sog!eT{!T1xm%x^TRfL;#ol^)toY#`V-VPV
z9r)CbH>Vm_KlUjRL5P0GcWKvf$<>^rt;wX5c{9w;oL%V5;c#0Qolk$0AD-^j8-V6@
zmuPqPXyx5?^o<9>Lgy)ogCc9&8+=2e_WQpie2$xd7K-}ZZ|UcCCGk?1y)!w@LVa8z
z)NkuNF4<$dR32Pqz28PEaTljS9P-;}a6|+xo8RQ#MjRp0WLt
z4@ycrzW@>wzgWG8rRC}*YTkV|w~vs1waM=+T;lj-W(K}B2|wCU@^fa{9Jf#`ZpNjg
z_nRL)*B-<_mLAoo{}ZUM-&n
zqnP9keMhi}I;5B$AYN!VDFM3j{oHI$*dcQwVXk5v7l0@kO;a
zX@o(D4Y?A)v-;sdxDT2d;kcsG1+?fc$Gh-y`JhuC3%kc
zgaq%+9s{u|s6eMU-itZeebz>v)=eLu`u-S&@YtX6T4Nx@O1Tl?!AJtXz3JKej{>piyG7(twzjdgT2j`b8El
zn7dT^$VB4{+**14{^MCzDM>2)tpinZ>svKpogzzFt}!7k1g`MTqO_5k{=e!h`+dI`N0?;SNgM)0!vCyYbm{2{Xdyh$JO@u;A#<
zoFEiY<#pKACeopz;&Z%RyOw;^e83L%1RnEa%I6IM_oj4m?aY_FlV0-i(uMa#Km64#
zAYmXem(5_r1Y`>p2sTDUTD;oEw@rndP7nM1ir*UTaz}Wn1K{(rtzfcn&)B|Z^}!T?
z(!umAZ9CA(n0LUX$L=Sh7P<;fA^Ufp#dl8Fb{W-mWzq8`ZC)8`XISFnaU0`a0@i=7
z&&LSW8p=(1n<;I8-h1+xXN@&|1iE{GUo-ju6};K{DzNigVIr8;A8D{!sC9n)4Ol%t
z(WMKR&m@l+uVrFDP?@QEj+7&EEi=Bl)epW
zi8NgHaWKi{(TOS;)4E4N-8BvPe;4nSt1Nw-d8X5}bfxdcyYZb@t_2WGw)qWAjTLQ?
z$*&q_$6hw4T8?Mg-f>a=1m;w;oI~_tpfBJ2%~1O5vr$YBy{7>`%QK8jRc7{Q+CKW(
z$2ZxpS%oXMA+tACY1hOiuGbZFicZE|u)b~SwHR9({P0dXE^YQl8oacFJ}Klt&J30Q
zi@ZrU;R6Q5N-Ld}Rxh2tkE|>Le0DQFL}YEWtzCOTZv<-J+USk)Lze~VBeh={Sh8QS
z2nPg9abmR*7@O~WhI)7T`|oP_ePlnCR=A;z88!Jfrjz2E*2ia%m6Zg955@L?Q09UTu_fmZ)w-7FDtuqtHW
zHlcw&y#e-bk6L0(q&wZ$!eNNX4faO08c!=jNTo(Sh8X_jp`aN@{MAc19tg}5wJv7~
zw;IF#dIv*Fb&i|VgEnFltDAN!i$zeGe!tL$C2r_+Aj%um7~=+$>K}3GHu%lO#>c~lV68)!
zS6XQF3FXnN78g9Z7!X1<*aEn>R^$4JJY9m{s*Typ259NdAxGm-KyP2!=o88j3w`&u
zO)q0Uu_@|_;fk0n?
z=j)yJ;;N1%SI>}@jfknn9<2h^MTv4YM!#iV%};3u^k27L7b@{8(hPf(X7GmtOq&_!-jemJ5VfFrHN#*1Rlj!Y$q+CGYM?}-hB5ez|I
zgg@Bc-qsm|h;FVg2X0N>0Q(N-!GJ%j~f;-PCbeUHyL&9_7sH$@evyL&aiz$Aj0ttw4Wm
zYlmW7lRQ1jj(s!kam2jRcjxE}7noQt9$ZOY%YK!ai%QRH?4ztHF%c+4GivD->3Gi*-|oZ9BR3485fw46Z?%0Z{)O9`$nrTe{~GB>4^d2;MA}Ua0q+~3bhK~J-3Xx{*;k%Zu=RX7+V)?*gP9r}p
z6`nQiBAqLiuHF7ePC<4W4ItD-4u>~Bh7TPyvw_1V{U)rnWF9MLoiAcyj1*!u?%&DO
zP5H=XyUwNDs2bWCH{}){77|#WQ&YCt%T&H(4xH)*DR>9|CgDjjDaSURn(kTeIIzsg
zQp`TE&k8BsqzXIm
zIsfI}H>|$EwhR+YrN2GXzr3q`ZNhr<4}{_QZzSHkL9KY;D+BQBzZqb*cmi(gLn&%cXL8SyMbGCPE)OUfhTi#kdr1qR
zB9UpIJfnYEAXX4GeJSX8EPG;2+A#V=0B0CWetGDJmOqNz|ENs=j|cqW5`q5w_>V{b
z#{>TDbbF~raoj>eLML70
zvB-1xc4yy+M&StTWKi5oB8J!faI}}bJ}0H5rafd68>rNw!4>FD*^4U|MLCpqt6Ye$
z91&i+S^v0^P-e_xcyl5qvW%N47G~&1uZ1iU?r^Rp;;^QGSce;!J7o$FHeb1P^>c-|
z(1Q!);|2Py-|p$ED%N^YVr=IyptV^ocougPtxB-Au*t3i0*?h@`_yizBx
zR8q*b$K~r0#j+ZGxjQk#YajEO_VEoMOrEa`9dmpPPY1Le^x+DIJ=bD|{8{~(sTtoL
zst)1Y96u3nWz_Z+e0|g=3r9z>LY>%JHFeG4i8*dh!laFH1Ny5V5o