diff --git a/Gopkg.lock b/Gopkg.lock index da0afc26..e9491956 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -3,7 +3,6 @@ [[projects]] branch = "master" -<<<<<<< HEAD digest = "1:1e34eb32b95242aa7c64217164296b40fe026c14c46a8581aca7918118d7b6b8" name = "code.cloudfoundry.org/bytefmt" packages = ["."] @@ -13,23 +12,11 @@ [[projects]] branch = "master" digest = "1:81f8c061c3d18ed1710957910542bc17d2b789c6cd19e0f654c30b35fd255ca5" -======= - digest = "1:69706f009abd714a03e16892f2632fe37cab837f72a7c3fed926de2f95277179" - name = "code.cloudfoundry.org/bytefmt" - packages = ["."] - pruneopts = "" - revision = "b31f603f5e1e047fdb38584e1a922dcc5c4de5c8" - -[[projects]] - branch = "master" - digest = "1:6978a38432a017763a148afbc7ce6491734b54292af7d3e969d84d2e9dd242e2" ->>>>>>> add hack script to list all pull requests for each release name = "github.com/Azure/go-ansiterm" packages = [ ".", "winterm", ] -<<<<<<< HEAD pruneopts = "NUT" revision = "d6e3b3328b783f23731bc4d058875b0371ff8109" @@ -47,30 +34,10 @@ name = "github.com/Nvveen/Gotty" packages = ["."] pruneopts = "NUT" -======= - pruneopts = "" - revision = "d6e3b3328b783f23731bc4d058875b0371ff8109" - -[[projects]] - digest = "1:6331095c1906771fbe129fe4a1f94ac5b5a97b0f60f2f80653bb95c3e5dad81e" - name = "github.com/Microsoft/go-winio" - packages = ["."] - pruneopts = "" - revision = "7da180ee92d8bd8bb8c37fc560e673e6557c392f" - version = "v0.4.7" - -[[projects]] - branch = "master" - digest = "1:3721a10686511b80c052323423f0de17a8c06d417dbdd3b392b1578432a33aae" - name = "github.com/Nvveen/Gotty" - packages = ["."] - pruneopts = "" ->>>>>>> add hack script to list all pull requests for each release revision = "cd527374f1e5bff4938207604a14f2e38a9cf512" [[projects]] branch = "master" -<<<<<<< HEAD digest = "1:4a029051269e04c040c092eb4ddd92732f8f3a3921a8b43b82b30804e00f3357" name = "github.com/containerd/continuity" packages = ["pathdriver"] @@ -79,35 +46,17 @@ [[projects]] digest = "1:4189ee6a3844f555124d9d2656fe7af02fca961c2a9bad9074789df13a0c62e0" -======= - digest = "1:88e2e57d8169637a91af80db02f21ae0dc9a233f51d794ee5939884aa82c293b" - name = "github.com/containerd/continuity" - packages = ["pathdriver"] - pruneopts = "" - revision = "d3c23511c1bf5851696cba83143d9cbcd666869b" - -[[projects]] - digest = "1:85557947084dd9599b76d06e82f3e35bfdfa109dc4cf195ecf34bf78a91fa11c" ->>>>>>> add hack script to list all pull requests for each release name = "github.com/docker/distribution" packages = [ "digestset", "reference", ] -<<<<<<< HEAD pruneopts = "NUT" revision = "83389a148052d74ac602f5f1d62f86ff2f3c4aa5" [[projects]] branch = "master" digest = "1:678c256d4c5fb4be98f3c3d365d51f268b79d2d4e856e40f2d0cfb334110c145" -======= - pruneopts = "" - revision = "f0cc927784781fa395c06317c58dea2841ece3a9" - -[[projects]] - digest = "1:c0f595126d94f6e395f1b2c3696dbc199cd10cf395673c7086be2a520a3b7ea7" ->>>>>>> add hack script to list all pull requests for each release name = "github.com/docker/docker" packages = [ "api", @@ -138,30 +87,18 @@ "pkg/pools", "pkg/stdcopy", "pkg/system", -<<<<<<< HEAD ] pruneopts = "NUT" revision = "299015de409743b3c85a33872dce645ed748d804" [[projects]] digest = "1:2a47f7eb1a2c30428d1ee6808cb66d4deb17e68a3e55d696f03c8068552ba5e8" -======= - "pkg/term", - "pkg/term/windows", - ] - pruneopts = "" - revision = "a422774e593b33bd287d9890544ad9e09b380d8c" - -[[projects]] - digest = "1:a5ecc2e70260a87aa263811281465a5effcfae8a54bac319cee87c4625f04d63" ->>>>>>> add hack script to list all pull requests for each release name = "github.com/docker/go-connections" packages = [ "nat", "sockets", "tlsconfig", ] -<<<<<<< HEAD pruneopts = "NUT" revision = "7395e3f8aa162843a74ed6d48e79627d9792ac55" version = "v0.4.0" @@ -171,22 +108,10 @@ name = "github.com/docker/go-units" packages = ["."] pruneopts = "NUT" -======= - pruneopts = "" - revision = "3ede32e2033de7505e6500d6c868c2b9ed9f169d" - version = "v0.3.0" - -[[projects]] - digest = "1:582d54fcb7233da8dde1dfd2210a5b9675d0685f84246a8d317b07d680c18b1b" - name = "github.com/docker/go-units" - packages = ["."] - pruneopts = "" ->>>>>>> add hack script to list all pull requests for each release revision = "47565b4f722fb6ceae66b95f853feed578a4a51c" version = "v0.3.3" [[projects]] -<<<<<<< HEAD digest = "1:00d0d550a1f1d7ca03270ebc1e136f21f6b9dab37f0c37e9a90d56d2f7afcff9" name = "github.com/docker/libnetwork" packages = ["ipamutils"] @@ -215,34 +140,15 @@ version = "v1.1.1" [[projects]] - digest = "1:2271ce74ea1368c951255b70585fe2d41822bd887c645f7edf03ccec037eff46" -======= - branch = "master" - digest = "1:f2cfaeef83b91cbd817cce987bf36e323a34ca54b5174435a4dbf6038a664bd5" - name = "github.com/fsouza/go-dockerclient" - packages = ["."] - pruneopts = "" - revision = "51bd33c0c7792b2566054672a4915b406d988cc6" - -[[projects]] - digest = "1:0a3f6a0c68ab8f3d455f8892295503b179e571b7fefe47cc6c556405d1f83411" - name = "github.com/gogo/protobuf" - packages = ["proto"] - pruneopts = "" - revision = "1adfc126b41513cc696b209667c8656ea7aac67c" - version = "v1.0.0" - -[[projects]] - digest = "1:3dd078fda7500c341bc26cfbc6c6a34614f295a2457149fc1045cab767cbcf18" + digest = "1:97df918963298c287643883209a2c3f642e6593379f97ab400c2a2e219ab647d" name = "github.com/golang/protobuf" packages = ["proto"] - pruneopts = "" + pruneopts = "NUT" revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5" version = "v1.2.0" [[projects]] - digest = "1:d09df47b5f07e7918b33724dee52ee909e00413aae751e0b2cbef34011ed9b79" ->>>>>>> add hack script to list all pull requests for each release + digest = "1:2271ce74ea1368c951255b70585fe2d41822bd887c645f7edf03ccec037eff46" name = "github.com/google/go-containerregistry" packages = [ "pkg/authn", @@ -259,47 +165,35 @@ "pkg/v1/types", "pkg/v1/v1util", ] -<<<<<<< HEAD - pruneopts = "NUT" - revision = "dc0a77702ddab8c3dc5630eca7c026d571c1c9b7" - -[[projects]] - digest = "1:406338ad39ab2e37b7f4452906442a3dbf0eb3379dd1f06aafb5c07e769a5fbb" - name = "github.com/inconshreveable/mousetrap" - packages = ["."] pruneopts = "NUT" -======= - pruneopts = "" revision = "dc0a77702ddab8c3dc5630eca7c026d571c1c9b7" [[projects]] - digest = "1:4f646745e87604d6ac39bd2a96b3c2f4a898d1866069fff26b8281d6f84b919e" + digest = "1:f4f203acd8b11b8747bdcd91696a01dbc95ccb9e2ca2db6abf81c3a4f5e950ce" name = "github.com/google/go-github" packages = ["github"] - pruneopts = "" + pruneopts = "NUT" revision = "f55b50f38167644bb7e4be03d9a2bde71d435239" version = "v18.2.0" [[projects]] - digest = "1:cea4aa2038169ee558bf507d5ea02c94ca85bcca28a4c7bb99fd59b31e43a686" + digest = "1:a63cff6b5d8b95638bfe300385d93b2a6d9d687734b863da8e09dc834510a690" name = "github.com/google/go-querystring" packages = ["query"] - pruneopts = "" + pruneopts = "NUT" revision = "44c6ddd0a2342c386950e880b658017258da92fc" version = "v1.0.0" [[projects]] - digest = "1:870d441fe217b8e689d7949fef6e43efbc787e50f200cb1e70dbca9204a1d6be" + digest = "1:406338ad39ab2e37b7f4452906442a3dbf0eb3379dd1f06aafb5c07e769a5fbb" name = "github.com/inconshreveable/mousetrap" packages = ["."] - pruneopts = "" ->>>>>>> add hack script to list all pull requests for each release + pruneopts = "NUT" revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" [[projects]] branch = "master" -<<<<<<< HEAD digest = "1:c8a452cc8dd4ef9f857570ce2be31ca257a0928bf3c2b08cd7e11972b985c6d7" name = "github.com/konsorten/go-windows-terminal-sequences" packages = ["."] @@ -326,114 +220,53 @@ name = "github.com/opencontainers/go-digest" packages = ["."] pruneopts = "NUT" -======= - digest = "1:99651e95333755cbe5c9768c1b80031300acca64a80870b40309202b32585a5a" - name = "github.com/mitchellh/go-homedir" - packages = ["."] - pruneopts = "" - revision = "3864e76763d94a6df2f9960b16a20a33da9f9a66" - -[[projects]] - branch = "master" - digest = "1:09b661e6a19992c3fef4ec71700d1f17dfe4640142e2918d6659cae3d62cb9d5" - name = "github.com/nightlyone/lockfile" - packages = ["."] - pruneopts = "" - revision = "6a197d5ea61168f2ac821de2b7f011b250904900" - -[[projects]] - digest = "1:5d9b668b0b4581a978f07e7d2e3314af18eb27b3fb5d19b70185b7c575723d11" - name = "github.com/opencontainers/go-digest" - packages = ["."] - pruneopts = "" ->>>>>>> add hack script to list all pull requests for each release revision = "279bed98673dd5bef374d3b6e4b09e2af76183bf" version = "v1.0.0-rc1" [[projects]] -<<<<<<< HEAD digest = "1:11db38d694c130c800d0aefb502fb02519e514dc53d9804ce51d1ad25ec27db6" -======= - digest = "1:f26c8670b11e29a49c8e45f7ec7f2d5bac62e8fd4e3c0ae1662baa4a697f984a" ->>>>>>> add hack script to list all pull requests for each release name = "github.com/opencontainers/image-spec" packages = [ "specs-go", "specs-go/v1", ] -<<<<<<< HEAD pruneopts = "NUT" -======= - pruneopts = "" ->>>>>>> add hack script to list all pull requests for each release revision = "d60099175f88c47cd379c4738d158884749ed235" version = "v1.0.1" [[projects]] -<<<<<<< HEAD digest = "1:918dbd46ad099418ce9760291bb156ebf23d441aad4cb682dd9bf09e2d3c0c7b" name = "github.com/opencontainers/runc" packages = ["libcontainer/user"] pruneopts = "NUT" -======= - digest = "1:fa19ddee0e5ee5951a6a450a4b6ec635a42957f86bfc87d9d778eeee04ad2036" - name = "github.com/opencontainers/runc" - packages = [ - "libcontainer/system", - "libcontainer/user", - ] - pruneopts = "" ->>>>>>> add hack script to list all pull requests for each release revision = "baf6536d6259209c3edfa2b22237af82942d3dfa" version = "v0.1.1" [[projects]] -<<<<<<< HEAD digest = "1:5cf3f025cbee5951a4ee961de067c8a89fc95a5adabead774f82822efabab121" name = "github.com/pkg/errors" packages = ["."] pruneopts = "NUT" -======= - digest = "1:7365acd48986e205ccb8652cc746f09c8b7876030d53710ea6ef7d0bd0dcd7ca" - name = "github.com/pkg/errors" - packages = ["."] - pruneopts = "" ->>>>>>> add hack script to list all pull requests for each release revision = "645ef00459ed84a119197bfb8d8205042c6df63d" version = "v0.8.0" [[projects]] -<<<<<<< HEAD digest = "1:de406937d444963016a8644b65e56e2f241a1d81f76418ce59ed12257fabb5ad" name = "github.com/pkg/profile" packages = ["."] pruneopts = "NUT" -======= - digest = "1:1cbc6b98173422a756ae79e485952cb37a0a460c710541c75d3e9961c5a60782" - name = "github.com/pkg/profile" - packages = ["."] - pruneopts = "" ->>>>>>> add hack script to list all pull requests for each release revision = "5b67d428864e92711fcbd2f8629456121a56d91f" version = "v1.2.1" [[projects]] -<<<<<<< HEAD digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe" name = "github.com/pmezard/go-difflib" packages = ["difflib"] pruneopts = "NUT" -======= - digest = "1:256484dbbcd271f9ecebc6795b2df8cad4c458dd0f5fd82a8c2fa0c29f233411" - name = "github.com/pmezard/go-difflib" - packages = ["difflib"] - pruneopts = "" ->>>>>>> add hack script to list all pull requests for each release revision = "792786c7400a136282c1664665ae0a8db921c6c2" version = "v1.0.0" [[projects]] -<<<<<<< HEAD digest = "1:01252cd79aac70f16cac02a72a1067dd136e0ad6d5b597d0129cf74c739fd8d1" name = "github.com/sirupsen/logrus" packages = ["."] @@ -446,25 +279,10 @@ name = "github.com/spf13/cobra" packages = ["."] pruneopts = "NUT" -======= - digest = "1:8cf46b6c18a91068d446e26b67512cf16f1540b45d90b28b9533706a127f0ca6" - name = "github.com/sirupsen/logrus" - packages = ["."] - pruneopts = "" - revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc" - version = "v1.0.5" - -[[projects]] - digest = "1:a1403cc8a94b8d7956ee5e9694badef0e7b051af289caad1cf668331e3ffa4f6" - name = "github.com/spf13/cobra" - packages = ["."] - pruneopts = "" ->>>>>>> add hack script to list all pull requests for each release revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385" version = "v0.0.3" [[projects]] -<<<<<<< HEAD digest = "1:e3707aeaccd2adc89eba6c062fec72116fe1fc1ba71097da85b4d8ae1668a675" name = "github.com/spf13/pflag" packages = ["."] @@ -483,26 +301,6 @@ [[projects]] branch = "master" digest = "1:d9f9f45d3383b93ce1c7e744b3ede6974917ae4d100e1a7abfc2906e5e5e2e28" -======= - digest = "1:8e243c568f36b09031ec18dff5f7d2769dcf5ca4d624ea511c8e3197dc3d352d" - name = "github.com/spf13/pflag" - packages = ["."] - pruneopts = "" - revision = "583c0c0531f06d5278b7d917446061adc344b5cd" - version = "v1.0.1" - -[[projects]] - branch = "master" - digest = "1:8af4dda167d0ef21ab0affc797bff87ed0e87c57bd1d9bf57ad8f72d348c7932" - name = "golang.org/x/crypto" - packages = ["ssh/terminal"] - pruneopts = "" - revision = "8ac0e0d97ce45cd83d1d7243c060cb8461dda5e9" - -[[projects]] - branch = "master" - digest = "1:5dc6753986b9eeba4abdf05dedc5ba06bb52dad43cc8aad35ffb42bb7adfa68f" ->>>>>>> add hack script to list all pull requests for each release name = "golang.org/x/net" packages = [ "context", @@ -510,47 +308,33 @@ "internal/socks", "proxy", ] -<<<<<<< HEAD pruneopts = "NUT" revision = "4dfa2610cdf3b287375bbba5b8f2a14d3b01d8de" [[projects]] branch = "master" - digest = "1:4ea08b5c4c51887a54caee2954db97b620736ae510bdc8514f691d3a9375d93a" -======= - pruneopts = "" - revision = "db08ff08e8622530d9ed3a0e8ac279f6d4c02196" - -[[projects]] - branch = "master" - digest = "1:b697592485cb412be4188c08ca0beed9aab87f36b86418e21acc4a3998f63734" + digest = "1:db0ef10bef8ec68d343f7371d5d6006c1086b5882654e10e7cc9335bfb551b8d" name = "golang.org/x/oauth2" packages = [ ".", "internal", ] - pruneopts = "" + pruneopts = "NUT" revision = "d2e6202438beef2727060aa7cabdd924d92ebfd9" [[projects]] branch = "master" - digest = "1:baee54aa41cb93366e76a9c29f8dd2e4c4e6a35ff89551721d5275d2c858edc9" ->>>>>>> add hack script to list all pull requests for each release + digest = "1:4ea08b5c4c51887a54caee2954db97b620736ae510bdc8514f691d3a9375d93a" name = "golang.org/x/sys" packages = [ "unix", "windows", ] -<<<<<<< HEAD pruneopts = "NUT" revision = "e4b3c5e9061176387e7cea65e4dc5853801f3fb7" -======= - pruneopts = "" - revision = "bff228c7b664c5fce602223a05fb708fd8654986" ->>>>>>> add hack script to list all pull requests for each release [[projects]] - digest = "1:8c432632a230496c35a15cfdf441436f04c90e724ad99c8463ef0c82bbe93edb" + digest = "1:36354a269794d9cb4cebae233f65a966e818f763088370c8524726853a31c96f" name = "google.golang.org/appengine" packages = [ "internal", @@ -561,7 +345,7 @@ "internal/urlfetch", "urlfetch", ] - pruneopts = "" + pruneopts = "NUT" revision = "ae0ab99deb4dc413a2b4bd6c8bdd0eb67f1e4d06" version = "v1.2.0" @@ -570,10 +354,6 @@ analyzer-version = 1 input-imports = [ "code.cloudfoundry.org/bytefmt", -<<<<<<< HEAD -======= - "github.com/docker/distribution", ->>>>>>> add hack script to list all pull requests for each release "github.com/docker/docker/api/types", "github.com/docker/docker/client", "github.com/docker/docker/pkg/system", @@ -588,10 +368,7 @@ "github.com/google/go-containerregistry/pkg/v1/remote", "github.com/google/go-containerregistry/pkg/v1/tarball", "github.com/google/go-containerregistry/pkg/v1/types", -<<<<<<< HEAD -======= "github.com/google/go-github/github", ->>>>>>> add hack script to list all pull requests for each release "github.com/mitchellh/go-homedir", "github.com/nightlyone/lockfile", "github.com/pkg/errors", @@ -600,10 +377,7 @@ "github.com/sirupsen/logrus", "github.com/spf13/cobra", "github.com/spf13/pflag", -<<<<<<< HEAD -======= "golang.org/x/oauth2", ->>>>>>> add hack script to list all pull requests for each release ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/vendor/github.com/Microsoft/go-winio/archive/tar/LICENSE b/vendor/github.com/Microsoft/go-winio/archive/tar/LICENSE new file mode 100644 index 00000000..74487567 --- /dev/null +++ b/vendor/github.com/Microsoft/go-winio/archive/tar/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2012 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/docker/docker/contrib/syntax/vim/LICENSE b/vendor/github.com/docker/docker/contrib/syntax/vim/LICENSE new file mode 100644 index 00000000..e67cdabd --- /dev/null +++ b/vendor/github.com/docker/docker/contrib/syntax/vim/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2013 Honza Pokorny +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/docker/docker/docs/static_files/contributors.png b/vendor/github.com/docker/docker/docs/static_files/contributors.png new file mode 100644 index 00000000..63c0a0c0 Binary files /dev/null and b/vendor/github.com/docker/docker/docs/static_files/contributors.png differ diff --git a/vendor/github.com/docker/docker/errdefs/defs.go b/vendor/github.com/docker/docker/errdefs/defs.go new file mode 100644 index 00000000..e6a2275b --- /dev/null +++ b/vendor/github.com/docker/docker/errdefs/defs.go @@ -0,0 +1,74 @@ +package errdefs // import "github.com/docker/docker/errdefs" + +// ErrNotFound signals that the requested object doesn't exist +type ErrNotFound interface { + NotFound() +} + +// ErrInvalidParameter signals that the user input is invalid +type ErrInvalidParameter interface { + InvalidParameter() +} + +// ErrConflict signals that some internal state conflicts with the requested action and can't be performed. +// A change in state should be able to clear this error. +type ErrConflict interface { + Conflict() +} + +// ErrUnauthorized is used to signify that the user is not authorized to perform a specific action +type ErrUnauthorized interface { + Unauthorized() +} + +// ErrUnavailable signals that the requested action/subsystem is not available. +type ErrUnavailable interface { + Unavailable() +} + +// ErrForbidden signals that the requested action cannot be performed under any circumstances. +// When a ErrForbidden is returned, the caller should never retry the action. +type ErrForbidden interface { + Forbidden() +} + +// ErrSystem signals that some internal error occurred. +// An example of this would be a failed mount request. +type ErrSystem interface { + System() +} + +// ErrNotModified signals that an action can't be performed because it's already in the desired state +type ErrNotModified interface { + NotModified() +} + +// ErrAlreadyExists is a special case of ErrConflict which signals that the desired object already exists +type ErrAlreadyExists interface { + AlreadyExists() +} + +// ErrNotImplemented signals that the requested action/feature is not implemented on the system as configured. +type ErrNotImplemented interface { + NotImplemented() +} + +// ErrUnknown signals that the kind of error that occurred is not known. +type ErrUnknown interface { + Unknown() +} + +// ErrCancelled signals that the action was cancelled. +type ErrCancelled interface { + Cancelled() +} + +// ErrDeadline signals that the deadline was reached before the action completed. +type ErrDeadline interface { + DeadlineExceeded() +} + +// ErrDataLoss indicates that data was lost or there is data corruption. +type ErrDataLoss interface { + DataLoss() +} diff --git a/vendor/github.com/docker/docker/errdefs/doc.go b/vendor/github.com/docker/docker/errdefs/doc.go new file mode 100644 index 00000000..c211f174 --- /dev/null +++ b/vendor/github.com/docker/docker/errdefs/doc.go @@ -0,0 +1,8 @@ +// Package errdefs defines a set of error interfaces that packages should use for communicating classes of errors. +// Errors that cross the package boundary should implement one (and only one) of these interfaces. +// +// Packages should not reference these interfaces directly, only implement them. +// To check if a particular error implements one of these interfaces, there are helper +// functions provided (e.g. `Is`) which can be used rather than asserting the interfaces directly. +// If you must assert on these interfaces, be sure to check the causal chain (`err.Cause()`). +package errdefs // import "github.com/docker/docker/errdefs" diff --git a/vendor/github.com/docker/docker/errdefs/helpers.go b/vendor/github.com/docker/docker/errdefs/helpers.go new file mode 100644 index 00000000..6169c2bc --- /dev/null +++ b/vendor/github.com/docker/docker/errdefs/helpers.go @@ -0,0 +1,240 @@ +package errdefs // import "github.com/docker/docker/errdefs" + +import "context" + +type errNotFound struct{ error } + +func (errNotFound) NotFound() {} + +func (e errNotFound) Cause() error { + return e.error +} + +// NotFound is a helper to create an error of the class with the same name from any error type +func NotFound(err error) error { + if err == nil { + return nil + } + return errNotFound{err} +} + +type errInvalidParameter struct{ error } + +func (errInvalidParameter) InvalidParameter() {} + +func (e errInvalidParameter) Cause() error { + return e.error +} + +// InvalidParameter is a helper to create an error of the class with the same name from any error type +func InvalidParameter(err error) error { + if err == nil { + return nil + } + return errInvalidParameter{err} +} + +type errConflict struct{ error } + +func (errConflict) Conflict() {} + +func (e errConflict) Cause() error { + return e.error +} + +// Conflict is a helper to create an error of the class with the same name from any error type +func Conflict(err error) error { + if err == nil { + return nil + } + return errConflict{err} +} + +type errUnauthorized struct{ error } + +func (errUnauthorized) Unauthorized() {} + +func (e errUnauthorized) Cause() error { + return e.error +} + +// Unauthorized is a helper to create an error of the class with the same name from any error type +func Unauthorized(err error) error { + if err == nil { + return nil + } + return errUnauthorized{err} +} + +type errUnavailable struct{ error } + +func (errUnavailable) Unavailable() {} + +func (e errUnavailable) Cause() error { + return e.error +} + +// Unavailable is a helper to create an error of the class with the same name from any error type +func Unavailable(err error) error { + return errUnavailable{err} +} + +type errForbidden struct{ error } + +func (errForbidden) Forbidden() {} + +func (e errForbidden) Cause() error { + return e.error +} + +// Forbidden is a helper to create an error of the class with the same name from any error type +func Forbidden(err error) error { + if err == nil { + return nil + } + return errForbidden{err} +} + +type errSystem struct{ error } + +func (errSystem) System() {} + +func (e errSystem) Cause() error { + return e.error +} + +// System is a helper to create an error of the class with the same name from any error type +func System(err error) error { + if err == nil { + return nil + } + return errSystem{err} +} + +type errNotModified struct{ error } + +func (errNotModified) NotModified() {} + +func (e errNotModified) Cause() error { + return e.error +} + +// NotModified is a helper to create an error of the class with the same name from any error type +func NotModified(err error) error { + if err == nil { + return nil + } + return errNotModified{err} +} + +type errAlreadyExists struct{ error } + +func (errAlreadyExists) AlreadyExists() {} + +func (e errAlreadyExists) Cause() error { + return e.error +} + +// AlreadyExists is a helper to create an error of the class with the same name from any error type +func AlreadyExists(err error) error { + if err == nil { + return nil + } + return errAlreadyExists{err} +} + +type errNotImplemented struct{ error } + +func (errNotImplemented) NotImplemented() {} + +func (e errNotImplemented) Cause() error { + return e.error +} + +// NotImplemented is a helper to create an error of the class with the same name from any error type +func NotImplemented(err error) error { + if err == nil { + return nil + } + return errNotImplemented{err} +} + +type errUnknown struct{ error } + +func (errUnknown) Unknown() {} + +func (e errUnknown) Cause() error { + return e.error +} + +// Unknown is a helper to create an error of the class with the same name from any error type +func Unknown(err error) error { + if err == nil { + return nil + } + return errUnknown{err} +} + +type errCancelled struct{ error } + +func (errCancelled) Cancelled() {} + +func (e errCancelled) Cause() error { + return e.error +} + +// Cancelled is a helper to create an error of the class with the same name from any error type +func Cancelled(err error) error { + if err == nil { + return nil + } + return errCancelled{err} +} + +type errDeadline struct{ error } + +func (errDeadline) DeadlineExceeded() {} + +func (e errDeadline) Cause() error { + return e.error +} + +// Deadline is a helper to create an error of the class with the same name from any error type +func Deadline(err error) error { + if err == nil { + return nil + } + return errDeadline{err} +} + +type errDataLoss struct{ error } + +func (errDataLoss) DataLoss() {} + +func (e errDataLoss) Cause() error { + return e.error +} + +// DataLoss is a helper to create an error of the class with the same name from any error type +func DataLoss(err error) error { + if err == nil { + return nil + } + return errDataLoss{err} +} + +// FromContext returns the error class from the passed in context +func FromContext(ctx context.Context) error { + e := ctx.Err() + if e == nil { + return nil + } + + if e == context.Canceled { + return Cancelled(e) + } + if e == context.DeadlineExceeded { + return Deadline(e) + } + return Unknown(e) +} diff --git a/vendor/github.com/docker/docker/errdefs/is.go b/vendor/github.com/docker/docker/errdefs/is.go index 5f36e80a..e0513331 100644 --- a/vendor/github.com/docker/docker/errdefs/is.go +++ b/vendor/github.com/docker/docker/errdefs/is.go @@ -47,11 +47,7 @@ func IsConflict(err error) bool { return ok } -<<<<<<< HEAD // IsUnauthorized returns if the passed in error is an ErrUnauthorized -======= -// IsUnauthorized returns if the the passed in error is an ErrUnauthorized ->>>>>>> add hack script to list all pull requests for each release func IsUnauthorized(err error) bool { _, ok := getImplementer(err).(ErrUnauthorized) return ok diff --git a/vendor/github.com/docker/docker/hack/generate-authors.sh b/vendor/github.com/docker/docker/hack/generate-authors.sh new file mode 100755 index 00000000..680bdb7b --- /dev/null +++ b/vendor/github.com/docker/docker/hack/generate-authors.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -e + +cd "$(dirname "$(readlink -f "$BASH_SOURCE")")/.." + +# see also ".mailmap" for how email addresses and names are deduplicated + +{ + cat <<-'EOH' + # This file lists all individuals having contributed content to the repository. + # For how it is generated, see `hack/generate-authors.sh`. + EOH + echo + git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf +} > AUTHORS diff --git a/vendor/github.com/docker/docker/integration-cli/fixtures/https/ca.pem b/vendor/github.com/docker/docker/integration-cli/fixtures/https/ca.pem new file mode 120000 index 00000000..70a3e6ce --- /dev/null +++ b/vendor/github.com/docker/docker/integration-cli/fixtures/https/ca.pem @@ -0,0 +1 @@ +../../../integration/testdata/https/ca.pem \ No newline at end of file diff --git a/vendor/github.com/docker/docker/integration-cli/fixtures/https/client-cert.pem b/vendor/github.com/docker/docker/integration-cli/fixtures/https/client-cert.pem new file mode 120000 index 00000000..45888202 --- /dev/null +++ b/vendor/github.com/docker/docker/integration-cli/fixtures/https/client-cert.pem @@ -0,0 +1 @@ +../../../integration/testdata/https/client-cert.pem \ No newline at end of file diff --git a/vendor/github.com/docker/docker/integration-cli/fixtures/https/client-key.pem b/vendor/github.com/docker/docker/integration-cli/fixtures/https/client-key.pem new file mode 120000 index 00000000..d5f6bbee --- /dev/null +++ b/vendor/github.com/docker/docker/integration-cli/fixtures/https/client-key.pem @@ -0,0 +1 @@ +../../../integration/testdata/https/client-key.pem \ No newline at end of file diff --git a/vendor/github.com/docker/docker/integration-cli/fixtures/https/server-cert.pem b/vendor/github.com/docker/docker/integration-cli/fixtures/https/server-cert.pem new file mode 120000 index 00000000..c1860106 --- /dev/null +++ b/vendor/github.com/docker/docker/integration-cli/fixtures/https/server-cert.pem @@ -0,0 +1 @@ +../../../integration/testdata/https/server-cert.pem \ No newline at end of file diff --git a/vendor/github.com/docker/docker/integration-cli/fixtures/https/server-key.pem b/vendor/github.com/docker/docker/integration-cli/fixtures/https/server-key.pem new file mode 120000 index 00000000..48b9c2df --- /dev/null +++ b/vendor/github.com/docker/docker/integration-cli/fixtures/https/server-key.pem @@ -0,0 +1 @@ +../../../integration/testdata/https/server-key.pem \ No newline at end of file diff --git a/vendor/github.com/docker/docker/pkg/symlink/LICENSE.APACHE b/vendor/github.com/docker/docker/pkg/symlink/LICENSE.APACHE index 87a8fb2e..5d80670b 100644 --- a/vendor/github.com/docker/docker/pkg/symlink/LICENSE.APACHE +++ b/vendor/github.com/docker/docker/pkg/symlink/LICENSE.APACHE @@ -176,11 +176,7 @@ END OF TERMS AND CONDITIONS -<<<<<<< HEAD Copyright 2014-2018 Docker, Inc. -======= - Copyright 2014-2017 Docker, Inc. ->>>>>>> add hack script to list all pull requests for each release Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/vendor/github.com/docker/docker/pkg/symlink/LICENSE.BSD b/vendor/github.com/docker/docker/pkg/symlink/LICENSE.BSD index 59aeb208..2ee8768d 100644 --- a/vendor/github.com/docker/docker/pkg/symlink/LICENSE.BSD +++ b/vendor/github.com/docker/docker/pkg/symlink/LICENSE.BSD @@ -1,8 +1,4 @@ -<<<<<<< HEAD Copyright (c) 2014-2018 The Docker & Go Authors. All rights reserved. -======= -Copyright (c) 2014-2017 The Docker & Go Authors. All rights reserved. ->>>>>>> add hack script to list all pull requests for each release Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are diff --git a/vendor/github.com/docker/docker/project/CONTRIBUTING.md b/vendor/github.com/docker/docker/project/CONTRIBUTING.md new file mode 120000 index 00000000..44fcc634 --- /dev/null +++ b/vendor/github.com/docker/docker/project/CONTRIBUTING.md @@ -0,0 +1 @@ +../CONTRIBUTING.md \ No newline at end of file diff --git a/vendor/github.com/golang/protobuf/.gitignore b/vendor/github.com/golang/protobuf/.gitignore deleted file mode 100644 index c7dd4058..00000000 --- a/vendor/github.com/golang/protobuf/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -.DS_Store -*.[568ao] -*.ao -*.so -*.pyc -._* -.nfs.* -[568a].out -*~ -*.orig -core -_obj -_test -_testmain.go - -# Conformance test output and transient files. -conformance/failing_tests.txt diff --git a/vendor/github.com/golang/protobuf/.travis.yml b/vendor/github.com/golang/protobuf/.travis.yml deleted file mode 100644 index 78949c88..00000000 --- a/vendor/github.com/golang/protobuf/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -sudo: false -language: go -go: -- 1.6.x -- 1.10.x -- 1.x - -install: - - go get -v -d google.golang.org/grpc - - go get -v -d -t github.com/golang/protobuf/... - - curl -L https://github.com/google/protobuf/releases/download/v3.5.1/protoc-3.5.1-linux-x86_64.zip -o /tmp/protoc.zip - - unzip /tmp/protoc.zip -d "$HOME"/protoc - - mkdir -p "$HOME"/src && ln -s "$HOME"/protoc "$HOME"/src/protobuf - -env: - - PATH=$HOME/protoc/bin:$PATH - -script: - - make all - - make regenerate - # TODO(tamird): When https://github.com/travis-ci/gimme/pull/130 is - # released, make this look for "1.x". - - if [[ "$TRAVIS_GO_VERSION" == 1.10* ]]; then - if [[ "$(git status --porcelain 2>&1)" != "" ]]; then - git status >&2; - git diff -a >&2; - exit 1; - fi; - echo "git status is clean."; - fi; - - make test diff --git a/vendor/github.com/golang/protobuf/Makefile b/vendor/github.com/golang/protobuf/Makefile deleted file mode 100644 index 7a51c95b..00000000 --- a/vendor/github.com/golang/protobuf/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -# Go support for Protocol Buffers - Google's data interchange format -# -# Copyright 2010 The Go Authors. All rights reserved. -# https://github.com/golang/protobuf -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -all: install - -install: - go install ./proto ./jsonpb ./ptypes ./protoc-gen-go - -test: - go test ./... ./protoc-gen-go/testdata - go test -tags purego ./... ./protoc-gen-go/testdata - go build ./protoc-gen-go/testdata/grpc/grpc.pb.go - make -C conformance test - -clean: - go clean ./... - -nuke: - go clean -i ./... - -regenerate: - ./regenerate.sh diff --git a/vendor/github.com/golang/protobuf/README.md b/vendor/github.com/golang/protobuf/README.md deleted file mode 100644 index 61820bed..00000000 --- a/vendor/github.com/golang/protobuf/README.md +++ /dev/null @@ -1,281 +0,0 @@ -# Go support for Protocol Buffers - Google's data interchange format - -[![Build Status](https://travis-ci.org/golang/protobuf.svg?branch=master)](https://travis-ci.org/golang/protobuf) -[![GoDoc](https://godoc.org/github.com/golang/protobuf?status.svg)](https://godoc.org/github.com/golang/protobuf) - -Google's data interchange format. -Copyright 2010 The Go Authors. -https://github.com/golang/protobuf - -This package and the code it generates requires at least Go 1.6. - -This software implements Go bindings for protocol buffers. For -information about protocol buffers themselves, see - https://developers.google.com/protocol-buffers/ - -## Installation ## - -To use this software, you must: -- Install the standard C++ implementation of protocol buffers from - https://developers.google.com/protocol-buffers/ -- Of course, install the Go compiler and tools from - https://golang.org/ - See - https://golang.org/doc/install - for details or, if you are using gccgo, follow the instructions at - https://golang.org/doc/install/gccgo -- Grab the code from the repository and install the proto package. - The simplest way is to run `go get -u github.com/golang/protobuf/protoc-gen-go`. - The compiler plugin, protoc-gen-go, will be installed in $GOBIN, - defaulting to $GOPATH/bin. It must be in your $PATH for the protocol - compiler, protoc, to find it. - -This software has two parts: a 'protocol compiler plugin' that -generates Go source files that, once compiled, can access and manage -protocol buffers; and a library that implements run-time support for -encoding (marshaling), decoding (unmarshaling), and accessing protocol -buffers. - -There is support for gRPC in Go using protocol buffers. -See the note at the bottom of this file for details. - -There are no insertion points in the plugin. - - -## Using protocol buffers with Go ## - -Once the software is installed, there are two steps to using it. -First you must compile the protocol buffer definitions and then import -them, with the support library, into your program. - -To compile the protocol buffer definition, run protoc with the --go_out -parameter set to the directory you want to output the Go code to. - - protoc --go_out=. *.proto - -The generated files will be suffixed .pb.go. See the Test code below -for an example using such a file. - -## Packages and input paths ## - -The protocol buffer language has a concept of "packages" which does not -correspond well to the Go notion of packages. In generated Go code, -each source `.proto` file is associated with a single Go package. The -name and import path for this package is specified with the `go_package` -proto option: - - option go_package = "github.com/golang/protobuf/ptypes/any"; - -The protocol buffer compiler will attempt to derive a package name and -import path if a `go_package` option is not present, but it is -best to always specify one explicitly. - -There is a one-to-one relationship between source `.proto` files and -generated `.pb.go` files, but any number of `.pb.go` files may be -contained in the same Go package. - -The output name of a generated file is produced by replacing the -`.proto` suffix with `.pb.go` (e.g., `foo.proto` produces `foo.pb.go`). -However, the output directory is selected in one of two ways. Let -us say we have `inputs/x.proto` with a `go_package` option of -`github.com/golang/protobuf/p`. The corresponding output file may -be: - -- Relative to the import path: - -```shell - protoc --go_out=. inputs/x.proto - # writes ./github.com/golang/protobuf/p/x.pb.go -``` - - (This can work well with `--go_out=$GOPATH`.) - -- Relative to the input file: - -```shell -protoc --go_out=paths=source_relative:. inputs/x.proto -# generate ./inputs/x.pb.go -``` - -## Generated code ## - -The package comment for the proto library contains text describing -the interface provided in Go for protocol buffers. Here is an edited -version. - -The proto package converts data structures to and from the -wire format of protocol buffers. It works in concert with the -Go source code generated for .proto files by the protocol compiler. - -A summary of the properties of the protocol buffer interface -for a protocol buffer variable v: - - - Names are turned from camel_case to CamelCase for export. - - There are no methods on v to set fields; just treat - them as structure fields. - - There are getters that return a field's value if set, - and return the field's default value if unset. - The getters work even if the receiver is a nil message. - - The zero value for a struct is its correct initialization state. - All desired fields must be set before marshaling. - - A Reset() method will restore a protobuf struct to its zero state. - - Non-repeated fields are pointers to the values; nil means unset. - That is, optional or required field int32 f becomes F *int32. - - Repeated fields are slices. - - Helper functions are available to aid the setting of fields. - Helpers for getting values are superseded by the - GetFoo methods and their use is deprecated. - msg.Foo = proto.String("hello") // set field - - Constants are defined to hold the default values of all fields that - have them. They have the form Default_StructName_FieldName. - Because the getter methods handle defaulted values, - direct use of these constants should be rare. - - Enums are given type names and maps from names to values. - Enum values are prefixed with the enum's type name. Enum types have - a String method, and a Enum method to assist in message construction. - - Nested groups and enums have type names prefixed with the name of - the surrounding message type. - - Extensions are given descriptor names that start with E_, - followed by an underscore-delimited list of the nested messages - that contain it (if any) followed by the CamelCased name of the - extension field itself. HasExtension, ClearExtension, GetExtension - and SetExtension are functions for manipulating extensions. - - Oneof field sets are given a single field in their message, - with distinguished wrapper types for each possible field value. - - Marshal and Unmarshal are functions to encode and decode the wire format. - -When the .proto file specifies `syntax="proto3"`, there are some differences: - - - Non-repeated fields of non-message type are values instead of pointers. - - Enum types do not get an Enum method. - -Consider file test.proto, containing - -```proto - syntax = "proto2"; - package example; - - enum FOO { X = 17; }; - - message Test { - required string label = 1; - optional int32 type = 2 [default=77]; - repeated int64 reps = 3; - } -``` - -To create and play with a Test object from the example package, - -```go - package main - - import ( - "log" - - "github.com/golang/protobuf/proto" - "path/to/example" - ) - - func main() { - test := &example.Test{ - Label: proto.String("hello"), - Type: proto.Int32(17), - Reps: []int64{1, 2, 3}, - } - data, err := proto.Marshal(test) - if err != nil { - log.Fatal("marshaling error: ", err) - } - newTest := &example.Test{} - err = proto.Unmarshal(data, newTest) - if err != nil { - log.Fatal("unmarshaling error: ", err) - } - // Now test and newTest contain the same data. - if test.GetLabel() != newTest.GetLabel() { - log.Fatalf("data mismatch %q != %q", test.GetLabel(), newTest.GetLabel()) - } - // etc. - } -``` - -## Parameters ## - -To pass extra parameters to the plugin, use a comma-separated -parameter list separated from the output directory by a colon: - - protoc --go_out=plugins=grpc,import_path=mypackage:. *.proto - -- `paths=(import | source_relative)` - specifies how the paths of - generated files are structured. See the "Packages and imports paths" - section above. The default is `import`. -- `plugins=plugin1+plugin2` - specifies the list of sub-plugins to - load. The only plugin in this repo is `grpc`. -- `Mfoo/bar.proto=quux/shme` - declares that foo/bar.proto is - associated with Go package quux/shme. This is subject to the - import_prefix parameter. - -The following parameters are deprecated and should not be used: - -- `import_prefix=xxx` - a prefix that is added onto the beginning of - all imports. -- `import_path=foo/bar` - used as the package if no input files - declare `go_package`. If it contains slashes, everything up to the - rightmost slash is ignored. - -## gRPC Support ## - -If a proto file specifies RPC services, protoc-gen-go can be instructed to -generate code compatible with gRPC (http://www.grpc.io/). To do this, pass -the `plugins` parameter to protoc-gen-go; the usual way is to insert it into -the --go_out argument to protoc: - - protoc --go_out=plugins=grpc:. *.proto - -## Compatibility ## - -The library and the generated code are expected to be stable over time. -However, we reserve the right to make breaking changes without notice for the -following reasons: - -- Security. A security issue in the specification or implementation may come to - light whose resolution requires breaking compatibility. We reserve the right - to address such security issues. -- Unspecified behavior. There are some aspects of the Protocol Buffers - specification that are undefined. Programs that depend on such unspecified - behavior may break in future releases. -- Specification errors or changes. If it becomes necessary to address an - inconsistency, incompleteness, or change in the Protocol Buffers - specification, resolving the issue could affect the meaning or legality of - existing programs. We reserve the right to address such issues, including - updating the implementations. -- Bugs. If the library has a bug that violates the specification, a program - that depends on the buggy behavior may break if the bug is fixed. We reserve - the right to fix such bugs. -- Adding methods or fields to generated structs. These may conflict with field - names that already exist in a schema, causing applications to break. When the - code generator encounters a field in the schema that would collide with a - generated field or method name, the code generator will append an underscore - to the generated field or method name. -- Adding, removing, or changing methods or fields in generated structs that - start with `XXX`. These parts of the generated code are exported out of - necessity, but should not be considered part of the public API. -- Adding, removing, or changing unexported symbols in generated code. - -Any breaking changes outside of these will be announced 6 months in advance to -protobuf@googlegroups.com. - -You should, whenever possible, use generated code created by the `protoc-gen-go` -tool built at the same commit as the `proto` package. The `proto` package -declares package-level constants in the form `ProtoPackageIsVersionX`. -Application code and generated code may depend on one of these constants to -ensure that compilation will fail if the available version of the proto library -is too old. Whenever we make a change to the generated code that requires newer -library support, in the same commit we will increment the version number of the -generated code and declare a new package-level constant whose name incorporates -the latest version number. Removing a compatibility constant is considered a -breaking change and would be subject to the announcement policy stated above. - -The `protoc-gen-go/generator` package exposes a plugin interface, -which is used by the gRPC code generation. This interface is not -supported and is subject to incompatible changes without notice. diff --git a/vendor/github.com/golang/protobuf/proto/all_test.go b/vendor/github.com/golang/protobuf/proto/all_test.go deleted file mode 100644 index 1bea4b6e..00000000 --- a/vendor/github.com/golang/protobuf/proto/all_test.go +++ /dev/null @@ -1,2492 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2010 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package proto_test - -import ( - "bytes" - "encoding/json" - "errors" - "fmt" - "math" - "math/rand" - "reflect" - "runtime/debug" - "strings" - "sync" - "testing" - "time" - - . "github.com/golang/protobuf/proto" - pb3 "github.com/golang/protobuf/proto/proto3_proto" - . "github.com/golang/protobuf/proto/test_proto" -) - -var globalO *Buffer - -func old() *Buffer { - if globalO == nil { - globalO = NewBuffer(nil) - } - globalO.Reset() - return globalO -} - -func equalbytes(b1, b2 []byte, t *testing.T) { - if len(b1) != len(b2) { - t.Errorf("wrong lengths: 2*%d != %d", len(b1), len(b2)) - return - } - for i := 0; i < len(b1); i++ { - if b1[i] != b2[i] { - t.Errorf("bad byte[%d]:%x %x: %s %s", i, b1[i], b2[i], b1, b2) - } - } -} - -func initGoTestField() *GoTestField { - f := new(GoTestField) - f.Label = String("label") - f.Type = String("type") - return f -} - -// These are all structurally equivalent but the tag numbers differ. -// (It's remarkable that required, optional, and repeated all have -// 8 letters.) -func initGoTest_RequiredGroup() *GoTest_RequiredGroup { - return &GoTest_RequiredGroup{ - RequiredField: String("required"), - } -} - -func initGoTest_OptionalGroup() *GoTest_OptionalGroup { - return &GoTest_OptionalGroup{ - RequiredField: String("optional"), - } -} - -func initGoTest_RepeatedGroup() *GoTest_RepeatedGroup { - return &GoTest_RepeatedGroup{ - RequiredField: String("repeated"), - } -} - -func initGoTest(setdefaults bool) *GoTest { - pb := new(GoTest) - if setdefaults { - pb.F_BoolDefaulted = Bool(Default_GoTest_F_BoolDefaulted) - pb.F_Int32Defaulted = Int32(Default_GoTest_F_Int32Defaulted) - pb.F_Int64Defaulted = Int64(Default_GoTest_F_Int64Defaulted) - pb.F_Fixed32Defaulted = Uint32(Default_GoTest_F_Fixed32Defaulted) - pb.F_Fixed64Defaulted = Uint64(Default_GoTest_F_Fixed64Defaulted) - pb.F_Uint32Defaulted = Uint32(Default_GoTest_F_Uint32Defaulted) - pb.F_Uint64Defaulted = Uint64(Default_GoTest_F_Uint64Defaulted) - pb.F_FloatDefaulted = Float32(Default_GoTest_F_FloatDefaulted) - pb.F_DoubleDefaulted = Float64(Default_GoTest_F_DoubleDefaulted) - pb.F_StringDefaulted = String(Default_GoTest_F_StringDefaulted) - pb.F_BytesDefaulted = Default_GoTest_F_BytesDefaulted - pb.F_Sint32Defaulted = Int32(Default_GoTest_F_Sint32Defaulted) - pb.F_Sint64Defaulted = Int64(Default_GoTest_F_Sint64Defaulted) - pb.F_Sfixed32Defaulted = Int32(Default_GoTest_F_Sfixed32Defaulted) - pb.F_Sfixed64Defaulted = Int64(Default_GoTest_F_Sfixed64Defaulted) - } - - pb.Kind = GoTest_TIME.Enum() - pb.RequiredField = initGoTestField() - pb.F_BoolRequired = Bool(true) - pb.F_Int32Required = Int32(3) - pb.F_Int64Required = Int64(6) - pb.F_Fixed32Required = Uint32(32) - pb.F_Fixed64Required = Uint64(64) - pb.F_Uint32Required = Uint32(3232) - pb.F_Uint64Required = Uint64(6464) - pb.F_FloatRequired = Float32(3232) - pb.F_DoubleRequired = Float64(6464) - pb.F_StringRequired = String("string") - pb.F_BytesRequired = []byte("bytes") - pb.F_Sint32Required = Int32(-32) - pb.F_Sint64Required = Int64(-64) - pb.F_Sfixed32Required = Int32(-32) - pb.F_Sfixed64Required = Int64(-64) - pb.Requiredgroup = initGoTest_RequiredGroup() - - return pb -} - -func hex(c uint8) uint8 { - if '0' <= c && c <= '9' { - return c - '0' - } - if 'a' <= c && c <= 'f' { - return 10 + c - 'a' - } - if 'A' <= c && c <= 'F' { - return 10 + c - 'A' - } - return 0 -} - -func equal(b []byte, s string, t *testing.T) bool { - if 2*len(b) != len(s) { - // fail(fmt.Sprintf("wrong lengths: 2*%d != %d", len(b), len(s)), b, s, t) - fmt.Printf("wrong lengths: 2*%d != %d\n", len(b), len(s)) - return false - } - for i, j := 0, 0; i < len(b); i, j = i+1, j+2 { - x := hex(s[j])*16 + hex(s[j+1]) - if b[i] != x { - // fail(fmt.Sprintf("bad byte[%d]:%x %x", i, b[i], x), b, s, t) - fmt.Printf("bad byte[%d]:%x %x", i, b[i], x) - return false - } - } - return true -} - -func overify(t *testing.T, pb *GoTest, expected string) { - o := old() - err := o.Marshal(pb) - if err != nil { - fmt.Printf("overify marshal-1 err = %v", err) - o.DebugPrint("", o.Bytes()) - t.Fatalf("expected = %s", expected) - } - if !equal(o.Bytes(), expected, t) { - o.DebugPrint("overify neq 1", o.Bytes()) - t.Fatalf("expected = %s", expected) - } - - // Now test Unmarshal by recreating the original buffer. - pbd := new(GoTest) - err = o.Unmarshal(pbd) - if err != nil { - t.Fatalf("overify unmarshal err = %v", err) - o.DebugPrint("", o.Bytes()) - t.Fatalf("string = %s", expected) - } - o.Reset() - err = o.Marshal(pbd) - if err != nil { - t.Errorf("overify marshal-2 err = %v", err) - o.DebugPrint("", o.Bytes()) - t.Fatalf("string = %s", expected) - } - if !equal(o.Bytes(), expected, t) { - o.DebugPrint("overify neq 2", o.Bytes()) - t.Fatalf("string = %s", expected) - } -} - -// Simple tests for numeric encode/decode primitives (varint, etc.) -func TestNumericPrimitives(t *testing.T) { - for i := uint64(0); i < 1e6; i += 111 { - o := old() - if o.EncodeVarint(i) != nil { - t.Error("EncodeVarint") - break - } - x, e := o.DecodeVarint() - if e != nil { - t.Fatal("DecodeVarint") - } - if x != i { - t.Fatal("varint decode fail:", i, x) - } - - o = old() - if o.EncodeFixed32(i) != nil { - t.Fatal("encFixed32") - } - x, e = o.DecodeFixed32() - if e != nil { - t.Fatal("decFixed32") - } - if x != i { - t.Fatal("fixed32 decode fail:", i, x) - } - - o = old() - if o.EncodeFixed64(i*1234567) != nil { - t.Error("encFixed64") - break - } - x, e = o.DecodeFixed64() - if e != nil { - t.Error("decFixed64") - break - } - if x != i*1234567 { - t.Error("fixed64 decode fail:", i*1234567, x) - break - } - - o = old() - i32 := int32(i - 12345) - if o.EncodeZigzag32(uint64(i32)) != nil { - t.Fatal("EncodeZigzag32") - } - x, e = o.DecodeZigzag32() - if e != nil { - t.Fatal("DecodeZigzag32") - } - if x != uint64(uint32(i32)) { - t.Fatal("zigzag32 decode fail:", i32, x) - } - - o = old() - i64 := int64(i - 12345) - if o.EncodeZigzag64(uint64(i64)) != nil { - t.Fatal("EncodeZigzag64") - } - x, e = o.DecodeZigzag64() - if e != nil { - t.Fatal("DecodeZigzag64") - } - if x != uint64(i64) { - t.Fatal("zigzag64 decode fail:", i64, x) - } - } -} - -// fakeMarshaler is a simple struct implementing Marshaler and Message interfaces. -type fakeMarshaler struct { - b []byte - err error -} - -func (f *fakeMarshaler) Marshal() ([]byte, error) { return f.b, f.err } -func (f *fakeMarshaler) String() string { return fmt.Sprintf("Bytes: %v Error: %v", f.b, f.err) } -func (f *fakeMarshaler) ProtoMessage() {} -func (f *fakeMarshaler) Reset() {} - -type msgWithFakeMarshaler struct { - M *fakeMarshaler `protobuf:"bytes,1,opt,name=fake"` -} - -func (m *msgWithFakeMarshaler) String() string { return CompactTextString(m) } -func (m *msgWithFakeMarshaler) ProtoMessage() {} -func (m *msgWithFakeMarshaler) Reset() {} - -// Simple tests for proto messages that implement the Marshaler interface. -func TestMarshalerEncoding(t *testing.T) { - tests := []struct { - name string - m Message - want []byte - errType reflect.Type - }{ - { - name: "Marshaler that fails", - m: &fakeMarshaler{ - err: errors.New("some marshal err"), - b: []byte{5, 6, 7}, - }, - // Since the Marshal method returned bytes, they should be written to the - // buffer. (For efficiency, we assume that Marshal implementations are - // always correct w.r.t. RequiredNotSetError and output.) - want: []byte{5, 6, 7}, - errType: reflect.TypeOf(errors.New("some marshal err")), - }, - { - name: "Marshaler that fails with RequiredNotSetError", - m: &msgWithFakeMarshaler{ - M: &fakeMarshaler{ - err: &RequiredNotSetError{}, - b: []byte{5, 6, 7}, - }, - }, - // Since there's an error that can be continued after, - // the buffer should be written. - want: []byte{ - 10, 3, // for &msgWithFakeMarshaler - 5, 6, 7, // for &fakeMarshaler - }, - errType: reflect.TypeOf(&RequiredNotSetError{}), - }, - { - name: "Marshaler that succeeds", - m: &fakeMarshaler{ - b: []byte{0, 1, 2, 3, 4, 127, 255}, - }, - want: []byte{0, 1, 2, 3, 4, 127, 255}, - }, - } - for _, test := range tests { - b := NewBuffer(nil) - err := b.Marshal(test.m) - if reflect.TypeOf(err) != test.errType { - t.Errorf("%s: got err %T(%v) wanted %T", test.name, err, err, test.errType) - } - if !reflect.DeepEqual(test.want, b.Bytes()) { - t.Errorf("%s: got bytes %v wanted %v", test.name, b.Bytes(), test.want) - } - if size := Size(test.m); size != len(b.Bytes()) { - t.Errorf("%s: Size(_) = %v, but marshaled to %v bytes", test.name, size, len(b.Bytes())) - } - - m, mErr := Marshal(test.m) - if !bytes.Equal(b.Bytes(), m) { - t.Errorf("%s: Marshal returned %v, but (*Buffer).Marshal wrote %v", test.name, m, b.Bytes()) - } - if !reflect.DeepEqual(err, mErr) { - t.Errorf("%s: Marshal err = %q, but (*Buffer).Marshal returned %q", - test.name, fmt.Sprint(mErr), fmt.Sprint(err)) - } - } -} - -// Ensure that Buffer.Marshal uses O(N) memory for N messages -func TestBufferMarshalAllocs(t *testing.T) { - value := &OtherMessage{Key: Int64(1)} - msg := &MyMessage{Count: Int32(1), Others: []*OtherMessage{value}} - - reallocSize := func(t *testing.T, items int, prealloc int) (int64, int64) { - var b Buffer - b.SetBuf(make([]byte, 0, prealloc)) - - var allocSpace int64 - prevCap := cap(b.Bytes()) - for i := 0; i < items; i++ { - err := b.Marshal(msg) - if err != nil { - t.Errorf("Marshal err = %q", err) - break - } - if c := cap(b.Bytes()); prevCap != c { - allocSpace += int64(c) - prevCap = c - } - } - needSpace := int64(len(b.Bytes())) - return allocSpace, needSpace - } - - for _, prealloc := range []int{0, 100, 10000} { - for _, items := range []int{1, 2, 5, 10, 20, 50, 100, 200, 500, 1000} { - runtimeSpace, need := reallocSize(t, items, prealloc) - totalSpace := int64(prealloc) + runtimeSpace - - runtimeRatio := float64(runtimeSpace) / float64(need) - totalRatio := float64(totalSpace) / float64(need) - - if totalRatio < 1 || runtimeRatio > 4 { - t.Errorf("needed %dB, allocated %dB total (ratio %.1f), allocated %dB at runtime (ratio %.1f)", - need, totalSpace, totalRatio, runtimeSpace, runtimeRatio) - } - } - } -} - -// Simple tests for bytes -func TestBytesPrimitives(t *testing.T) { - o := old() - bytes := []byte{'n', 'o', 'w', ' ', 'i', 's', ' ', 't', 'h', 'e', ' ', 't', 'i', 'm', 'e'} - if o.EncodeRawBytes(bytes) != nil { - t.Error("EncodeRawBytes") - } - decb, e := o.DecodeRawBytes(false) - if e != nil { - t.Error("DecodeRawBytes") - } - equalbytes(bytes, decb, t) -} - -// Simple tests for strings -func TestStringPrimitives(t *testing.T) { - o := old() - s := "now is the time" - if o.EncodeStringBytes(s) != nil { - t.Error("enc_string") - } - decs, e := o.DecodeStringBytes() - if e != nil { - t.Error("dec_string") - } - if s != decs { - t.Error("string encode/decode fail:", s, decs) - } -} - -// Do we catch the "required bit not set" case? -func TestRequiredBit(t *testing.T) { - o := old() - pb := new(GoTest) - err := o.Marshal(pb) - if err == nil { - t.Error("did not catch missing required fields") - } else if !strings.Contains(err.Error(), "Kind") { - t.Error("wrong error type:", err) - } -} - -// Check that all fields are nil. -// Clearly silly, and a residue from a more interesting test with an earlier, -// different initialization property, but it once caught a compiler bug so -// it lives. -func checkInitialized(pb *GoTest, t *testing.T) { - if pb.F_BoolDefaulted != nil { - t.Error("New or Reset did not set boolean:", *pb.F_BoolDefaulted) - } - if pb.F_Int32Defaulted != nil { - t.Error("New or Reset did not set int32:", *pb.F_Int32Defaulted) - } - if pb.F_Int64Defaulted != nil { - t.Error("New or Reset did not set int64:", *pb.F_Int64Defaulted) - } - if pb.F_Fixed32Defaulted != nil { - t.Error("New or Reset did not set fixed32:", *pb.F_Fixed32Defaulted) - } - if pb.F_Fixed64Defaulted != nil { - t.Error("New or Reset did not set fixed64:", *pb.F_Fixed64Defaulted) - } - if pb.F_Uint32Defaulted != nil { - t.Error("New or Reset did not set uint32:", *pb.F_Uint32Defaulted) - } - if pb.F_Uint64Defaulted != nil { - t.Error("New or Reset did not set uint64:", *pb.F_Uint64Defaulted) - } - if pb.F_FloatDefaulted != nil { - t.Error("New or Reset did not set float:", *pb.F_FloatDefaulted) - } - if pb.F_DoubleDefaulted != nil { - t.Error("New or Reset did not set double:", *pb.F_DoubleDefaulted) - } - if pb.F_StringDefaulted != nil { - t.Error("New or Reset did not set string:", *pb.F_StringDefaulted) - } - if pb.F_BytesDefaulted != nil { - t.Error("New or Reset did not set bytes:", string(pb.F_BytesDefaulted)) - } - if pb.F_Sint32Defaulted != nil { - t.Error("New or Reset did not set int32:", *pb.F_Sint32Defaulted) - } - if pb.F_Sint64Defaulted != nil { - t.Error("New or Reset did not set int64:", *pb.F_Sint64Defaulted) - } -} - -// Does Reset() reset? -func TestReset(t *testing.T) { - pb := initGoTest(true) - // muck with some values - pb.F_BoolDefaulted = Bool(false) - pb.F_Int32Defaulted = Int32(237) - pb.F_Int64Defaulted = Int64(12346) - pb.F_Fixed32Defaulted = Uint32(32000) - pb.F_Fixed64Defaulted = Uint64(666) - pb.F_Uint32Defaulted = Uint32(323232) - pb.F_Uint64Defaulted = nil - pb.F_FloatDefaulted = nil - pb.F_DoubleDefaulted = Float64(0) - pb.F_StringDefaulted = String("gotcha") - pb.F_BytesDefaulted = []byte("asdfasdf") - pb.F_Sint32Defaulted = Int32(123) - pb.F_Sint64Defaulted = Int64(789) - pb.Reset() - checkInitialized(pb, t) -} - -// All required fields set, no defaults provided. -func TestEncodeDecode1(t *testing.T) { - pb := initGoTest(false) - overify(t, pb, - "0807"+ // field 1, encoding 0, value 7 - "220d"+"0a056c6162656c120474797065"+ // field 4, encoding 2 (GoTestField) - "5001"+ // field 10, encoding 0, value 1 - "5803"+ // field 11, encoding 0, value 3 - "6006"+ // field 12, encoding 0, value 6 - "6d20000000"+ // field 13, encoding 5, value 0x20 - "714000000000000000"+ // field 14, encoding 1, value 0x40 - "78a019"+ // field 15, encoding 0, value 0xca0 = 3232 - "8001c032"+ // field 16, encoding 0, value 0x1940 = 6464 - "8d0100004a45"+ // field 17, encoding 5, value 3232.0 - "9101000000000040b940"+ // field 18, encoding 1, value 6464.0 - "9a0106"+"737472696e67"+ // field 19, encoding 2, string "string" - "b304"+ // field 70, encoding 3, start group - "ba0408"+"7265717569726564"+ // field 71, encoding 2, string "required" - "b404"+ // field 70, encoding 4, end group - "aa0605"+"6279746573"+ // field 101, encoding 2, string "bytes" - "b0063f"+ // field 102, encoding 0, 0x3f zigzag32 - "b8067f"+ // field 103, encoding 0, 0x7f zigzag64 - "c506e0ffffff"+ // field 104, encoding 5, -32 fixed32 - "c906c0ffffffffffffff") // field 105, encoding 1, -64 fixed64 -} - -// All required fields set, defaults provided. -func TestEncodeDecode2(t *testing.T) { - pb := initGoTest(true) - overify(t, pb, - "0807"+ // field 1, encoding 0, value 7 - "220d"+"0a056c6162656c120474797065"+ // field 4, encoding 2 (GoTestField) - "5001"+ // field 10, encoding 0, value 1 - "5803"+ // field 11, encoding 0, value 3 - "6006"+ // field 12, encoding 0, value 6 - "6d20000000"+ // field 13, encoding 5, value 32 - "714000000000000000"+ // field 14, encoding 1, value 64 - "78a019"+ // field 15, encoding 0, value 3232 - "8001c032"+ // field 16, encoding 0, value 6464 - "8d0100004a45"+ // field 17, encoding 5, value 3232.0 - "9101000000000040b940"+ // field 18, encoding 1, value 6464.0 - "9a0106"+"737472696e67"+ // field 19, encoding 2 string "string" - "c00201"+ // field 40, encoding 0, value 1 - "c80220"+ // field 41, encoding 0, value 32 - "d00240"+ // field 42, encoding 0, value 64 - "dd0240010000"+ // field 43, encoding 5, value 320 - "e1028002000000000000"+ // field 44, encoding 1, value 640 - "e8028019"+ // field 45, encoding 0, value 3200 - "f0028032"+ // field 46, encoding 0, value 6400 - "fd02e0659948"+ // field 47, encoding 5, value 314159.0 - "81030000000050971041"+ // field 48, encoding 1, value 271828.0 - "8a0310"+"68656c6c6f2c2022776f726c6421220a"+ // field 49, encoding 2 string "hello, \"world!\"\n" - "b304"+ // start group field 70 level 1 - "ba0408"+"7265717569726564"+ // field 71, encoding 2, string "required" - "b404"+ // end group field 70 level 1 - "aa0605"+"6279746573"+ // field 101, encoding 2 string "bytes" - "b0063f"+ // field 102, encoding 0, 0x3f zigzag32 - "b8067f"+ // field 103, encoding 0, 0x7f zigzag64 - "c506e0ffffff"+ // field 104, encoding 5, -32 fixed32 - "c906c0ffffffffffffff"+ // field 105, encoding 1, -64 fixed64 - "8a1907"+"4269676e6f7365"+ // field 401, encoding 2, string "Bignose" - "90193f"+ // field 402, encoding 0, value 63 - "98197f"+ // field 403, encoding 0, value 127 - "a519e0ffffff"+ // field 404, encoding 5, -32 fixed32 - "a919c0ffffffffffffff") // field 405, encoding 1, -64 fixed64 - -} - -// All default fields set to their default value by hand -func TestEncodeDecode3(t *testing.T) { - pb := initGoTest(false) - pb.F_BoolDefaulted = Bool(true) - pb.F_Int32Defaulted = Int32(32) - pb.F_Int64Defaulted = Int64(64) - pb.F_Fixed32Defaulted = Uint32(320) - pb.F_Fixed64Defaulted = Uint64(640) - pb.F_Uint32Defaulted = Uint32(3200) - pb.F_Uint64Defaulted = Uint64(6400) - pb.F_FloatDefaulted = Float32(314159) - pb.F_DoubleDefaulted = Float64(271828) - pb.F_StringDefaulted = String("hello, \"world!\"\n") - pb.F_BytesDefaulted = []byte("Bignose") - pb.F_Sint32Defaulted = Int32(-32) - pb.F_Sint64Defaulted = Int64(-64) - pb.F_Sfixed32Defaulted = Int32(-32) - pb.F_Sfixed64Defaulted = Int64(-64) - - overify(t, pb, - "0807"+ // field 1, encoding 0, value 7 - "220d"+"0a056c6162656c120474797065"+ // field 4, encoding 2 (GoTestField) - "5001"+ // field 10, encoding 0, value 1 - "5803"+ // field 11, encoding 0, value 3 - "6006"+ // field 12, encoding 0, value 6 - "6d20000000"+ // field 13, encoding 5, value 32 - "714000000000000000"+ // field 14, encoding 1, value 64 - "78a019"+ // field 15, encoding 0, value 3232 - "8001c032"+ // field 16, encoding 0, value 6464 - "8d0100004a45"+ // field 17, encoding 5, value 3232.0 - "9101000000000040b940"+ // field 18, encoding 1, value 6464.0 - "9a0106"+"737472696e67"+ // field 19, encoding 2 string "string" - "c00201"+ // field 40, encoding 0, value 1 - "c80220"+ // field 41, encoding 0, value 32 - "d00240"+ // field 42, encoding 0, value 64 - "dd0240010000"+ // field 43, encoding 5, value 320 - "e1028002000000000000"+ // field 44, encoding 1, value 640 - "e8028019"+ // field 45, encoding 0, value 3200 - "f0028032"+ // field 46, encoding 0, value 6400 - "fd02e0659948"+ // field 47, encoding 5, value 314159.0 - "81030000000050971041"+ // field 48, encoding 1, value 271828.0 - "8a0310"+"68656c6c6f2c2022776f726c6421220a"+ // field 49, encoding 2 string "hello, \"world!\"\n" - "b304"+ // start group field 70 level 1 - "ba0408"+"7265717569726564"+ // field 71, encoding 2, string "required" - "b404"+ // end group field 70 level 1 - "aa0605"+"6279746573"+ // field 101, encoding 2 string "bytes" - "b0063f"+ // field 102, encoding 0, 0x3f zigzag32 - "b8067f"+ // field 103, encoding 0, 0x7f zigzag64 - "c506e0ffffff"+ // field 104, encoding 5, -32 fixed32 - "c906c0ffffffffffffff"+ // field 105, encoding 1, -64 fixed64 - "8a1907"+"4269676e6f7365"+ // field 401, encoding 2, string "Bignose" - "90193f"+ // field 402, encoding 0, value 63 - "98197f"+ // field 403, encoding 0, value 127 - "a519e0ffffff"+ // field 404, encoding 5, -32 fixed32 - "a919c0ffffffffffffff") // field 405, encoding 1, -64 fixed64 - -} - -// All required fields set, defaults provided, all non-defaulted optional fields have values. -func TestEncodeDecode4(t *testing.T) { - pb := initGoTest(true) - pb.Table = String("hello") - pb.Param = Int32(7) - pb.OptionalField = initGoTestField() - pb.F_BoolOptional = Bool(true) - pb.F_Int32Optional = Int32(32) - pb.F_Int64Optional = Int64(64) - pb.F_Fixed32Optional = Uint32(3232) - pb.F_Fixed64Optional = Uint64(6464) - pb.F_Uint32Optional = Uint32(323232) - pb.F_Uint64Optional = Uint64(646464) - pb.F_FloatOptional = Float32(32.) - pb.F_DoubleOptional = Float64(64.) - pb.F_StringOptional = String("hello") - pb.F_BytesOptional = []byte("Bignose") - pb.F_Sint32Optional = Int32(-32) - pb.F_Sint64Optional = Int64(-64) - pb.F_Sfixed32Optional = Int32(-32) - pb.F_Sfixed64Optional = Int64(-64) - pb.Optionalgroup = initGoTest_OptionalGroup() - - overify(t, pb, - "0807"+ // field 1, encoding 0, value 7 - "1205"+"68656c6c6f"+ // field 2, encoding 2, string "hello" - "1807"+ // field 3, encoding 0, value 7 - "220d"+"0a056c6162656c120474797065"+ // field 4, encoding 2 (GoTestField) - "320d"+"0a056c6162656c120474797065"+ // field 6, encoding 2 (GoTestField) - "5001"+ // field 10, encoding 0, value 1 - "5803"+ // field 11, encoding 0, value 3 - "6006"+ // field 12, encoding 0, value 6 - "6d20000000"+ // field 13, encoding 5, value 32 - "714000000000000000"+ // field 14, encoding 1, value 64 - "78a019"+ // field 15, encoding 0, value 3232 - "8001c032"+ // field 16, encoding 0, value 6464 - "8d0100004a45"+ // field 17, encoding 5, value 3232.0 - "9101000000000040b940"+ // field 18, encoding 1, value 6464.0 - "9a0106"+"737472696e67"+ // field 19, encoding 2 string "string" - "f00101"+ // field 30, encoding 0, value 1 - "f80120"+ // field 31, encoding 0, value 32 - "800240"+ // field 32, encoding 0, value 64 - "8d02a00c0000"+ // field 33, encoding 5, value 3232 - "91024019000000000000"+ // field 34, encoding 1, value 6464 - "9802a0dd13"+ // field 35, encoding 0, value 323232 - "a002c0ba27"+ // field 36, encoding 0, value 646464 - "ad0200000042"+ // field 37, encoding 5, value 32.0 - "b1020000000000005040"+ // field 38, encoding 1, value 64.0 - "ba0205"+"68656c6c6f"+ // field 39, encoding 2, string "hello" - "c00201"+ // field 40, encoding 0, value 1 - "c80220"+ // field 41, encoding 0, value 32 - "d00240"+ // field 42, encoding 0, value 64 - "dd0240010000"+ // field 43, encoding 5, value 320 - "e1028002000000000000"+ // field 44, encoding 1, value 640 - "e8028019"+ // field 45, encoding 0, value 3200 - "f0028032"+ // field 46, encoding 0, value 6400 - "fd02e0659948"+ // field 47, encoding 5, value 314159.0 - "81030000000050971041"+ // field 48, encoding 1, value 271828.0 - "8a0310"+"68656c6c6f2c2022776f726c6421220a"+ // field 49, encoding 2 string "hello, \"world!\"\n" - "b304"+ // start group field 70 level 1 - "ba0408"+"7265717569726564"+ // field 71, encoding 2, string "required" - "b404"+ // end group field 70 level 1 - "d305"+ // start group field 90 level 1 - "da0508"+"6f7074696f6e616c"+ // field 91, encoding 2, string "optional" - "d405"+ // end group field 90 level 1 - "aa0605"+"6279746573"+ // field 101, encoding 2 string "bytes" - "b0063f"+ // field 102, encoding 0, 0x3f zigzag32 - "b8067f"+ // field 103, encoding 0, 0x7f zigzag64 - "c506e0ffffff"+ // field 104, encoding 5, -32 fixed32 - "c906c0ffffffffffffff"+ // field 105, encoding 1, -64 fixed64 - "ea1207"+"4269676e6f7365"+ // field 301, encoding 2, string "Bignose" - "f0123f"+ // field 302, encoding 0, value 63 - "f8127f"+ // field 303, encoding 0, value 127 - "8513e0ffffff"+ // field 304, encoding 5, -32 fixed32 - "8913c0ffffffffffffff"+ // field 305, encoding 1, -64 fixed64 - "8a1907"+"4269676e6f7365"+ // field 401, encoding 2, string "Bignose" - "90193f"+ // field 402, encoding 0, value 63 - "98197f"+ // field 403, encoding 0, value 127 - "a519e0ffffff"+ // field 404, encoding 5, -32 fixed32 - "a919c0ffffffffffffff") // field 405, encoding 1, -64 fixed64 - -} - -// All required fields set, defaults provided, all repeated fields given two values. -func TestEncodeDecode5(t *testing.T) { - pb := initGoTest(true) - pb.RepeatedField = []*GoTestField{initGoTestField(), initGoTestField()} - pb.F_BoolRepeated = []bool{false, true} - pb.F_Int32Repeated = []int32{32, 33} - pb.F_Int64Repeated = []int64{64, 65} - pb.F_Fixed32Repeated = []uint32{3232, 3333} - pb.F_Fixed64Repeated = []uint64{6464, 6565} - pb.F_Uint32Repeated = []uint32{323232, 333333} - pb.F_Uint64Repeated = []uint64{646464, 656565} - pb.F_FloatRepeated = []float32{32., 33.} - pb.F_DoubleRepeated = []float64{64., 65.} - pb.F_StringRepeated = []string{"hello", "sailor"} - pb.F_BytesRepeated = [][]byte{[]byte("big"), []byte("nose")} - pb.F_Sint32Repeated = []int32{32, -32} - pb.F_Sint64Repeated = []int64{64, -64} - pb.F_Sfixed32Repeated = []int32{32, -32} - pb.F_Sfixed64Repeated = []int64{64, -64} - pb.Repeatedgroup = []*GoTest_RepeatedGroup{initGoTest_RepeatedGroup(), initGoTest_RepeatedGroup()} - - overify(t, pb, - "0807"+ // field 1, encoding 0, value 7 - "220d"+"0a056c6162656c120474797065"+ // field 4, encoding 2 (GoTestField) - "2a0d"+"0a056c6162656c120474797065"+ // field 5, encoding 2 (GoTestField) - "2a0d"+"0a056c6162656c120474797065"+ // field 5, encoding 2 (GoTestField) - "5001"+ // field 10, encoding 0, value 1 - "5803"+ // field 11, encoding 0, value 3 - "6006"+ // field 12, encoding 0, value 6 - "6d20000000"+ // field 13, encoding 5, value 32 - "714000000000000000"+ // field 14, encoding 1, value 64 - "78a019"+ // field 15, encoding 0, value 3232 - "8001c032"+ // field 16, encoding 0, value 6464 - "8d0100004a45"+ // field 17, encoding 5, value 3232.0 - "9101000000000040b940"+ // field 18, encoding 1, value 6464.0 - "9a0106"+"737472696e67"+ // field 19, encoding 2 string "string" - "a00100"+ // field 20, encoding 0, value 0 - "a00101"+ // field 20, encoding 0, value 1 - "a80120"+ // field 21, encoding 0, value 32 - "a80121"+ // field 21, encoding 0, value 33 - "b00140"+ // field 22, encoding 0, value 64 - "b00141"+ // field 22, encoding 0, value 65 - "bd01a00c0000"+ // field 23, encoding 5, value 3232 - "bd01050d0000"+ // field 23, encoding 5, value 3333 - "c1014019000000000000"+ // field 24, encoding 1, value 6464 - "c101a519000000000000"+ // field 24, encoding 1, value 6565 - "c801a0dd13"+ // field 25, encoding 0, value 323232 - "c80195ac14"+ // field 25, encoding 0, value 333333 - "d001c0ba27"+ // field 26, encoding 0, value 646464 - "d001b58928"+ // field 26, encoding 0, value 656565 - "dd0100000042"+ // field 27, encoding 5, value 32.0 - "dd0100000442"+ // field 27, encoding 5, value 33.0 - "e1010000000000005040"+ // field 28, encoding 1, value 64.0 - "e1010000000000405040"+ // field 28, encoding 1, value 65.0 - "ea0105"+"68656c6c6f"+ // field 29, encoding 2, string "hello" - "ea0106"+"7361696c6f72"+ // field 29, encoding 2, string "sailor" - "c00201"+ // field 40, encoding 0, value 1 - "c80220"+ // field 41, encoding 0, value 32 - "d00240"+ // field 42, encoding 0, value 64 - "dd0240010000"+ // field 43, encoding 5, value 320 - "e1028002000000000000"+ // field 44, encoding 1, value 640 - "e8028019"+ // field 45, encoding 0, value 3200 - "f0028032"+ // field 46, encoding 0, value 6400 - "fd02e0659948"+ // field 47, encoding 5, value 314159.0 - "81030000000050971041"+ // field 48, encoding 1, value 271828.0 - "8a0310"+"68656c6c6f2c2022776f726c6421220a"+ // field 49, encoding 2 string "hello, \"world!\"\n" - "b304"+ // start group field 70 level 1 - "ba0408"+"7265717569726564"+ // field 71, encoding 2, string "required" - "b404"+ // end group field 70 level 1 - "8305"+ // start group field 80 level 1 - "8a0508"+"7265706561746564"+ // field 81, encoding 2, string "repeated" - "8405"+ // end group field 80 level 1 - "8305"+ // start group field 80 level 1 - "8a0508"+"7265706561746564"+ // field 81, encoding 2, string "repeated" - "8405"+ // end group field 80 level 1 - "aa0605"+"6279746573"+ // field 101, encoding 2 string "bytes" - "b0063f"+ // field 102, encoding 0, 0x3f zigzag32 - "b8067f"+ // field 103, encoding 0, 0x7f zigzag64 - "c506e0ffffff"+ // field 104, encoding 5, -32 fixed32 - "c906c0ffffffffffffff"+ // field 105, encoding 1, -64 fixed64 - "ca0c03"+"626967"+ // field 201, encoding 2, string "big" - "ca0c04"+"6e6f7365"+ // field 201, encoding 2, string "nose" - "d00c40"+ // field 202, encoding 0, value 32 - "d00c3f"+ // field 202, encoding 0, value -32 - "d80c8001"+ // field 203, encoding 0, value 64 - "d80c7f"+ // field 203, encoding 0, value -64 - "e50c20000000"+ // field 204, encoding 5, 32 fixed32 - "e50ce0ffffff"+ // field 204, encoding 5, -32 fixed32 - "e90c4000000000000000"+ // field 205, encoding 1, 64 fixed64 - "e90cc0ffffffffffffff"+ // field 205, encoding 1, -64 fixed64 - "8a1907"+"4269676e6f7365"+ // field 401, encoding 2, string "Bignose" - "90193f"+ // field 402, encoding 0, value 63 - "98197f"+ // field 403, encoding 0, value 127 - "a519e0ffffff"+ // field 404, encoding 5, -32 fixed32 - "a919c0ffffffffffffff") // field 405, encoding 1, -64 fixed64 - -} - -// All required fields set, all packed repeated fields given two values. -func TestEncodeDecode6(t *testing.T) { - pb := initGoTest(false) - pb.F_BoolRepeatedPacked = []bool{false, true} - pb.F_Int32RepeatedPacked = []int32{32, 33} - pb.F_Int64RepeatedPacked = []int64{64, 65} - pb.F_Fixed32RepeatedPacked = []uint32{3232, 3333} - pb.F_Fixed64RepeatedPacked = []uint64{6464, 6565} - pb.F_Uint32RepeatedPacked = []uint32{323232, 333333} - pb.F_Uint64RepeatedPacked = []uint64{646464, 656565} - pb.F_FloatRepeatedPacked = []float32{32., 33.} - pb.F_DoubleRepeatedPacked = []float64{64., 65.} - pb.F_Sint32RepeatedPacked = []int32{32, -32} - pb.F_Sint64RepeatedPacked = []int64{64, -64} - pb.F_Sfixed32RepeatedPacked = []int32{32, -32} - pb.F_Sfixed64RepeatedPacked = []int64{64, -64} - - overify(t, pb, - "0807"+ // field 1, encoding 0, value 7 - "220d"+"0a056c6162656c120474797065"+ // field 4, encoding 2 (GoTestField) - "5001"+ // field 10, encoding 0, value 1 - "5803"+ // field 11, encoding 0, value 3 - "6006"+ // field 12, encoding 0, value 6 - "6d20000000"+ // field 13, encoding 5, value 32 - "714000000000000000"+ // field 14, encoding 1, value 64 - "78a019"+ // field 15, encoding 0, value 3232 - "8001c032"+ // field 16, encoding 0, value 6464 - "8d0100004a45"+ // field 17, encoding 5, value 3232.0 - "9101000000000040b940"+ // field 18, encoding 1, value 6464.0 - "9a0106"+"737472696e67"+ // field 19, encoding 2 string "string" - "9203020001"+ // field 50, encoding 2, 2 bytes, value 0, value 1 - "9a03022021"+ // field 51, encoding 2, 2 bytes, value 32, value 33 - "a203024041"+ // field 52, encoding 2, 2 bytes, value 64, value 65 - "aa0308"+ // field 53, encoding 2, 8 bytes - "a00c0000050d0000"+ // value 3232, value 3333 - "b20310"+ // field 54, encoding 2, 16 bytes - "4019000000000000a519000000000000"+ // value 6464, value 6565 - "ba0306"+ // field 55, encoding 2, 6 bytes - "a0dd1395ac14"+ // value 323232, value 333333 - "c20306"+ // field 56, encoding 2, 6 bytes - "c0ba27b58928"+ // value 646464, value 656565 - "ca0308"+ // field 57, encoding 2, 8 bytes - "0000004200000442"+ // value 32.0, value 33.0 - "d20310"+ // field 58, encoding 2, 16 bytes - "00000000000050400000000000405040"+ // value 64.0, value 65.0 - "b304"+ // start group field 70 level 1 - "ba0408"+"7265717569726564"+ // field 71, encoding 2, string "required" - "b404"+ // end group field 70 level 1 - "aa0605"+"6279746573"+ // field 101, encoding 2 string "bytes" - "b0063f"+ // field 102, encoding 0, 0x3f zigzag32 - "b8067f"+ // field 103, encoding 0, 0x7f zigzag64 - "c506e0ffffff"+ // field 104, encoding 5, -32 fixed32 - "c906c0ffffffffffffff"+ // field 105, encoding 1, -64 fixed64 - "b21f02"+ // field 502, encoding 2, 2 bytes - "403f"+ // value 32, value -32 - "ba1f03"+ // field 503, encoding 2, 3 bytes - "80017f"+ // value 64, value -64 - "c21f08"+ // field 504, encoding 2, 8 bytes - "20000000e0ffffff"+ // value 32, value -32 - "ca1f10"+ // field 505, encoding 2, 16 bytes - "4000000000000000c0ffffffffffffff") // value 64, value -64 - -} - -// Test that we can encode empty bytes fields. -func TestEncodeDecodeBytes1(t *testing.T) { - pb := initGoTest(false) - - // Create our bytes - pb.F_BytesRequired = []byte{} - pb.F_BytesRepeated = [][]byte{{}} - pb.F_BytesOptional = []byte{} - - d, err := Marshal(pb) - if err != nil { - t.Error(err) - } - - pbd := new(GoTest) - if err := Unmarshal(d, pbd); err != nil { - t.Error(err) - } - - if pbd.F_BytesRequired == nil || len(pbd.F_BytesRequired) != 0 { - t.Error("required empty bytes field is incorrect") - } - if pbd.F_BytesRepeated == nil || len(pbd.F_BytesRepeated) == 1 && pbd.F_BytesRepeated[0] == nil { - t.Error("repeated empty bytes field is incorrect") - } - if pbd.F_BytesOptional == nil || len(pbd.F_BytesOptional) != 0 { - t.Error("optional empty bytes field is incorrect") - } -} - -// Test that we encode nil-valued fields of a repeated bytes field correctly. -// Since entries in a repeated field cannot be nil, nil must mean empty value. -func TestEncodeDecodeBytes2(t *testing.T) { - pb := initGoTest(false) - - // Create our bytes - pb.F_BytesRepeated = [][]byte{nil} - - d, err := Marshal(pb) - if err != nil { - t.Error(err) - } - - pbd := new(GoTest) - if err := Unmarshal(d, pbd); err != nil { - t.Error(err) - } - - if len(pbd.F_BytesRepeated) != 1 || pbd.F_BytesRepeated[0] == nil { - t.Error("Unexpected value for repeated bytes field") - } -} - -// All required fields set, defaults provided, all repeated fields given two values. -func TestSkippingUnrecognizedFields(t *testing.T) { - o := old() - pb := initGoTestField() - - // Marshal it normally. - o.Marshal(pb) - - // Now new a GoSkipTest record. - skip := &GoSkipTest{ - SkipInt32: Int32(32), - SkipFixed32: Uint32(3232), - SkipFixed64: Uint64(6464), - SkipString: String("skipper"), - Skipgroup: &GoSkipTest_SkipGroup{ - GroupInt32: Int32(75), - GroupString: String("wxyz"), - }, - } - - // Marshal it into same buffer. - o.Marshal(skip) - - pbd := new(GoTestField) - o.Unmarshal(pbd) - - // The __unrecognized field should be a marshaling of GoSkipTest - skipd := new(GoSkipTest) - - o.SetBuf(pbd.XXX_unrecognized) - o.Unmarshal(skipd) - - if *skipd.SkipInt32 != *skip.SkipInt32 { - t.Error("skip int32", skipd.SkipInt32) - } - if *skipd.SkipFixed32 != *skip.SkipFixed32 { - t.Error("skip fixed32", skipd.SkipFixed32) - } - if *skipd.SkipFixed64 != *skip.SkipFixed64 { - t.Error("skip fixed64", skipd.SkipFixed64) - } - if *skipd.SkipString != *skip.SkipString { - t.Error("skip string", *skipd.SkipString) - } - if *skipd.Skipgroup.GroupInt32 != *skip.Skipgroup.GroupInt32 { - t.Error("skip group int32", skipd.Skipgroup.GroupInt32) - } - if *skipd.Skipgroup.GroupString != *skip.Skipgroup.GroupString { - t.Error("skip group string", *skipd.Skipgroup.GroupString) - } -} - -// Check that unrecognized fields of a submessage are preserved. -func TestSubmessageUnrecognizedFields(t *testing.T) { - nm := &NewMessage{ - Nested: &NewMessage_Nested{ - Name: String("Nigel"), - FoodGroup: String("carbs"), - }, - } - b, err := Marshal(nm) - if err != nil { - t.Fatalf("Marshal of NewMessage: %v", err) - } - - // Unmarshal into an OldMessage. - om := new(OldMessage) - if err := Unmarshal(b, om); err != nil { - t.Fatalf("Unmarshal to OldMessage: %v", err) - } - exp := &OldMessage{ - Nested: &OldMessage_Nested{ - Name: String("Nigel"), - // normal protocol buffer users should not do this - XXX_unrecognized: []byte("\x12\x05carbs"), - }, - } - if !Equal(om, exp) { - t.Errorf("om = %v, want %v", om, exp) - } - - // Clone the OldMessage. - om = Clone(om).(*OldMessage) - if !Equal(om, exp) { - t.Errorf("Clone(om) = %v, want %v", om, exp) - } - - // Marshal the OldMessage, then unmarshal it into an empty NewMessage. - if b, err = Marshal(om); err != nil { - t.Fatalf("Marshal of OldMessage: %v", err) - } - t.Logf("Marshal(%v) -> %q", om, b) - nm2 := new(NewMessage) - if err := Unmarshal(b, nm2); err != nil { - t.Fatalf("Unmarshal to NewMessage: %v", err) - } - if !Equal(nm, nm2) { - t.Errorf("NewMessage round-trip: %v => %v", nm, nm2) - } -} - -// Check that an int32 field can be upgraded to an int64 field. -func TestNegativeInt32(t *testing.T) { - om := &OldMessage{ - Num: Int32(-1), - } - b, err := Marshal(om) - if err != nil { - t.Fatalf("Marshal of OldMessage: %v", err) - } - - // Check the size. It should be 11 bytes; - // 1 for the field/wire type, and 10 for the negative number. - if len(b) != 11 { - t.Errorf("%v marshaled as %q, wanted 11 bytes", om, b) - } - - // Unmarshal into a NewMessage. - nm := new(NewMessage) - if err := Unmarshal(b, nm); err != nil { - t.Fatalf("Unmarshal to NewMessage: %v", err) - } - want := &NewMessage{ - Num: Int64(-1), - } - if !Equal(nm, want) { - t.Errorf("nm = %v, want %v", nm, want) - } -} - -// Check that we can grow an array (repeated field) to have many elements. -// This test doesn't depend only on our encoding; for variety, it makes sure -// we create, encode, and decode the correct contents explicitly. It's therefore -// a bit messier. -// This test also uses (and hence tests) the Marshal/Unmarshal functions -// instead of the methods. -func TestBigRepeated(t *testing.T) { - pb := initGoTest(true) - - // Create the arrays - const N = 50 // Internally the library starts much smaller. - pb.Repeatedgroup = make([]*GoTest_RepeatedGroup, N) - pb.F_Sint64Repeated = make([]int64, N) - pb.F_Sint32Repeated = make([]int32, N) - pb.F_BytesRepeated = make([][]byte, N) - pb.F_StringRepeated = make([]string, N) - pb.F_DoubleRepeated = make([]float64, N) - pb.F_FloatRepeated = make([]float32, N) - pb.F_Uint64Repeated = make([]uint64, N) - pb.F_Uint32Repeated = make([]uint32, N) - pb.F_Fixed64Repeated = make([]uint64, N) - pb.F_Fixed32Repeated = make([]uint32, N) - pb.F_Int64Repeated = make([]int64, N) - pb.F_Int32Repeated = make([]int32, N) - pb.F_BoolRepeated = make([]bool, N) - pb.RepeatedField = make([]*GoTestField, N) - - // Fill in the arrays with checkable values. - igtf := initGoTestField() - igtrg := initGoTest_RepeatedGroup() - for i := 0; i < N; i++ { - pb.Repeatedgroup[i] = igtrg - pb.F_Sint64Repeated[i] = int64(i) - pb.F_Sint32Repeated[i] = int32(i) - s := fmt.Sprint(i) - pb.F_BytesRepeated[i] = []byte(s) - pb.F_StringRepeated[i] = s - pb.F_DoubleRepeated[i] = float64(i) - pb.F_FloatRepeated[i] = float32(i) - pb.F_Uint64Repeated[i] = uint64(i) - pb.F_Uint32Repeated[i] = uint32(i) - pb.F_Fixed64Repeated[i] = uint64(i) - pb.F_Fixed32Repeated[i] = uint32(i) - pb.F_Int64Repeated[i] = int64(i) - pb.F_Int32Repeated[i] = int32(i) - pb.F_BoolRepeated[i] = i%2 == 0 - pb.RepeatedField[i] = igtf - } - - // Marshal. - buf, _ := Marshal(pb) - - // Now test Unmarshal by recreating the original buffer. - pbd := new(GoTest) - Unmarshal(buf, pbd) - - // Check the checkable values - for i := uint64(0); i < N; i++ { - if pbd.Repeatedgroup[i] == nil { // TODO: more checking? - t.Error("pbd.Repeatedgroup bad") - } - if x := uint64(pbd.F_Sint64Repeated[i]); x != i { - t.Error("pbd.F_Sint64Repeated bad", x, i) - } - if x := uint64(pbd.F_Sint32Repeated[i]); x != i { - t.Error("pbd.F_Sint32Repeated bad", x, i) - } - s := fmt.Sprint(i) - equalbytes(pbd.F_BytesRepeated[i], []byte(s), t) - if pbd.F_StringRepeated[i] != s { - t.Error("pbd.F_Sint32Repeated bad", pbd.F_StringRepeated[i], i) - } - if x := uint64(pbd.F_DoubleRepeated[i]); x != i { - t.Error("pbd.F_DoubleRepeated bad", x, i) - } - if x := uint64(pbd.F_FloatRepeated[i]); x != i { - t.Error("pbd.F_FloatRepeated bad", x, i) - } - if x := pbd.F_Uint64Repeated[i]; x != i { - t.Error("pbd.F_Uint64Repeated bad", x, i) - } - if x := uint64(pbd.F_Uint32Repeated[i]); x != i { - t.Error("pbd.F_Uint32Repeated bad", x, i) - } - if x := pbd.F_Fixed64Repeated[i]; x != i { - t.Error("pbd.F_Fixed64Repeated bad", x, i) - } - if x := uint64(pbd.F_Fixed32Repeated[i]); x != i { - t.Error("pbd.F_Fixed32Repeated bad", x, i) - } - if x := uint64(pbd.F_Int64Repeated[i]); x != i { - t.Error("pbd.F_Int64Repeated bad", x, i) - } - if x := uint64(pbd.F_Int32Repeated[i]); x != i { - t.Error("pbd.F_Int32Repeated bad", x, i) - } - if x := pbd.F_BoolRepeated[i]; x != (i%2 == 0) { - t.Error("pbd.F_BoolRepeated bad", x, i) - } - if pbd.RepeatedField[i] == nil { // TODO: more checking? - t.Error("pbd.RepeatedField bad") - } - } -} - -func TestBadWireTypeUnknown(t *testing.T) { - var b []byte - fmt.Sscanf("0a01780d00000000080b101612036161611521000000202c220362626225370000002203636363214200000000000000584d5a036464645900000000000056405d63000000", "%x", &b) - - m := new(MyMessage) - if err := Unmarshal(b, m); err != nil { - t.Errorf("unexpected Unmarshal error: %v", err) - } - - var unknown []byte - fmt.Sscanf("0a01780d0000000010161521000000202c2537000000214200000000000000584d5a036464645d63000000", "%x", &unknown) - if !bytes.Equal(m.XXX_unrecognized, unknown) { - t.Errorf("unknown bytes mismatch:\ngot %x\nwant %x", m.XXX_unrecognized, unknown) - } - DiscardUnknown(m) - - want := &MyMessage{Count: Int32(11), Name: String("aaa"), Pet: []string{"bbb", "ccc"}, Bigfloat: Float64(88)} - if !Equal(m, want) { - t.Errorf("message mismatch:\ngot %v\nwant %v", m, want) - } -} - -func encodeDecode(t *testing.T, in, out Message, msg string) { - buf, err := Marshal(in) - if err != nil { - t.Fatalf("failed marshaling %v: %v", msg, err) - } - if err := Unmarshal(buf, out); err != nil { - t.Fatalf("failed unmarshaling %v: %v", msg, err) - } -} - -func TestPackedNonPackedDecoderSwitching(t *testing.T) { - np, p := new(NonPackedTest), new(PackedTest) - - // non-packed -> packed - np.A = []int32{0, 1, 1, 2, 3, 5} - encodeDecode(t, np, p, "non-packed -> packed") - if !reflect.DeepEqual(np.A, p.B) { - t.Errorf("failed non-packed -> packed; np.A=%+v, p.B=%+v", np.A, p.B) - } - - // packed -> non-packed - np.Reset() - p.B = []int32{3, 1, 4, 1, 5, 9} - encodeDecode(t, p, np, "packed -> non-packed") - if !reflect.DeepEqual(p.B, np.A) { - t.Errorf("failed packed -> non-packed; p.B=%+v, np.A=%+v", p.B, np.A) - } -} - -func TestProto1RepeatedGroup(t *testing.T) { - pb := &MessageList{ - Message: []*MessageList_Message{ - { - Name: String("blah"), - Count: Int32(7), - }, - // NOTE: pb.Message[1] is a nil - nil, - }, - } - - o := old() - err := o.Marshal(pb) - if err == nil || !strings.Contains(err.Error(), "repeated field Message has nil") { - t.Fatalf("unexpected or no error when marshaling: %v", err) - } -} - -// Test that enums work. Checks for a bug introduced by making enums -// named types instead of int32: newInt32FromUint64 would crash with -// a type mismatch in reflect.PointTo. -func TestEnum(t *testing.T) { - pb := new(GoEnum) - pb.Foo = FOO_FOO1.Enum() - o := old() - if err := o.Marshal(pb); err != nil { - t.Fatal("error encoding enum:", err) - } - pb1 := new(GoEnum) - if err := o.Unmarshal(pb1); err != nil { - t.Fatal("error decoding enum:", err) - } - if *pb1.Foo != FOO_FOO1 { - t.Error("expected 7 but got ", *pb1.Foo) - } -} - -// Enum types have String methods. Check that enum fields can be printed. -// We don't care what the value actually is, just as long as it doesn't crash. -func TestPrintingNilEnumFields(t *testing.T) { - pb := new(GoEnum) - _ = fmt.Sprintf("%+v", pb) -} - -// Verify that absent required fields cause Marshal/Unmarshal to return errors. -func TestRequiredFieldEnforcement(t *testing.T) { - pb := new(GoTestField) - _, err := Marshal(pb) - if err == nil { - t.Error("marshal: expected error, got nil") - } else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), "Label") { - t.Errorf("marshal: bad error type: %v", err) - } - - // A slightly sneaky, yet valid, proto. It encodes the same required field twice, - // so simply counting the required fields is insufficient. - // field 1, encoding 2, value "hi" - buf := []byte("\x0A\x02hi\x0A\x02hi") - err = Unmarshal(buf, pb) - if err == nil { - t.Error("unmarshal: expected error, got nil") - } else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), "Type") && !strings.Contains(err.Error(), "{Unknown}") { - // TODO: remove unknown cases once we commit to the new unmarshaler. - t.Errorf("unmarshal: bad error type: %v", err) - } -} - -// Verify that absent required fields in groups cause Marshal/Unmarshal to return errors. -func TestRequiredFieldEnforcementGroups(t *testing.T) { - pb := &GoTestRequiredGroupField{Group: &GoTestRequiredGroupField_Group{}} - if _, err := Marshal(pb); err == nil { - t.Error("marshal: expected error, got nil") - } else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), "Group.Field") { - t.Errorf("marshal: bad error type: %v", err) - } - - buf := []byte{11, 12} - if err := Unmarshal(buf, pb); err == nil { - t.Error("unmarshal: expected error, got nil") - } else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), "Group.Field") && !strings.Contains(err.Error(), "Group.{Unknown}") { - t.Errorf("unmarshal: bad error type: %v", err) - } -} - -func TestTypedNilMarshal(t *testing.T) { - // A typed nil should return ErrNil and not crash. - { - var m *GoEnum - if _, err := Marshal(m); err != ErrNil { - t.Errorf("Marshal(%#v): got %v, want ErrNil", m, err) - } - } - - { - m := &Communique{Union: &Communique_Msg{nil}} - if _, err := Marshal(m); err == nil || err == ErrNil { - t.Errorf("Marshal(%#v): got %v, want errOneofHasNil", m, err) - } - } -} - -// A type that implements the Marshaler interface, but is not nillable. -type nonNillableInt uint64 - -func (nni nonNillableInt) Marshal() ([]byte, error) { - return EncodeVarint(uint64(nni)), nil -} - -type NNIMessage struct { - nni nonNillableInt -} - -func (*NNIMessage) Reset() {} -func (*NNIMessage) String() string { return "" } -func (*NNIMessage) ProtoMessage() {} - -type NMMessage struct{} - -func (*NMMessage) Reset() {} -func (*NMMessage) String() string { return "" } -func (*NMMessage) ProtoMessage() {} - -// Verify a type that uses the Marshaler interface, but has a nil pointer. -func TestNilMarshaler(t *testing.T) { - // Try a struct with a Marshaler field that is nil. - // It should be directly marshable. - nmm := new(NMMessage) - if _, err := Marshal(nmm); err != nil { - t.Error("unexpected error marshaling nmm: ", err) - } - - // Try a struct with a Marshaler field that is not nillable. - nnim := new(NNIMessage) - nnim.nni = 7 - var _ Marshaler = nnim.nni // verify it is truly a Marshaler - if _, err := Marshal(nnim); err != nil { - t.Error("unexpected error marshaling nnim: ", err) - } -} - -func TestAllSetDefaults(t *testing.T) { - // Exercise SetDefaults with all scalar field types. - m := &Defaults{ - // NaN != NaN, so override that here. - F_Nan: Float32(1.7), - } - expected := &Defaults{ - F_Bool: Bool(true), - F_Int32: Int32(32), - F_Int64: Int64(64), - F_Fixed32: Uint32(320), - F_Fixed64: Uint64(640), - F_Uint32: Uint32(3200), - F_Uint64: Uint64(6400), - F_Float: Float32(314159), - F_Double: Float64(271828), - F_String: String(`hello, "world!"` + "\n"), - F_Bytes: []byte("Bignose"), - F_Sint32: Int32(-32), - F_Sint64: Int64(-64), - F_Enum: Defaults_GREEN.Enum(), - F_Pinf: Float32(float32(math.Inf(1))), - F_Ninf: Float32(float32(math.Inf(-1))), - F_Nan: Float32(1.7), - StrZero: String(""), - } - SetDefaults(m) - if !Equal(m, expected) { - t.Errorf("SetDefaults failed\n got %v\nwant %v", m, expected) - } -} - -func TestSetDefaultsWithSetField(t *testing.T) { - // Check that a set value is not overridden. - m := &Defaults{ - F_Int32: Int32(12), - } - SetDefaults(m) - if v := m.GetF_Int32(); v != 12 { - t.Errorf("m.FInt32 = %v, want 12", v) - } -} - -func TestSetDefaultsWithSubMessage(t *testing.T) { - m := &OtherMessage{ - Key: Int64(123), - Inner: &InnerMessage{ - Host: String("gopher"), - }, - } - expected := &OtherMessage{ - Key: Int64(123), - Inner: &InnerMessage{ - Host: String("gopher"), - Port: Int32(4000), - }, - } - SetDefaults(m) - if !Equal(m, expected) { - t.Errorf("\n got %v\nwant %v", m, expected) - } -} - -func TestSetDefaultsWithRepeatedSubMessage(t *testing.T) { - m := &MyMessage{ - RepInner: []*InnerMessage{{}}, - } - expected := &MyMessage{ - RepInner: []*InnerMessage{{ - Port: Int32(4000), - }}, - } - SetDefaults(m) - if !Equal(m, expected) { - t.Errorf("\n got %v\nwant %v", m, expected) - } -} - -func TestSetDefaultWithRepeatedNonMessage(t *testing.T) { - m := &MyMessage{ - Pet: []string{"turtle", "wombat"}, - } - expected := Clone(m) - SetDefaults(m) - if !Equal(m, expected) { - t.Errorf("\n got %v\nwant %v", m, expected) - } -} - -func TestMaximumTagNumber(t *testing.T) { - m := &MaxTag{ - LastField: String("natural goat essence"), - } - buf, err := Marshal(m) - if err != nil { - t.Fatalf("proto.Marshal failed: %v", err) - } - m2 := new(MaxTag) - if err := Unmarshal(buf, m2); err != nil { - t.Fatalf("proto.Unmarshal failed: %v", err) - } - if got, want := m2.GetLastField(), *m.LastField; got != want { - t.Errorf("got %q, want %q", got, want) - } -} - -func TestJSON(t *testing.T) { - m := &MyMessage{ - Count: Int32(4), - Pet: []string{"bunny", "kitty"}, - Inner: &InnerMessage{ - Host: String("cauchy"), - }, - Bikeshed: MyMessage_GREEN.Enum(), - } - const expected = `{"count":4,"pet":["bunny","kitty"],"inner":{"host":"cauchy"},"bikeshed":1}` - - b, err := json.Marshal(m) - if err != nil { - t.Fatalf("json.Marshal failed: %v", err) - } - s := string(b) - if s != expected { - t.Errorf("got %s\nwant %s", s, expected) - } - - received := new(MyMessage) - if err := json.Unmarshal(b, received); err != nil { - t.Fatalf("json.Unmarshal failed: %v", err) - } - if !Equal(received, m) { - t.Fatalf("got %s, want %s", received, m) - } - - // Test unmarshalling of JSON with symbolic enum name. - const old = `{"count":4,"pet":["bunny","kitty"],"inner":{"host":"cauchy"},"bikeshed":"GREEN"}` - received.Reset() - if err := json.Unmarshal([]byte(old), received); err != nil { - t.Fatalf("json.Unmarshal failed: %v", err) - } - if !Equal(received, m) { - t.Fatalf("got %s, want %s", received, m) - } -} - -func TestBadWireType(t *testing.T) { - b := []byte{7<<3 | 6} // field 7, wire type 6 - pb := new(OtherMessage) - if err := Unmarshal(b, pb); err == nil { - t.Errorf("Unmarshal did not fail") - } else if !strings.Contains(err.Error(), "unknown wire type") { - t.Errorf("wrong error: %v", err) - } -} - -func TestBytesWithInvalidLength(t *testing.T) { - // If a byte sequence has an invalid (negative) length, Unmarshal should not panic. - b := []byte{2<<3 | WireBytes, 0xff, 0xff, 0xff, 0xff, 0xff, 0} - Unmarshal(b, new(MyMessage)) -} - -func TestLengthOverflow(t *testing.T) { - // Overflowing a length should not panic. - b := []byte{2<<3 | WireBytes, 1, 1, 3<<3 | WireBytes, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x01} - Unmarshal(b, new(MyMessage)) -} - -func TestVarintOverflow(t *testing.T) { - // Overflowing a 64-bit length should not be allowed. - b := []byte{1<<3 | WireVarint, 0x01, 3<<3 | WireBytes, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x01} - if err := Unmarshal(b, new(MyMessage)); err == nil { - t.Fatalf("Overflowed uint64 length without error") - } -} - -func TestBytesWithInvalidLengthInGroup(t *testing.T) { - // Overflowing a 64-bit length should not be allowed. - b := []byte{0xbb, 0x30, 0xb2, 0x30, 0xb0, 0xb2, 0x83, 0xf1, 0xb0, 0xb2, 0xef, 0xbf, 0xbd, 0x01} - if err := Unmarshal(b, new(MyMessage)); err == nil { - t.Fatalf("Overflowed uint64 length without error") - } -} - -func TestUnmarshalFuzz(t *testing.T) { - const N = 1000 - seed := time.Now().UnixNano() - t.Logf("RNG seed is %d", seed) - rng := rand.New(rand.NewSource(seed)) - buf := make([]byte, 20) - for i := 0; i < N; i++ { - for j := range buf { - buf[j] = byte(rng.Intn(256)) - } - fuzzUnmarshal(t, buf) - } -} - -func TestMergeMessages(t *testing.T) { - pb := &MessageList{Message: []*MessageList_Message{{Name: String("x"), Count: Int32(1)}}} - data, err := Marshal(pb) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - - pb1 := new(MessageList) - if err := Unmarshal(data, pb1); err != nil { - t.Fatalf("first Unmarshal: %v", err) - } - if err := Unmarshal(data, pb1); err != nil { - t.Fatalf("second Unmarshal: %v", err) - } - if len(pb1.Message) != 1 { - t.Errorf("two Unmarshals produced %d Messages, want 1", len(pb1.Message)) - } - - pb2 := new(MessageList) - if err := UnmarshalMerge(data, pb2); err != nil { - t.Fatalf("first UnmarshalMerge: %v", err) - } - if err := UnmarshalMerge(data, pb2); err != nil { - t.Fatalf("second UnmarshalMerge: %v", err) - } - if len(pb2.Message) != 2 { - t.Errorf("two UnmarshalMerges produced %d Messages, want 2", len(pb2.Message)) - } -} - -func TestExtensionMarshalOrder(t *testing.T) { - m := &MyMessage{Count: Int(123)} - if err := SetExtension(m, E_Ext_More, &Ext{Data: String("alpha")}); err != nil { - t.Fatalf("SetExtension: %v", err) - } - if err := SetExtension(m, E_Ext_Text, String("aleph")); err != nil { - t.Fatalf("SetExtension: %v", err) - } - if err := SetExtension(m, E_Ext_Number, Int32(1)); err != nil { - t.Fatalf("SetExtension: %v", err) - } - - // Serialize m several times, and check we get the same bytes each time. - var orig []byte - for i := 0; i < 100; i++ { - b, err := Marshal(m) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - if i == 0 { - orig = b - continue - } - if !bytes.Equal(b, orig) { - t.Errorf("Bytes differ on attempt #%d", i) - } - } -} - -func TestExtensionMapFieldMarshalDeterministic(t *testing.T) { - m := &MyMessage{Count: Int(123)} - if err := SetExtension(m, E_Ext_More, &Ext{MapField: map[int32]int32{1: 1, 2: 2, 3: 3, 4: 4}}); err != nil { - t.Fatalf("SetExtension: %v", err) - } - marshal := func(m Message) []byte { - var b Buffer - b.SetDeterministic(true) - if err := b.Marshal(m); err != nil { - t.Fatalf("Marshal failed: %v", err) - } - return b.Bytes() - } - - want := marshal(m) - for i := 0; i < 100; i++ { - if got := marshal(m); !bytes.Equal(got, want) { - t.Errorf("Marshal produced inconsistent output with determinism enabled (pass %d).\n got %v\nwant %v", i, got, want) - } - } -} - -// Many extensions, because small maps might not iterate differently on each iteration. -var exts = []*ExtensionDesc{ - E_X201, - E_X202, - E_X203, - E_X204, - E_X205, - E_X206, - E_X207, - E_X208, - E_X209, - E_X210, - E_X211, - E_X212, - E_X213, - E_X214, - E_X215, - E_X216, - E_X217, - E_X218, - E_X219, - E_X220, - E_X221, - E_X222, - E_X223, - E_X224, - E_X225, - E_X226, - E_X227, - E_X228, - E_X229, - E_X230, - E_X231, - E_X232, - E_X233, - E_X234, - E_X235, - E_X236, - E_X237, - E_X238, - E_X239, - E_X240, - E_X241, - E_X242, - E_X243, - E_X244, - E_X245, - E_X246, - E_X247, - E_X248, - E_X249, - E_X250, -} - -func TestMessageSetMarshalOrder(t *testing.T) { - m := &MyMessageSet{} - for _, x := range exts { - if err := SetExtension(m, x, &Empty{}); err != nil { - t.Fatalf("SetExtension: %v", err) - } - } - - buf, err := Marshal(m) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - - // Serialize m several times, and check we get the same bytes each time. - for i := 0; i < 10; i++ { - b1, err := Marshal(m) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - if !bytes.Equal(b1, buf) { - t.Errorf("Bytes differ on re-Marshal #%d", i) - } - - m2 := &MyMessageSet{} - if err := Unmarshal(buf, m2); err != nil { - t.Errorf("Unmarshal: %v", err) - } - b2, err := Marshal(m2) - if err != nil { - t.Errorf("re-Marshal: %v", err) - } - if !bytes.Equal(b2, buf) { - t.Errorf("Bytes differ on round-trip #%d", i) - } - } -} - -func TestUnmarshalMergesMessages(t *testing.T) { - // If a nested message occurs twice in the input, - // the fields should be merged when decoding. - a := &OtherMessage{ - Key: Int64(123), - Inner: &InnerMessage{ - Host: String("polhode"), - Port: Int32(1234), - }, - } - aData, err := Marshal(a) - if err != nil { - t.Fatalf("Marshal(a): %v", err) - } - b := &OtherMessage{ - Weight: Float32(1.2), - Inner: &InnerMessage{ - Host: String("herpolhode"), - Connected: Bool(true), - }, - } - bData, err := Marshal(b) - if err != nil { - t.Fatalf("Marshal(b): %v", err) - } - want := &OtherMessage{ - Key: Int64(123), - Weight: Float32(1.2), - Inner: &InnerMessage{ - Host: String("herpolhode"), - Port: Int32(1234), - Connected: Bool(true), - }, - } - got := new(OtherMessage) - if err := Unmarshal(append(aData, bData...), got); err != nil { - t.Fatalf("Unmarshal: %v", err) - } - if !Equal(got, want) { - t.Errorf("\n got %v\nwant %v", got, want) - } -} - -func TestUnmarshalMergesGroups(t *testing.T) { - // If a nested group occurs twice in the input, - // the fields should be merged when decoding. - a := &GroupNew{ - G: &GroupNew_G{ - X: Int32(7), - Y: Int32(8), - }, - } - aData, err := Marshal(a) - if err != nil { - t.Fatalf("Marshal(a): %v", err) - } - b := &GroupNew{ - G: &GroupNew_G{ - X: Int32(9), - }, - } - bData, err := Marshal(b) - if err != nil { - t.Fatalf("Marshal(b): %v", err) - } - want := &GroupNew{ - G: &GroupNew_G{ - X: Int32(9), - Y: Int32(8), - }, - } - got := new(GroupNew) - if err := Unmarshal(append(aData, bData...), got); err != nil { - t.Fatalf("Unmarshal: %v", err) - } - if !Equal(got, want) { - t.Errorf("\n got %v\nwant %v", got, want) - } -} - -func TestEncodingSizes(t *testing.T) { - tests := []struct { - m Message - n int - }{ - {&Defaults{F_Int32: Int32(math.MaxInt32)}, 6}, - {&Defaults{F_Int32: Int32(math.MinInt32)}, 11}, - {&Defaults{F_Uint32: Uint32(uint32(math.MaxInt32) + 1)}, 6}, - {&Defaults{F_Uint32: Uint32(math.MaxUint32)}, 6}, - } - for _, test := range tests { - b, err := Marshal(test.m) - if err != nil { - t.Errorf("Marshal(%v): %v", test.m, err) - continue - } - if len(b) != test.n { - t.Errorf("Marshal(%v) yielded %d bytes, want %d bytes", test.m, len(b), test.n) - } - } -} - -func TestRequiredNotSetError(t *testing.T) { - pb := initGoTest(false) - pb.RequiredField.Label = nil - pb.F_Int32Required = nil - pb.F_Int64Required = nil - - expected := "0807" + // field 1, encoding 0, value 7 - "2206" + "120474797065" + // field 4, encoding 2 (GoTestField) - "5001" + // field 10, encoding 0, value 1 - "6d20000000" + // field 13, encoding 5, value 0x20 - "714000000000000000" + // field 14, encoding 1, value 0x40 - "78a019" + // field 15, encoding 0, value 0xca0 = 3232 - "8001c032" + // field 16, encoding 0, value 0x1940 = 6464 - "8d0100004a45" + // field 17, encoding 5, value 3232.0 - "9101000000000040b940" + // field 18, encoding 1, value 6464.0 - "9a0106" + "737472696e67" + // field 19, encoding 2, string "string" - "b304" + // field 70, encoding 3, start group - "ba0408" + "7265717569726564" + // field 71, encoding 2, string "required" - "b404" + // field 70, encoding 4, end group - "aa0605" + "6279746573" + // field 101, encoding 2, string "bytes" - "b0063f" + // field 102, encoding 0, 0x3f zigzag32 - "b8067f" + // field 103, encoding 0, 0x7f zigzag64 - "c506e0ffffff" + // field 104, encoding 5, -32 fixed32 - "c906c0ffffffffffffff" // field 105, encoding 1, -64 fixed64 - - o := old() - bytes, err := Marshal(pb) - if _, ok := err.(*RequiredNotSetError); !ok { - fmt.Printf("marshal-1 err = %v, want *RequiredNotSetError", err) - o.DebugPrint("", bytes) - t.Fatalf("expected = %s", expected) - } - if !strings.Contains(err.Error(), "RequiredField.Label") { - t.Errorf("marshal-1 wrong err msg: %v", err) - } - if !equal(bytes, expected, t) { - o.DebugPrint("neq 1", bytes) - t.Fatalf("expected = %s", expected) - } - - // Now test Unmarshal by recreating the original buffer. - pbd := new(GoTest) - err = Unmarshal(bytes, pbd) - if _, ok := err.(*RequiredNotSetError); !ok { - t.Fatalf("unmarshal err = %v, want *RequiredNotSetError", err) - o.DebugPrint("", bytes) - t.Fatalf("string = %s", expected) - } - if !strings.Contains(err.Error(), "RequiredField.Label") && !strings.Contains(err.Error(), "RequiredField.{Unknown}") { - t.Errorf("unmarshal wrong err msg: %v", err) - } - bytes, err = Marshal(pbd) - if _, ok := err.(*RequiredNotSetError); !ok { - t.Errorf("marshal-2 err = %v, want *RequiredNotSetError", err) - o.DebugPrint("", bytes) - t.Fatalf("string = %s", expected) - } - if !strings.Contains(err.Error(), "RequiredField.Label") { - t.Errorf("marshal-2 wrong err msg: %v", err) - } - if !equal(bytes, expected, t) { - o.DebugPrint("neq 2", bytes) - t.Fatalf("string = %s", expected) - } -} - -func TestRequiredNotSetErrorWithBadWireTypes(t *testing.T) { - // Required field expects a varint, and properly found a varint. - if err := Unmarshal([]byte{0x08, 0x00}, new(GoEnum)); err != nil { - t.Errorf("Unmarshal = %v, want nil", err) - } - // Required field expects a varint, but found a fixed32 instead. - if err := Unmarshal([]byte{0x0d, 0x00, 0x00, 0x00, 0x00}, new(GoEnum)); err == nil { - t.Errorf("Unmarshal = nil, want RequiredNotSetError") - } - // Required field expects a varint, and found both a varint and fixed32 (ignored). - m := new(GoEnum) - if err := Unmarshal([]byte{0x08, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00}, m); err != nil { - t.Errorf("Unmarshal = %v, want nil", err) - } - if !bytes.Equal(m.XXX_unrecognized, []byte{0x0d, 0x00, 0x00, 0x00, 0x00}) { - t.Errorf("expected fixed32 to appear as unknown bytes: %x", m.XXX_unrecognized) - } -} - -func fuzzUnmarshal(t *testing.T, data []byte) { - defer func() { - if e := recover(); e != nil { - t.Errorf("These bytes caused a panic: %+v", data) - t.Logf("Stack:\n%s", debug.Stack()) - t.FailNow() - } - }() - - pb := new(MyMessage) - Unmarshal(data, pb) -} - -func TestMapFieldMarshal(t *testing.T) { - m := &MessageWithMap{ - NameMapping: map[int32]string{ - 1: "Rob", - 4: "Ian", - 8: "Dave", - }, - } - b, err := Marshal(m) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - - // b should be the concatenation of these three byte sequences in some order. - parts := []string{ - "\n\a\b\x01\x12\x03Rob", - "\n\a\b\x04\x12\x03Ian", - "\n\b\b\x08\x12\x04Dave", - } - ok := false - for i := range parts { - for j := range parts { - if j == i { - continue - } - for k := range parts { - if k == i || k == j { - continue - } - try := parts[i] + parts[j] + parts[k] - if bytes.Equal(b, []byte(try)) { - ok = true - break - } - } - } - } - if !ok { - t.Fatalf("Incorrect Marshal output.\n got %q\nwant %q (or a permutation of that)", b, parts[0]+parts[1]+parts[2]) - } - t.Logf("FYI b: %q", b) - - (new(Buffer)).DebugPrint("Dump of b", b) -} - -func TestMapFieldDeterministicMarshal(t *testing.T) { - m := &MessageWithMap{ - NameMapping: map[int32]string{ - 1: "Rob", - 4: "Ian", - 8: "Dave", - }, - } - - marshal := func(m Message) []byte { - var b Buffer - b.SetDeterministic(true) - if err := b.Marshal(m); err != nil { - t.Fatalf("Marshal failed: %v", err) - } - return b.Bytes() - } - - want := marshal(m) - for i := 0; i < 10; i++ { - if got := marshal(m); !bytes.Equal(got, want) { - t.Errorf("Marshal produced inconsistent output with determinism enabled (pass %d).\n got %v\nwant %v", i, got, want) - } - } -} - -func TestMapFieldRoundTrips(t *testing.T) { - m := &MessageWithMap{ - NameMapping: map[int32]string{ - 1: "Rob", - 4: "Ian", - 8: "Dave", - }, - MsgMapping: map[int64]*FloatingPoint{ - 0x7001: {F: Float64(2.0)}, - }, - ByteMapping: map[bool][]byte{ - false: []byte("that's not right!"), - true: []byte("aye, 'tis true!"), - }, - } - b, err := Marshal(m) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - t.Logf("FYI b: %q", b) - m2 := new(MessageWithMap) - if err := Unmarshal(b, m2); err != nil { - t.Fatalf("Unmarshal: %v", err) - } - if !Equal(m, m2) { - t.Errorf("Map did not survive a round trip.\ninitial: %v\n final: %v", m, m2) - } -} - -func TestMapFieldWithNil(t *testing.T) { - m1 := &MessageWithMap{ - MsgMapping: map[int64]*FloatingPoint{ - 1: nil, - }, - } - b, err := Marshal(m1) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - m2 := new(MessageWithMap) - if err := Unmarshal(b, m2); err != nil { - t.Fatalf("Unmarshal: %v, got these bytes: %v", err, b) - } - if v, ok := m2.MsgMapping[1]; !ok { - t.Error("msg_mapping[1] not present") - } else if v != nil { - t.Errorf("msg_mapping[1] not nil: %v", v) - } -} - -func TestMapFieldWithNilBytes(t *testing.T) { - m1 := &MessageWithMap{ - ByteMapping: map[bool][]byte{ - false: {}, - true: nil, - }, - } - n := Size(m1) - b, err := Marshal(m1) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - if n != len(b) { - t.Errorf("Size(m1) = %d; want len(Marshal(m1)) = %d", n, len(b)) - } - m2 := new(MessageWithMap) - if err := Unmarshal(b, m2); err != nil { - t.Fatalf("Unmarshal: %v, got these bytes: %v", err, b) - } - if v, ok := m2.ByteMapping[false]; !ok { - t.Error("byte_mapping[false] not present") - } else if len(v) != 0 { - t.Errorf("byte_mapping[false] not empty: %#v", v) - } - if v, ok := m2.ByteMapping[true]; !ok { - t.Error("byte_mapping[true] not present") - } else if len(v) != 0 { - t.Errorf("byte_mapping[true] not empty: %#v", v) - } -} - -func TestDecodeMapFieldMissingKey(t *testing.T) { - b := []byte{ - 0x0A, 0x03, // message, tag 1 (name_mapping), of length 3 bytes - // no key - 0x12, 0x01, 0x6D, // string value of length 1 byte, value "m" - } - got := &MessageWithMap{} - err := Unmarshal(b, got) - if err != nil { - t.Fatalf("failed to marshal map with missing key: %v", err) - } - want := &MessageWithMap{NameMapping: map[int32]string{0: "m"}} - if !Equal(got, want) { - t.Errorf("Unmarshaled map with no key was not as expected. got: %v, want %v", got, want) - } -} - -func TestDecodeMapFieldMissingValue(t *testing.T) { - b := []byte{ - 0x0A, 0x02, // message, tag 1 (name_mapping), of length 2 bytes - 0x08, 0x01, // varint key, value 1 - // no value - } - got := &MessageWithMap{} - err := Unmarshal(b, got) - if err != nil { - t.Fatalf("failed to marshal map with missing value: %v", err) - } - want := &MessageWithMap{NameMapping: map[int32]string{1: ""}} - if !Equal(got, want) { - t.Errorf("Unmarshaled map with no value was not as expected. got: %v, want %v", got, want) - } -} - -func TestOneof(t *testing.T) { - m := &Communique{} - b, err := Marshal(m) - if err != nil { - t.Fatalf("Marshal of empty message with oneof: %v", err) - } - if len(b) != 0 { - t.Errorf("Marshal of empty message yielded too many bytes: %v", b) - } - - m = &Communique{ - Union: &Communique_Name{"Barry"}, - } - - // Round-trip. - b, err = Marshal(m) - if err != nil { - t.Fatalf("Marshal of message with oneof: %v", err) - } - if len(b) != 7 { // name tag/wire (1) + name len (1) + name (5) - t.Errorf("Incorrect marshal of message with oneof: %v", b) - } - m.Reset() - if err := Unmarshal(b, m); err != nil { - t.Fatalf("Unmarshal of message with oneof: %v", err) - } - if x, ok := m.Union.(*Communique_Name); !ok || x.Name != "Barry" { - t.Errorf("After round trip, Union = %+v", m.Union) - } - if name := m.GetName(); name != "Barry" { - t.Errorf("After round trip, GetName = %q, want %q", name, "Barry") - } - - // Let's try with a message in the oneof. - m.Union = &Communique_Msg{&Strings{StringField: String("deep deep string")}} - b, err = Marshal(m) - if err != nil { - t.Fatalf("Marshal of message with oneof set to message: %v", err) - } - if len(b) != 20 { // msg tag/wire (1) + msg len (1) + msg (1 + 1 + 16) - t.Errorf("Incorrect marshal of message with oneof set to message: %v", b) - } - m.Reset() - if err := Unmarshal(b, m); err != nil { - t.Fatalf("Unmarshal of message with oneof set to message: %v", err) - } - ss, ok := m.Union.(*Communique_Msg) - if !ok || ss.Msg.GetStringField() != "deep deep string" { - t.Errorf("After round trip with oneof set to message, Union = %+v", m.Union) - } -} - -func TestOneofNilBytes(t *testing.T) { - // A oneof with nil byte slice should marshal to tag + 0 (size), with no error. - m := &Communique{Union: &Communique_Data{Data: nil}} - b, err := Marshal(m) - if err != nil { - t.Fatalf("Marshal failed: %v", err) - } - want := []byte{ - 7<<3 | 2, // tag 7, wire type 2 - 0, // size - } - if !bytes.Equal(b, want) { - t.Errorf("Wrong result of Marshal: got %x, want %x", b, want) - } -} - -func TestInefficientPackedBool(t *testing.T) { - // https://github.com/golang/protobuf/issues/76 - inp := []byte{ - 0x12, 0x02, // 0x12 = 2<<3|2; 2 bytes - // Usually a bool should take a single byte, - // but it is permitted to be any varint. - 0xb9, 0x30, - } - if err := Unmarshal(inp, new(MoreRepeated)); err != nil { - t.Error(err) - } -} - -// Make sure pure-reflect-based implementation handles -// []int32-[]enum conversion correctly. -func TestRepeatedEnum2(t *testing.T) { - pb := &RepeatedEnum{ - Color: []RepeatedEnum_Color{RepeatedEnum_RED}, - } - b, err := Marshal(pb) - if err != nil { - t.Fatalf("Marshal failed: %v", err) - } - x := new(RepeatedEnum) - err = Unmarshal(b, x) - if err != nil { - t.Fatalf("Unmarshal failed: %v", err) - } - if !Equal(pb, x) { - t.Errorf("Incorrect result: want: %v got: %v", pb, x) - } -} - -// TestConcurrentMarshal makes sure that it is safe to marshal -// same message in multiple goroutines concurrently. -func TestConcurrentMarshal(t *testing.T) { - pb := initGoTest(true) - const N = 100 - b := make([][]byte, N) - - var wg sync.WaitGroup - for i := 0; i < N; i++ { - wg.Add(1) - go func(i int) { - defer wg.Done() - var err error - b[i], err = Marshal(pb) - if err != nil { - t.Errorf("marshal error: %v", err) - } - }(i) - } - - wg.Wait() - for i := 1; i < N; i++ { - if !bytes.Equal(b[0], b[i]) { - t.Errorf("concurrent marshal result not same: b[0] = %v, b[%d] = %v", b[0], i, b[i]) - } - } -} - -func TestInvalidUTF8(t *testing.T) { - const invalidUTF8 = "\xde\xad\xbe\xef\x80\x00\xff" - tests := []struct { - label string - proto2 Message - proto3 Message - want []byte - }{{ - label: "Scalar", - proto2: &TestUTF8{Scalar: String(invalidUTF8)}, - proto3: &pb3.TestUTF8{Scalar: invalidUTF8}, - want: []byte{0x0a, 0x07, 0xde, 0xad, 0xbe, 0xef, 0x80, 0x00, 0xff}, - }, { - label: "Vector", - proto2: &TestUTF8{Vector: []string{invalidUTF8}}, - proto3: &pb3.TestUTF8{Vector: []string{invalidUTF8}}, - want: []byte{0x12, 0x07, 0xde, 0xad, 0xbe, 0xef, 0x80, 0x00, 0xff}, - }, { - label: "Oneof", - proto2: &TestUTF8{Oneof: &TestUTF8_Field{invalidUTF8}}, - proto3: &pb3.TestUTF8{Oneof: &pb3.TestUTF8_Field{invalidUTF8}}, - want: []byte{0x1a, 0x07, 0xde, 0xad, 0xbe, 0xef, 0x80, 0x00, 0xff}, - }, { - label: "MapKey", - proto2: &TestUTF8{MapKey: map[string]int64{invalidUTF8: 0}}, - proto3: &pb3.TestUTF8{MapKey: map[string]int64{invalidUTF8: 0}}, - want: []byte{0x22, 0x0b, 0x0a, 0x07, 0xde, 0xad, 0xbe, 0xef, 0x80, 0x00, 0xff, 0x10, 0x00}, - }, { - label: "MapValue", - proto2: &TestUTF8{MapValue: map[int64]string{0: invalidUTF8}}, - proto3: &pb3.TestUTF8{MapValue: map[int64]string{0: invalidUTF8}}, - want: []byte{0x2a, 0x0b, 0x08, 0x00, 0x12, 0x07, 0xde, 0xad, 0xbe, 0xef, 0x80, 0x00, 0xff}, - }} - - for _, tt := range tests { - // Proto2 should not validate UTF-8. - b, err := Marshal(tt.proto2) - if err != nil { - t.Errorf("Marshal(proto2.%s) = %v, want nil", tt.label, err) - } - if !bytes.Equal(b, tt.want) { - t.Errorf("Marshal(proto2.%s) = %x, want %x", tt.label, b, tt.want) - } - - m := Clone(tt.proto2) - m.Reset() - if err = Unmarshal(tt.want, m); err != nil { - t.Errorf("Unmarshal(proto2.%s) = %v, want nil", tt.label, err) - } - if !Equal(m, tt.proto2) { - t.Errorf("proto2.%s: output mismatch:\ngot %v\nwant %v", tt.label, m, tt.proto2) - } - - // Proto3 should validate UTF-8. - b, err = Marshal(tt.proto3) - if err == nil { - t.Errorf("Marshal(proto3.%s) = %v, want non-nil", tt.label, err) - } - if !bytes.Equal(b, tt.want) { - t.Errorf("Marshal(proto3.%s) = %x, want %x", tt.label, b, tt.want) - } - - m = Clone(tt.proto3) - m.Reset() - err = Unmarshal(tt.want, m) - if err == nil { - t.Errorf("Unmarshal(proto3.%s) = %v, want non-nil", tt.label, err) - } - if !Equal(m, tt.proto3) { - t.Errorf("proto3.%s: output mismatch:\ngot %v\nwant %v", tt.label, m, tt.proto2) - } - } -} - -func TestRequired(t *testing.T) { - // The F_BoolRequired field appears after all of the required fields. - // It should still be handled even after multiple required field violations. - m := &GoTest{F_BoolRequired: Bool(true)} - got, err := Marshal(m) - if _, ok := err.(*RequiredNotSetError); !ok { - t.Errorf("Marshal() = %v, want RequiredNotSetError error", err) - } - if want := []byte{0x50, 0x01}; !bytes.Equal(got, want) { - t.Errorf("Marshal() = %x, want %x", got, want) - } - - m = new(GoTest) - err = Unmarshal(got, m) - if _, ok := err.(*RequiredNotSetError); !ok { - t.Errorf("Marshal() = %v, want RequiredNotSetError error", err) - } - if !m.GetF_BoolRequired() { - t.Error("m.F_BoolRequired = false, want true") - } -} - -// Benchmarks - -func testMsg() *GoTest { - pb := initGoTest(true) - const N = 1000 // Internally the library starts much smaller. - pb.F_Int32Repeated = make([]int32, N) - pb.F_DoubleRepeated = make([]float64, N) - for i := 0; i < N; i++ { - pb.F_Int32Repeated[i] = int32(i) - pb.F_DoubleRepeated[i] = float64(i) - } - return pb -} - -func bytesMsg() *GoTest { - pb := initGoTest(true) - buf := make([]byte, 4000) - for i := range buf { - buf[i] = byte(i) - } - pb.F_BytesDefaulted = buf - return pb -} - -func benchmarkMarshal(b *testing.B, pb Message, marshal func(Message) ([]byte, error)) { - d, _ := marshal(pb) - b.SetBytes(int64(len(d))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - marshal(pb) - } -} - -func benchmarkBufferMarshal(b *testing.B, pb Message) { - p := NewBuffer(nil) - benchmarkMarshal(b, pb, func(pb0 Message) ([]byte, error) { - p.Reset() - err := p.Marshal(pb0) - return p.Bytes(), err - }) -} - -func benchmarkSize(b *testing.B, pb Message) { - benchmarkMarshal(b, pb, func(pb0 Message) ([]byte, error) { - Size(pb) - return nil, nil - }) -} - -func newOf(pb Message) Message { - in := reflect.ValueOf(pb) - if in.IsNil() { - return pb - } - return reflect.New(in.Type().Elem()).Interface().(Message) -} - -func benchmarkUnmarshal(b *testing.B, pb Message, unmarshal func([]byte, Message) error) { - d, _ := Marshal(pb) - b.SetBytes(int64(len(d))) - pbd := newOf(pb) - - b.ResetTimer() - for i := 0; i < b.N; i++ { - unmarshal(d, pbd) - } -} - -func benchmarkBufferUnmarshal(b *testing.B, pb Message) { - p := NewBuffer(nil) - benchmarkUnmarshal(b, pb, func(d []byte, pb0 Message) error { - p.SetBuf(d) - return p.Unmarshal(pb0) - }) -} - -// Benchmark{Marshal,BufferMarshal,Size,Unmarshal,BufferUnmarshal}{,Bytes} - -func BenchmarkMarshal(b *testing.B) { - benchmarkMarshal(b, testMsg(), Marshal) -} - -func BenchmarkBufferMarshal(b *testing.B) { - benchmarkBufferMarshal(b, testMsg()) -} - -func BenchmarkSize(b *testing.B) { - benchmarkSize(b, testMsg()) -} - -func BenchmarkUnmarshal(b *testing.B) { - benchmarkUnmarshal(b, testMsg(), Unmarshal) -} - -func BenchmarkBufferUnmarshal(b *testing.B) { - benchmarkBufferUnmarshal(b, testMsg()) -} - -func BenchmarkMarshalBytes(b *testing.B) { - benchmarkMarshal(b, bytesMsg(), Marshal) -} - -func BenchmarkBufferMarshalBytes(b *testing.B) { - benchmarkBufferMarshal(b, bytesMsg()) -} - -func BenchmarkSizeBytes(b *testing.B) { - benchmarkSize(b, bytesMsg()) -} - -func BenchmarkUnmarshalBytes(b *testing.B) { - benchmarkUnmarshal(b, bytesMsg(), Unmarshal) -} - -func BenchmarkBufferUnmarshalBytes(b *testing.B) { - benchmarkBufferUnmarshal(b, bytesMsg()) -} - -func BenchmarkUnmarshalUnrecognizedFields(b *testing.B) { - b.StopTimer() - pb := initGoTestField() - skip := &GoSkipTest{ - SkipInt32: Int32(32), - SkipFixed32: Uint32(3232), - SkipFixed64: Uint64(6464), - SkipString: String("skipper"), - Skipgroup: &GoSkipTest_SkipGroup{ - GroupInt32: Int32(75), - GroupString: String("wxyz"), - }, - } - - pbd := new(GoTestField) - p := NewBuffer(nil) - p.Marshal(pb) - p.Marshal(skip) - p2 := NewBuffer(nil) - - b.StartTimer() - for i := 0; i < b.N; i++ { - p2.SetBuf(p.Bytes()) - p2.Unmarshal(pbd) - } -} diff --git a/vendor/github.com/golang/protobuf/proto/any_test.go b/vendor/github.com/golang/protobuf/proto/any_test.go deleted file mode 100644 index 56fc97c1..00000000 --- a/vendor/github.com/golang/protobuf/proto/any_test.go +++ /dev/null @@ -1,300 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2016 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package proto_test - -import ( - "strings" - "testing" - - "github.com/golang/protobuf/proto" - - pb "github.com/golang/protobuf/proto/proto3_proto" - testpb "github.com/golang/protobuf/proto/test_proto" - anypb "github.com/golang/protobuf/ptypes/any" -) - -var ( - expandedMarshaler = proto.TextMarshaler{ExpandAny: true} - expandedCompactMarshaler = proto.TextMarshaler{Compact: true, ExpandAny: true} -) - -// anyEqual reports whether two messages which may be google.protobuf.Any or may -// contain google.protobuf.Any fields are equal. We can't use proto.Equal for -// comparison, because semantically equivalent messages may be marshaled to -// binary in different tag order. Instead, trust that TextMarshaler with -// ExpandAny option works and compare the text marshaling results. -func anyEqual(got, want proto.Message) bool { - // if messages are proto.Equal, no need to marshal. - if proto.Equal(got, want) { - return true - } - g := expandedMarshaler.Text(got) - w := expandedMarshaler.Text(want) - return g == w -} - -type golden struct { - m proto.Message - t, c string -} - -var goldenMessages = makeGolden() - -func makeGolden() []golden { - nested := &pb.Nested{Bunny: "Monty"} - nb, err := proto.Marshal(nested) - if err != nil { - panic(err) - } - m1 := &pb.Message{ - Name: "David", - ResultCount: 47, - Anything: &anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(nested), Value: nb}, - } - m2 := &pb.Message{ - Name: "David", - ResultCount: 47, - Anything: &anypb.Any{TypeUrl: "http://[::1]/type.googleapis.com/" + proto.MessageName(nested), Value: nb}, - } - m3 := &pb.Message{ - Name: "David", - ResultCount: 47, - Anything: &anypb.Any{TypeUrl: `type.googleapis.com/"/` + proto.MessageName(nested), Value: nb}, - } - m4 := &pb.Message{ - Name: "David", - ResultCount: 47, - Anything: &anypb.Any{TypeUrl: "type.googleapis.com/a/path/" + proto.MessageName(nested), Value: nb}, - } - m5 := &anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(nested), Value: nb} - - any1 := &testpb.MyMessage{Count: proto.Int32(47), Name: proto.String("David")} - proto.SetExtension(any1, testpb.E_Ext_More, &testpb.Ext{Data: proto.String("foo")}) - proto.SetExtension(any1, testpb.E_Ext_Text, proto.String("bar")) - any1b, err := proto.Marshal(any1) - if err != nil { - panic(err) - } - any2 := &testpb.MyMessage{Count: proto.Int32(42), Bikeshed: testpb.MyMessage_GREEN.Enum(), RepBytes: [][]byte{[]byte("roboto")}} - proto.SetExtension(any2, testpb.E_Ext_More, &testpb.Ext{Data: proto.String("baz")}) - any2b, err := proto.Marshal(any2) - if err != nil { - panic(err) - } - m6 := &pb.Message{ - Name: "David", - ResultCount: 47, - Anything: &anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(any1), Value: any1b}, - ManyThings: []*anypb.Any{ - &anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(any2), Value: any2b}, - &anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(any1), Value: any1b}, - }, - } - - const ( - m1Golden = ` -name: "David" -result_count: 47 -anything: < - [type.googleapis.com/proto3_proto.Nested]: < - bunny: "Monty" - > -> -` - m2Golden = ` -name: "David" -result_count: 47 -anything: < - ["http://[::1]/type.googleapis.com/proto3_proto.Nested"]: < - bunny: "Monty" - > -> -` - m3Golden = ` -name: "David" -result_count: 47 -anything: < - ["type.googleapis.com/\"/proto3_proto.Nested"]: < - bunny: "Monty" - > -> -` - m4Golden = ` -name: "David" -result_count: 47 -anything: < - [type.googleapis.com/a/path/proto3_proto.Nested]: < - bunny: "Monty" - > -> -` - m5Golden = ` -[type.googleapis.com/proto3_proto.Nested]: < - bunny: "Monty" -> -` - m6Golden = ` -name: "David" -result_count: 47 -anything: < - [type.googleapis.com/test_proto.MyMessage]: < - count: 47 - name: "David" - [test_proto.Ext.more]: < - data: "foo" - > - [test_proto.Ext.text]: "bar" - > -> -many_things: < - [type.googleapis.com/test_proto.MyMessage]: < - count: 42 - bikeshed: GREEN - rep_bytes: "roboto" - [test_proto.Ext.more]: < - data: "baz" - > - > -> -many_things: < - [type.googleapis.com/test_proto.MyMessage]: < - count: 47 - name: "David" - [test_proto.Ext.more]: < - data: "foo" - > - [test_proto.Ext.text]: "bar" - > -> -` - ) - return []golden{ - {m1, strings.TrimSpace(m1Golden) + "\n", strings.TrimSpace(compact(m1Golden)) + " "}, - {m2, strings.TrimSpace(m2Golden) + "\n", strings.TrimSpace(compact(m2Golden)) + " "}, - {m3, strings.TrimSpace(m3Golden) + "\n", strings.TrimSpace(compact(m3Golden)) + " "}, - {m4, strings.TrimSpace(m4Golden) + "\n", strings.TrimSpace(compact(m4Golden)) + " "}, - {m5, strings.TrimSpace(m5Golden) + "\n", strings.TrimSpace(compact(m5Golden)) + " "}, - {m6, strings.TrimSpace(m6Golden) + "\n", strings.TrimSpace(compact(m6Golden)) + " "}, - } -} - -func TestMarshalGolden(t *testing.T) { - for _, tt := range goldenMessages { - if got, want := expandedMarshaler.Text(tt.m), tt.t; got != want { - t.Errorf("message %v: got:\n%s\nwant:\n%s", tt.m, got, want) - } - if got, want := expandedCompactMarshaler.Text(tt.m), tt.c; got != want { - t.Errorf("message %v: got:\n`%s`\nwant:\n`%s`", tt.m, got, want) - } - } -} - -func TestUnmarshalGolden(t *testing.T) { - for _, tt := range goldenMessages { - want := tt.m - got := proto.Clone(tt.m) - got.Reset() - if err := proto.UnmarshalText(tt.t, got); err != nil { - t.Errorf("failed to unmarshal\n%s\nerror: %v", tt.t, err) - } - if !anyEqual(got, want) { - t.Errorf("message:\n%s\ngot:\n%s\nwant:\n%s", tt.t, got, want) - } - got.Reset() - if err := proto.UnmarshalText(tt.c, got); err != nil { - t.Errorf("failed to unmarshal\n%s\nerror: %v", tt.c, err) - } - if !anyEqual(got, want) { - t.Errorf("message:\n%s\ngot:\n%s\nwant:\n%s", tt.c, got, want) - } - } -} - -func TestMarshalUnknownAny(t *testing.T) { - m := &pb.Message{ - Anything: &anypb.Any{ - TypeUrl: "foo", - Value: []byte("bar"), - }, - } - want := `anything: < - type_url: "foo" - value: "bar" -> -` - got := expandedMarshaler.Text(m) - if got != want { - t.Errorf("got\n`%s`\nwant\n`%s`", got, want) - } -} - -func TestAmbiguousAny(t *testing.T) { - pb := &anypb.Any{} - err := proto.UnmarshalText(` - type_url: "ttt/proto3_proto.Nested" - value: "\n\x05Monty" - `, pb) - t.Logf("result: %v (error: %v)", expandedMarshaler.Text(pb), err) - if err != nil { - t.Errorf("failed to parse ambiguous Any message: %v", err) - } -} - -func TestUnmarshalOverwriteAny(t *testing.T) { - pb := &anypb.Any{} - err := proto.UnmarshalText(` - [type.googleapis.com/a/path/proto3_proto.Nested]: < - bunny: "Monty" - > - [type.googleapis.com/a/path/proto3_proto.Nested]: < - bunny: "Rabbit of Caerbannog" - > - `, pb) - want := `line 7: Any message unpacked multiple times, or "type_url" already set` - if err.Error() != want { - t.Errorf("incorrect error.\nHave: %v\nWant: %v", err.Error(), want) - } -} - -func TestUnmarshalAnyMixAndMatch(t *testing.T) { - pb := &anypb.Any{} - err := proto.UnmarshalText(` - value: "\n\x05Monty" - [type.googleapis.com/a/path/proto3_proto.Nested]: < - bunny: "Rabbit of Caerbannog" - > - `, pb) - want := `line 5: Any message unpacked multiple times, or "value" already set` - if err.Error() != want { - t.Errorf("incorrect error.\nHave: %v\nWant: %v", err.Error(), want) - } -} diff --git a/vendor/github.com/golang/protobuf/proto/clone_test.go b/vendor/github.com/golang/protobuf/proto/clone_test.go deleted file mode 100644 index 0d3b1273..00000000 --- a/vendor/github.com/golang/protobuf/proto/clone_test.go +++ /dev/null @@ -1,390 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2011 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package proto_test - -import ( - "testing" - - "github.com/golang/protobuf/proto" - - proto3pb "github.com/golang/protobuf/proto/proto3_proto" - pb "github.com/golang/protobuf/proto/test_proto" -) - -var cloneTestMessage = &pb.MyMessage{ - Count: proto.Int32(42), - Name: proto.String("Dave"), - Pet: []string{"bunny", "kitty", "horsey"}, - Inner: &pb.InnerMessage{ - Host: proto.String("niles"), - Port: proto.Int32(9099), - Connected: proto.Bool(true), - }, - Others: []*pb.OtherMessage{ - { - Value: []byte("some bytes"), - }, - }, - Somegroup: &pb.MyMessage_SomeGroup{ - GroupField: proto.Int32(6), - }, - RepBytes: [][]byte{[]byte("sham"), []byte("wow")}, -} - -func init() { - ext := &pb.Ext{ - Data: proto.String("extension"), - } - if err := proto.SetExtension(cloneTestMessage, pb.E_Ext_More, ext); err != nil { - panic("SetExtension: " + err.Error()) - } -} - -func TestClone(t *testing.T) { - m := proto.Clone(cloneTestMessage).(*pb.MyMessage) - if !proto.Equal(m, cloneTestMessage) { - t.Fatalf("Clone(%v) = %v", cloneTestMessage, m) - } - - // Verify it was a deep copy. - *m.Inner.Port++ - if proto.Equal(m, cloneTestMessage) { - t.Error("Mutating clone changed the original") - } - // Byte fields and repeated fields should be copied. - if &m.Pet[0] == &cloneTestMessage.Pet[0] { - t.Error("Pet: repeated field not copied") - } - if &m.Others[0] == &cloneTestMessage.Others[0] { - t.Error("Others: repeated field not copied") - } - if &m.Others[0].Value[0] == &cloneTestMessage.Others[0].Value[0] { - t.Error("Others[0].Value: bytes field not copied") - } - if &m.RepBytes[0] == &cloneTestMessage.RepBytes[0] { - t.Error("RepBytes: repeated field not copied") - } - if &m.RepBytes[0][0] == &cloneTestMessage.RepBytes[0][0] { - t.Error("RepBytes[0]: bytes field not copied") - } -} - -func TestCloneNil(t *testing.T) { - var m *pb.MyMessage - if c := proto.Clone(m); !proto.Equal(m, c) { - t.Errorf("Clone(%v) = %v", m, c) - } -} - -var mergeTests = []struct { - src, dst, want proto.Message -}{ - { - src: &pb.MyMessage{ - Count: proto.Int32(42), - }, - dst: &pb.MyMessage{ - Name: proto.String("Dave"), - }, - want: &pb.MyMessage{ - Count: proto.Int32(42), - Name: proto.String("Dave"), - }, - }, - { - src: &pb.MyMessage{ - Inner: &pb.InnerMessage{ - Host: proto.String("hey"), - Connected: proto.Bool(true), - }, - Pet: []string{"horsey"}, - Others: []*pb.OtherMessage{ - { - Value: []byte("some bytes"), - }, - }, - }, - dst: &pb.MyMessage{ - Inner: &pb.InnerMessage{ - Host: proto.String("niles"), - Port: proto.Int32(9099), - }, - Pet: []string{"bunny", "kitty"}, - Others: []*pb.OtherMessage{ - { - Key: proto.Int64(31415926535), - }, - { - // Explicitly test a src=nil field - Inner: nil, - }, - }, - }, - want: &pb.MyMessage{ - Inner: &pb.InnerMessage{ - Host: proto.String("hey"), - Connected: proto.Bool(true), - Port: proto.Int32(9099), - }, - Pet: []string{"bunny", "kitty", "horsey"}, - Others: []*pb.OtherMessage{ - { - Key: proto.Int64(31415926535), - }, - {}, - { - Value: []byte("some bytes"), - }, - }, - }, - }, - { - src: &pb.MyMessage{ - RepBytes: [][]byte{[]byte("wow")}, - }, - dst: &pb.MyMessage{ - Somegroup: &pb.MyMessage_SomeGroup{ - GroupField: proto.Int32(6), - }, - RepBytes: [][]byte{[]byte("sham")}, - }, - want: &pb.MyMessage{ - Somegroup: &pb.MyMessage_SomeGroup{ - GroupField: proto.Int32(6), - }, - RepBytes: [][]byte{[]byte("sham"), []byte("wow")}, - }, - }, - // Check that a scalar bytes field replaces rather than appends. - { - src: &pb.OtherMessage{Value: []byte("foo")}, - dst: &pb.OtherMessage{Value: []byte("bar")}, - want: &pb.OtherMessage{Value: []byte("foo")}, - }, - { - src: &pb.MessageWithMap{ - NameMapping: map[int32]string{6: "Nigel"}, - MsgMapping: map[int64]*pb.FloatingPoint{ - 0x4001: &pb.FloatingPoint{F: proto.Float64(2.0)}, - 0x4002: &pb.FloatingPoint{ - F: proto.Float64(2.0), - }, - }, - ByteMapping: map[bool][]byte{true: []byte("wowsa")}, - }, - dst: &pb.MessageWithMap{ - NameMapping: map[int32]string{ - 6: "Bruce", // should be overwritten - 7: "Andrew", - }, - MsgMapping: map[int64]*pb.FloatingPoint{ - 0x4002: &pb.FloatingPoint{ - F: proto.Float64(3.0), - Exact: proto.Bool(true), - }, // the entire message should be overwritten - }, - }, - want: &pb.MessageWithMap{ - NameMapping: map[int32]string{ - 6: "Nigel", - 7: "Andrew", - }, - MsgMapping: map[int64]*pb.FloatingPoint{ - 0x4001: &pb.FloatingPoint{F: proto.Float64(2.0)}, - 0x4002: &pb.FloatingPoint{ - F: proto.Float64(2.0), - }, - }, - ByteMapping: map[bool][]byte{true: []byte("wowsa")}, - }, - }, - // proto3 shouldn't merge zero values, - // in the same way that proto2 shouldn't merge nils. - { - src: &proto3pb.Message{ - Name: "Aaron", - Data: []byte(""), // zero value, but not nil - }, - dst: &proto3pb.Message{ - HeightInCm: 176, - Data: []byte("texas!"), - }, - want: &proto3pb.Message{ - Name: "Aaron", - HeightInCm: 176, - Data: []byte("texas!"), - }, - }, - { // Oneof fields should merge by assignment. - src: &pb.Communique{Union: &pb.Communique_Number{41}}, - dst: &pb.Communique{Union: &pb.Communique_Name{"Bobby Tables"}}, - want: &pb.Communique{Union: &pb.Communique_Number{41}}, - }, - { // Oneof nil is the same as not set. - src: &pb.Communique{}, - dst: &pb.Communique{Union: &pb.Communique_Name{"Bobby Tables"}}, - want: &pb.Communique{Union: &pb.Communique_Name{"Bobby Tables"}}, - }, - { - src: &pb.Communique{Union: &pb.Communique_Number{1337}}, - dst: &pb.Communique{}, - want: &pb.Communique{Union: &pb.Communique_Number{1337}}, - }, - { - src: &pb.Communique{Union: &pb.Communique_Col{pb.MyMessage_RED}}, - dst: &pb.Communique{}, - want: &pb.Communique{Union: &pb.Communique_Col{pb.MyMessage_RED}}, - }, - { - src: &pb.Communique{Union: &pb.Communique_Data{[]byte("hello")}}, - dst: &pb.Communique{}, - want: &pb.Communique{Union: &pb.Communique_Data{[]byte("hello")}}, - }, - { - src: &pb.Communique{Union: &pb.Communique_Msg{&pb.Strings{BytesField: []byte{1, 2, 3}}}}, - dst: &pb.Communique{}, - want: &pb.Communique{Union: &pb.Communique_Msg{&pb.Strings{BytesField: []byte{1, 2, 3}}}}, - }, - { - src: &pb.Communique{Union: &pb.Communique_Msg{}}, - dst: &pb.Communique{}, - want: &pb.Communique{Union: &pb.Communique_Msg{}}, - }, - { - src: &pb.Communique{Union: &pb.Communique_Msg{&pb.Strings{StringField: proto.String("123")}}}, - dst: &pb.Communique{Union: &pb.Communique_Msg{&pb.Strings{BytesField: []byte{1, 2, 3}}}}, - want: &pb.Communique{Union: &pb.Communique_Msg{&pb.Strings{StringField: proto.String("123"), BytesField: []byte{1, 2, 3}}}}, - }, - { - src: &proto3pb.Message{ - Terrain: map[string]*proto3pb.Nested{ - "kay_a": &proto3pb.Nested{Cute: true}, // replace - "kay_b": &proto3pb.Nested{Bunny: "rabbit"}, // insert - }, - }, - dst: &proto3pb.Message{ - Terrain: map[string]*proto3pb.Nested{ - "kay_a": &proto3pb.Nested{Bunny: "lost"}, // replaced - "kay_c": &proto3pb.Nested{Bunny: "bunny"}, // keep - }, - }, - want: &proto3pb.Message{ - Terrain: map[string]*proto3pb.Nested{ - "kay_a": &proto3pb.Nested{Cute: true}, - "kay_b": &proto3pb.Nested{Bunny: "rabbit"}, - "kay_c": &proto3pb.Nested{Bunny: "bunny"}, - }, - }, - }, - { - src: &pb.GoTest{ - F_BoolRepeated: []bool{}, - F_Int32Repeated: []int32{}, - F_Int64Repeated: []int64{}, - F_Uint32Repeated: []uint32{}, - F_Uint64Repeated: []uint64{}, - F_FloatRepeated: []float32{}, - F_DoubleRepeated: []float64{}, - F_StringRepeated: []string{}, - F_BytesRepeated: [][]byte{}, - }, - dst: &pb.GoTest{}, - want: &pb.GoTest{ - F_BoolRepeated: []bool{}, - F_Int32Repeated: []int32{}, - F_Int64Repeated: []int64{}, - F_Uint32Repeated: []uint32{}, - F_Uint64Repeated: []uint64{}, - F_FloatRepeated: []float32{}, - F_DoubleRepeated: []float64{}, - F_StringRepeated: []string{}, - F_BytesRepeated: [][]byte{}, - }, - }, - { - src: &pb.GoTest{}, - dst: &pb.GoTest{ - F_BoolRepeated: []bool{}, - F_Int32Repeated: []int32{}, - F_Int64Repeated: []int64{}, - F_Uint32Repeated: []uint32{}, - F_Uint64Repeated: []uint64{}, - F_FloatRepeated: []float32{}, - F_DoubleRepeated: []float64{}, - F_StringRepeated: []string{}, - F_BytesRepeated: [][]byte{}, - }, - want: &pb.GoTest{ - F_BoolRepeated: []bool{}, - F_Int32Repeated: []int32{}, - F_Int64Repeated: []int64{}, - F_Uint32Repeated: []uint32{}, - F_Uint64Repeated: []uint64{}, - F_FloatRepeated: []float32{}, - F_DoubleRepeated: []float64{}, - F_StringRepeated: []string{}, - F_BytesRepeated: [][]byte{}, - }, - }, - { - src: &pb.GoTest{ - F_BytesRepeated: [][]byte{nil, []byte{}, []byte{0}}, - }, - dst: &pb.GoTest{}, - want: &pb.GoTest{ - F_BytesRepeated: [][]byte{nil, []byte{}, []byte{0}}, - }, - }, - { - src: &pb.MyMessage{ - Others: []*pb.OtherMessage{}, - }, - dst: &pb.MyMessage{}, - want: &pb.MyMessage{ - Others: []*pb.OtherMessage{}, - }, - }, -} - -func TestMerge(t *testing.T) { - for _, m := range mergeTests { - got := proto.Clone(m.dst) - if !proto.Equal(got, m.dst) { - t.Errorf("Clone()\ngot %v\nwant %v", got, m.dst) - continue - } - proto.Merge(got, m.src) - if !proto.Equal(got, m.want) { - t.Errorf("Merge(%v, %v)\ngot %v\nwant %v", m.dst, m.src, got, m.want) - } - } -} diff --git a/vendor/github.com/golang/protobuf/proto/decode_test.go b/vendor/github.com/golang/protobuf/proto/decode_test.go deleted file mode 100644 index 949be3ab..00000000 --- a/vendor/github.com/golang/protobuf/proto/decode_test.go +++ /dev/null @@ -1,255 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2010 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// +build go1.7 - -package proto_test - -import ( - "fmt" - "testing" - - "github.com/golang/protobuf/proto" - tpb "github.com/golang/protobuf/proto/proto3_proto" -) - -var msgBlackhole = new(tpb.Message) - -// BenchmarkVarint32ArraySmall shows the performance on an array of small int32 fields (1 and -// 2 bytes long). -func BenchmarkVarint32ArraySmall(b *testing.B) { - for i := uint(1); i <= 10; i++ { - dist := genInt32Dist([7]int{0, 3, 1}, 1<unmarshal. -} - -func TestMarshalUnmarshalRepeatedExtension(t *testing.T) { - // Add a repeated extension to the result. - tests := []struct { - name string - ext []*pb.ComplexExtension - }{ - { - "two fields", - []*pb.ComplexExtension{ - {First: proto.Int32(7)}, - {Second: proto.Int32(11)}, - }, - }, - { - "repeated field", - []*pb.ComplexExtension{ - {Third: []int32{1000}}, - {Third: []int32{2000}}, - }, - }, - { - "two fields and repeated field", - []*pb.ComplexExtension{ - {Third: []int32{1000}}, - {First: proto.Int32(9)}, - {Second: proto.Int32(21)}, - {Third: []int32{2000}}, - }, - }, - } - for _, test := range tests { - // Marshal message with a repeated extension. - msg1 := new(pb.OtherMessage) - err := proto.SetExtension(msg1, pb.E_RComplex, test.ext) - if err != nil { - t.Fatalf("[%s] Error setting extension: %v", test.name, err) - } - b, err := proto.Marshal(msg1) - if err != nil { - t.Fatalf("[%s] Error marshaling message: %v", test.name, err) - } - - // Unmarshal and read the merged proto. - msg2 := new(pb.OtherMessage) - err = proto.Unmarshal(b, msg2) - if err != nil { - t.Fatalf("[%s] Error unmarshaling message: %v", test.name, err) - } - e, err := proto.GetExtension(msg2, pb.E_RComplex) - if err != nil { - t.Fatalf("[%s] Error getting extension: %v", test.name, err) - } - ext := e.([]*pb.ComplexExtension) - if ext == nil { - t.Fatalf("[%s] Invalid extension", test.name) - } - if len(ext) != len(test.ext) { - t.Errorf("[%s] Wrong length of ComplexExtension: got: %v want: %v\n", test.name, len(ext), len(test.ext)) - } - for i := range test.ext { - if !proto.Equal(ext[i], test.ext[i]) { - t.Errorf("[%s] Wrong value for ComplexExtension[%d]: got: %v want: %v\n", test.name, i, ext[i], test.ext[i]) - } - } - } -} - -func TestUnmarshalRepeatingNonRepeatedExtension(t *testing.T) { - // We may see multiple instances of the same extension in the wire - // format. For example, the proto compiler may encode custom options in - // this way. Here, we verify that we merge the extensions together. - tests := []struct { - name string - ext []*pb.ComplexExtension - }{ - { - "two fields", - []*pb.ComplexExtension{ - {First: proto.Int32(7)}, - {Second: proto.Int32(11)}, - }, - }, - { - "repeated field", - []*pb.ComplexExtension{ - {Third: []int32{1000}}, - {Third: []int32{2000}}, - }, - }, - { - "two fields and repeated field", - []*pb.ComplexExtension{ - {Third: []int32{1000}}, - {First: proto.Int32(9)}, - {Second: proto.Int32(21)}, - {Third: []int32{2000}}, - }, - }, - } - for _, test := range tests { - var buf bytes.Buffer - var want pb.ComplexExtension - - // Generate a serialized representation of a repeated extension - // by catenating bytes together. - for i, e := range test.ext { - // Merge to create the wanted proto. - proto.Merge(&want, e) - - // serialize the message - msg := new(pb.OtherMessage) - err := proto.SetExtension(msg, pb.E_Complex, e) - if err != nil { - t.Fatalf("[%s] Error setting extension %d: %v", test.name, i, err) - } - b, err := proto.Marshal(msg) - if err != nil { - t.Fatalf("[%s] Error marshaling message %d: %v", test.name, i, err) - } - buf.Write(b) - } - - // Unmarshal and read the merged proto. - msg2 := new(pb.OtherMessage) - err := proto.Unmarshal(buf.Bytes(), msg2) - if err != nil { - t.Fatalf("[%s] Error unmarshaling message: %v", test.name, err) - } - e, err := proto.GetExtension(msg2, pb.E_Complex) - if err != nil { - t.Fatalf("[%s] Error getting extension: %v", test.name, err) - } - ext := e.(*pb.ComplexExtension) - if ext == nil { - t.Fatalf("[%s] Invalid extension", test.name) - } - if !proto.Equal(ext, &want) { - t.Errorf("[%s] Wrong value for ComplexExtension: got: %s want: %s\n", test.name, ext, &want) - } - } -} - -func TestClearAllExtensions(t *testing.T) { - // unregistered extension - desc := &proto.ExtensionDesc{ - ExtendedType: (*pb.MyMessage)(nil), - ExtensionType: (*bool)(nil), - Field: 101010100, - Name: "emptyextension", - Tag: "varint,0,opt", - } - m := &pb.MyMessage{} - if proto.HasExtension(m, desc) { - t.Errorf("proto.HasExtension(%s): got true, want false", proto.MarshalTextString(m)) - } - if err := proto.SetExtension(m, desc, proto.Bool(true)); err != nil { - t.Errorf("proto.SetExtension(m, desc, true): got error %q, want nil", err) - } - if !proto.HasExtension(m, desc) { - t.Errorf("proto.HasExtension(%s): got false, want true", proto.MarshalTextString(m)) - } - proto.ClearAllExtensions(m) - if proto.HasExtension(m, desc) { - t.Errorf("proto.HasExtension(%s): got true, want false", proto.MarshalTextString(m)) - } -} - -func TestMarshalRace(t *testing.T) { - ext := &pb.Ext{} - m := &pb.MyMessage{Count: proto.Int32(4)} - if err := proto.SetExtension(m, pb.E_Ext_More, ext); err != nil { - t.Fatalf("proto.SetExtension(m, desc, true): got error %q, want nil", err) - } - - b, err := proto.Marshal(m) - if err != nil { - t.Fatalf("Could not marshal message: %v", err) - } - if err := proto.Unmarshal(b, m); err != nil { - t.Fatalf("Could not unmarshal message: %v", err) - } - // after Unmarshal, the extension is in undecoded form. - // GetExtension will decode it lazily. Make sure this does - // not race against Marshal. - - var g errgroup.Group - for n := 3; n > 0; n-- { - g.Go(func() error { - _, err := proto.Marshal(m) - return err - }) - g.Go(func() error { - _, err := proto.GetExtension(m, pb.E_Ext_More) - return err - }) - } - if err := g.Wait(); err != nil { - t.Fatal(err) - } -} diff --git a/vendor/github.com/golang/protobuf/proto/map_test.go b/vendor/github.com/golang/protobuf/proto/map_test.go deleted file mode 100644 index b1e1529e..00000000 --- a/vendor/github.com/golang/protobuf/proto/map_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package proto_test - -import ( - "fmt" - "reflect" - "testing" - - "github.com/golang/protobuf/proto" - ppb "github.com/golang/protobuf/proto/proto3_proto" -) - -func TestMap(t *testing.T) { - var b []byte - fmt.Sscanf("a2010c0a044b657931120456616c31a201130a044b657932120556616c3261120456616c32a201240a044b6579330d05000000120556616c33621a0556616c3361120456616c331505000000a20100a201260a044b657934130a07536f6d6555524c1209536f6d655469746c651a08536e69707065743114", "%x", &b) - - var m ppb.Message - if err := proto.Unmarshal(b, &m); err != nil { - t.Fatalf("proto.Unmarshal error: %v", err) - } - - got := m.StringMap - want := map[string]string{ - "": "", - "Key1": "Val1", - "Key2": "Val2", - "Key3": "Val3", - "Key4": "", - } - - if !reflect.DeepEqual(got, want) { - t.Errorf("maps differ:\ngot %#v\nwant %#v", got, want) - } -} - -func marshalled() []byte { - m := &ppb.IntMaps{} - for i := 0; i < 1000; i++ { - m.Maps = append(m.Maps, &ppb.IntMap{ - Rtt: map[int32]int32{1: 2}, - }) - } - b, err := proto.Marshal(m) - if err != nil { - panic(fmt.Sprintf("Can't marshal %+v: %v", m, err)) - } - return b -} - -func BenchmarkConcurrentMapUnmarshal(b *testing.B) { - in := marshalled() - b.RunParallel(func(pb *testing.PB) { - for pb.Next() { - var out ppb.IntMaps - if err := proto.Unmarshal(in, &out); err != nil { - b.Errorf("Can't unmarshal ppb.IntMaps: %v", err) - } - } - }) -} - -func BenchmarkSequentialMapUnmarshal(b *testing.B) { - in := marshalled() - b.ResetTimer() - for i := 0; i < b.N; i++ { - var out ppb.IntMaps - if err := proto.Unmarshal(in, &out); err != nil { - b.Errorf("Can't unmarshal ppb.IntMaps: %v", err) - } - } -} diff --git a/vendor/github.com/golang/protobuf/proto/message_set_test.go b/vendor/github.com/golang/protobuf/proto/message_set_test.go deleted file mode 100644 index 2c170c5f..00000000 --- a/vendor/github.com/golang/protobuf/proto/message_set_test.go +++ /dev/null @@ -1,77 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2014 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package proto - -import ( - "bytes" - "testing" -) - -func TestUnmarshalMessageSetWithDuplicate(t *testing.T) { - // Check that a repeated message set entry will be concatenated. - in := &messageSet{ - Item: []*_MessageSet_Item{ - {TypeId: Int32(12345), Message: []byte("hoo")}, - {TypeId: Int32(12345), Message: []byte("hah")}, - }, - } - b, err := Marshal(in) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - t.Logf("Marshaled bytes: %q", b) - - var extensions XXX_InternalExtensions - if err := UnmarshalMessageSet(b, &extensions); err != nil { - t.Fatalf("UnmarshalMessageSet: %v", err) - } - ext, ok := extensions.p.extensionMap[12345] - if !ok { - t.Fatalf("Didn't retrieve extension 12345; map is %v", extensions.p.extensionMap) - } - // Skip wire type/field number and length varints. - got := skipVarint(skipVarint(ext.enc)) - if want := []byte("hoohah"); !bytes.Equal(got, want) { - t.Errorf("Combined extension is %q, want %q", got, want) - } -} - -func TestMarshalMessageSetJSON_UnknownType(t *testing.T) { - extMap := map[int32]Extension{12345: Extension{}} - got, err := MarshalMessageSetJSON(extMap) - if err != nil { - t.Fatalf("MarshalMessageSetJSON: %v", err) - } - if want := []byte("{}"); !bytes.Equal(got, want) { - t.Errorf("MarshalMessageSetJSON(%v) = %q, want %q", extMap, got, want) - } -} diff --git a/vendor/github.com/golang/protobuf/proto/proto3_test.go b/vendor/github.com/golang/protobuf/proto/proto3_test.go deleted file mode 100644 index 73eed6c0..00000000 --- a/vendor/github.com/golang/protobuf/proto/proto3_test.go +++ /dev/null @@ -1,151 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2014 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package proto_test - -import ( - "bytes" - "testing" - - "github.com/golang/protobuf/proto" - pb "github.com/golang/protobuf/proto/proto3_proto" - tpb "github.com/golang/protobuf/proto/test_proto" -) - -func TestProto3ZeroValues(t *testing.T) { - tests := []struct { - desc string - m proto.Message - }{ - {"zero message", &pb.Message{}}, - {"empty bytes field", &pb.Message{Data: []byte{}}}, - } - for _, test := range tests { - b, err := proto.Marshal(test.m) - if err != nil { - t.Errorf("%s: proto.Marshal: %v", test.desc, err) - continue - } - if len(b) > 0 { - t.Errorf("%s: Encoding is non-empty: %q", test.desc, b) - } - } -} - -func TestRoundTripProto3(t *testing.T) { - m := &pb.Message{ - Name: "David", // (2 | 1<<3): 0x0a 0x05 "David" - Hilarity: pb.Message_PUNS, // (0 | 2<<3): 0x10 0x01 - HeightInCm: 178, // (0 | 3<<3): 0x18 0xb2 0x01 - Data: []byte("roboto"), // (2 | 4<<3): 0x20 0x06 "roboto" - ResultCount: 47, // (0 | 7<<3): 0x38 0x2f - TrueScotsman: true, // (0 | 8<<3): 0x40 0x01 - Score: 8.1, // (5 | 9<<3): 0x4d <8.1> - - Key: []uint64{1, 0xdeadbeef}, - Nested: &pb.Nested{ - Bunny: "Monty", - }, - } - t.Logf(" m: %v", m) - - b, err := proto.Marshal(m) - if err != nil { - t.Fatalf("proto.Marshal: %v", err) - } - t.Logf(" b: %q", b) - - m2 := new(pb.Message) - if err := proto.Unmarshal(b, m2); err != nil { - t.Fatalf("proto.Unmarshal: %v", err) - } - t.Logf("m2: %v", m2) - - if !proto.Equal(m, m2) { - t.Errorf("proto.Equal returned false:\n m: %v\nm2: %v", m, m2) - } -} - -func TestGettersForBasicTypesExist(t *testing.T) { - var m pb.Message - if got := m.GetNested().GetBunny(); got != "" { - t.Errorf("m.GetNested().GetBunny() = %q, want empty string", got) - } - if got := m.GetNested().GetCute(); got { - t.Errorf("m.GetNested().GetCute() = %t, want false", got) - } -} - -func TestProto3SetDefaults(t *testing.T) { - in := &pb.Message{ - Terrain: map[string]*pb.Nested{ - "meadow": new(pb.Nested), - }, - Proto2Field: new(tpb.SubDefaults), - Proto2Value: map[string]*tpb.SubDefaults{ - "badlands": new(tpb.SubDefaults), - }, - } - - got := proto.Clone(in).(*pb.Message) - proto.SetDefaults(got) - - // There are no defaults in proto3. Everything should be the zero value, but - // we need to remember to set defaults for nested proto2 messages. - want := &pb.Message{ - Terrain: map[string]*pb.Nested{ - "meadow": new(pb.Nested), - }, - Proto2Field: &tpb.SubDefaults{N: proto.Int64(7)}, - Proto2Value: map[string]*tpb.SubDefaults{ - "badlands": &tpb.SubDefaults{N: proto.Int64(7)}, - }, - } - - if !proto.Equal(got, want) { - t.Errorf("with in = %v\nproto.SetDefaults(in) =>\ngot %v\nwant %v", in, got, want) - } -} - -func TestUnknownFieldPreservation(t *testing.T) { - b1 := "\x0a\x05David" // Known tag 1 - b2 := "\xc2\x0c\x06Google" // Unknown tag 200 - b := []byte(b1 + b2) - - m := new(pb.Message) - if err := proto.Unmarshal(b, m); err != nil { - t.Fatalf("proto.Unmarshal: %v", err) - } - - if !bytes.Equal(m.XXX_unrecognized, []byte(b2)) { - t.Fatalf("mismatching unknown fields:\ngot %q\nwant %q", m.XXX_unrecognized, b2) - } -} diff --git a/vendor/github.com/golang/protobuf/proto/size2_test.go b/vendor/github.com/golang/protobuf/proto/size2_test.go deleted file mode 100644 index 7846b061..00000000 --- a/vendor/github.com/golang/protobuf/proto/size2_test.go +++ /dev/null @@ -1,63 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2012 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package proto - -import ( - "testing" -) - -// This is a separate file and package from size_test.go because that one uses -// generated messages and thus may not be in package proto without having a circular -// dependency, whereas this file tests unexported details of size.go. - -func TestVarintSize(t *testing.T) { - // Check the edge cases carefully. - testCases := []struct { - n uint64 - size int - }{ - {0, 1}, - {1, 1}, - {127, 1}, - {128, 2}, - {16383, 2}, - {16384, 3}, - {1<<63 - 1, 9}, - {1 << 63, 10}, - } - for _, tc := range testCases { - size := SizeVarint(tc.n) - if size != tc.size { - t.Errorf("sizeVarint(%d) = %d, want %d", tc.n, size, tc.size) - } - } -} diff --git a/vendor/github.com/golang/protobuf/proto/size_test.go b/vendor/github.com/golang/protobuf/proto/size_test.go deleted file mode 100644 index 3abac418..00000000 --- a/vendor/github.com/golang/protobuf/proto/size_test.go +++ /dev/null @@ -1,191 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2012 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package proto_test - -import ( - "log" - "strings" - "testing" - - . "github.com/golang/protobuf/proto" - proto3pb "github.com/golang/protobuf/proto/proto3_proto" - pb "github.com/golang/protobuf/proto/test_proto" -) - -var messageWithExtension1 = &pb.MyMessage{Count: Int32(7)} - -// messageWithExtension2 is in equal_test.go. -var messageWithExtension3 = &pb.MyMessage{Count: Int32(8)} - -func init() { - if err := SetExtension(messageWithExtension1, pb.E_Ext_More, &pb.Ext{Data: String("Abbott")}); err != nil { - log.Panicf("SetExtension: %v", err) - } - if err := SetExtension(messageWithExtension3, pb.E_Ext_More, &pb.Ext{Data: String("Costello")}); err != nil { - log.Panicf("SetExtension: %v", err) - } - - // Force messageWithExtension3 to have the extension encoded. - Marshal(messageWithExtension3) - -} - -// non-pointer custom message -type nonptrMessage struct{} - -func (m nonptrMessage) ProtoMessage() {} -func (m nonptrMessage) Reset() {} -func (m nonptrMessage) String() string { return "" } - -func (m nonptrMessage) Marshal() ([]byte, error) { - return []byte{42}, nil -} - -// custom message embedding a proto.Message -type messageWithEmbedding struct { - *pb.OtherMessage -} - -func (m *messageWithEmbedding) ProtoMessage() {} -func (m *messageWithEmbedding) Reset() {} -func (m *messageWithEmbedding) String() string { return "" } - -func (m *messageWithEmbedding) Marshal() ([]byte, error) { - return []byte{42}, nil -} - -var SizeTests = []struct { - desc string - pb Message -}{ - {"empty", &pb.OtherMessage{}}, - // Basic types. - {"bool", &pb.Defaults{F_Bool: Bool(true)}}, - {"int32", &pb.Defaults{F_Int32: Int32(12)}}, - {"negative int32", &pb.Defaults{F_Int32: Int32(-1)}}, - {"small int64", &pb.Defaults{F_Int64: Int64(1)}}, - {"big int64", &pb.Defaults{F_Int64: Int64(1 << 20)}}, - {"negative int64", &pb.Defaults{F_Int64: Int64(-1)}}, - {"fixed32", &pb.Defaults{F_Fixed32: Uint32(71)}}, - {"fixed64", &pb.Defaults{F_Fixed64: Uint64(72)}}, - {"uint32", &pb.Defaults{F_Uint32: Uint32(123)}}, - {"uint64", &pb.Defaults{F_Uint64: Uint64(124)}}, - {"float", &pb.Defaults{F_Float: Float32(12.6)}}, - {"double", &pb.Defaults{F_Double: Float64(13.9)}}, - {"string", &pb.Defaults{F_String: String("niles")}}, - {"bytes", &pb.Defaults{F_Bytes: []byte("wowsa")}}, - {"bytes, empty", &pb.Defaults{F_Bytes: []byte{}}}, - {"sint32", &pb.Defaults{F_Sint32: Int32(65)}}, - {"sint64", &pb.Defaults{F_Sint64: Int64(67)}}, - {"enum", &pb.Defaults{F_Enum: pb.Defaults_BLUE.Enum()}}, - // Repeated. - {"empty repeated bool", &pb.MoreRepeated{Bools: []bool{}}}, - {"repeated bool", &pb.MoreRepeated{Bools: []bool{false, true, true, false}}}, - {"packed repeated bool", &pb.MoreRepeated{BoolsPacked: []bool{false, true, true, false, true, true, true}}}, - {"repeated int32", &pb.MoreRepeated{Ints: []int32{1, 12203, 1729, -1}}}, - {"repeated int32 packed", &pb.MoreRepeated{IntsPacked: []int32{1, 12203, 1729}}}, - {"repeated int64 packed", &pb.MoreRepeated{Int64SPacked: []int64{ - // Need enough large numbers to verify that the header is counting the number of bytes - // for the field, not the number of elements. - 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, - 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, - }}}, - {"repeated string", &pb.MoreRepeated{Strings: []string{"r", "ken", "gri"}}}, - {"repeated fixed", &pb.MoreRepeated{Fixeds: []uint32{1, 2, 3, 4}}}, - // Nested. - {"nested", &pb.OldMessage{Nested: &pb.OldMessage_Nested{Name: String("whatever")}}}, - {"group", &pb.GroupOld{G: &pb.GroupOld_G{X: Int32(12345)}}}, - // Other things. - {"unrecognized", &pb.MoreRepeated{XXX_unrecognized: []byte{13<<3 | 0, 4}}}, - {"extension (unencoded)", messageWithExtension1}, - {"extension (encoded)", messageWithExtension3}, - // proto3 message - {"proto3 empty", &proto3pb.Message{}}, - {"proto3 bool", &proto3pb.Message{TrueScotsman: true}}, - {"proto3 int64", &proto3pb.Message{ResultCount: 1}}, - {"proto3 uint32", &proto3pb.Message{HeightInCm: 123}}, - {"proto3 float", &proto3pb.Message{Score: 12.6}}, - {"proto3 string", &proto3pb.Message{Name: "Snezana"}}, - {"proto3 bytes", &proto3pb.Message{Data: []byte("wowsa")}}, - {"proto3 bytes, empty", &proto3pb.Message{Data: []byte{}}}, - {"proto3 enum", &proto3pb.Message{Hilarity: proto3pb.Message_PUNS}}, - {"proto3 map field with empty bytes", &proto3pb.MessageWithMap{ByteMapping: map[bool][]byte{false: []byte{}}}}, - - {"map field", &pb.MessageWithMap{NameMapping: map[int32]string{1: "Rob", 7: "Andrew"}}}, - {"map field with message", &pb.MessageWithMap{MsgMapping: map[int64]*pb.FloatingPoint{0x7001: &pb.FloatingPoint{F: Float64(2.0)}}}}, - {"map field with bytes", &pb.MessageWithMap{ByteMapping: map[bool][]byte{true: []byte("this time for sure")}}}, - {"map field with empty bytes", &pb.MessageWithMap{ByteMapping: map[bool][]byte{true: []byte{}}}}, - - {"map field with big entry", &pb.MessageWithMap{NameMapping: map[int32]string{8: strings.Repeat("x", 125)}}}, - {"map field with big key and val", &pb.MessageWithMap{StrToStr: map[string]string{strings.Repeat("x", 70): strings.Repeat("y", 70)}}}, - {"map field with big numeric key", &pb.MessageWithMap{NameMapping: map[int32]string{0xf00d: "om nom nom"}}}, - - {"oneof not set", &pb.Oneof{}}, - {"oneof bool", &pb.Oneof{Union: &pb.Oneof_F_Bool{true}}}, - {"oneof zero int32", &pb.Oneof{Union: &pb.Oneof_F_Int32{0}}}, - {"oneof big int32", &pb.Oneof{Union: &pb.Oneof_F_Int32{1 << 20}}}, - {"oneof int64", &pb.Oneof{Union: &pb.Oneof_F_Int64{42}}}, - {"oneof fixed32", &pb.Oneof{Union: &pb.Oneof_F_Fixed32{43}}}, - {"oneof fixed64", &pb.Oneof{Union: &pb.Oneof_F_Fixed64{44}}}, - {"oneof uint32", &pb.Oneof{Union: &pb.Oneof_F_Uint32{45}}}, - {"oneof uint64", &pb.Oneof{Union: &pb.Oneof_F_Uint64{46}}}, - {"oneof float", &pb.Oneof{Union: &pb.Oneof_F_Float{47.1}}}, - {"oneof double", &pb.Oneof{Union: &pb.Oneof_F_Double{48.9}}}, - {"oneof string", &pb.Oneof{Union: &pb.Oneof_F_String{"Rhythmic Fman"}}}, - {"oneof bytes", &pb.Oneof{Union: &pb.Oneof_F_Bytes{[]byte("let go")}}}, - {"oneof sint32", &pb.Oneof{Union: &pb.Oneof_F_Sint32{50}}}, - {"oneof sint64", &pb.Oneof{Union: &pb.Oneof_F_Sint64{51}}}, - {"oneof enum", &pb.Oneof{Union: &pb.Oneof_F_Enum{pb.MyMessage_BLUE}}}, - {"message for oneof", &pb.GoTestField{Label: String("k"), Type: String("v")}}, - {"oneof message", &pb.Oneof{Union: &pb.Oneof_F_Message{&pb.GoTestField{Label: String("k"), Type: String("v")}}}}, - {"oneof group", &pb.Oneof{Union: &pb.Oneof_FGroup{&pb.Oneof_F_Group{X: Int32(52)}}}}, - {"oneof largest tag", &pb.Oneof{Union: &pb.Oneof_F_Largest_Tag{1}}}, - {"multiple oneofs", &pb.Oneof{Union: &pb.Oneof_F_Int32{1}, Tormato: &pb.Oneof_Value{2}}}, - - {"non-pointer message", nonptrMessage{}}, - {"custom message with embedding", &messageWithEmbedding{&pb.OtherMessage{}}}, -} - -func TestSize(t *testing.T) { - for _, tc := range SizeTests { - size := Size(tc.pb) - b, err := Marshal(tc.pb) - if err != nil { - t.Errorf("%v: Marshal failed: %v", tc.desc, err) - continue - } - if size != len(b) { - t.Errorf("%v: Size(%v) = %d, want %d", tc.desc, tc.pb, size, len(b)) - t.Logf("%v: bytes: %#v", tc.desc, b) - } - } -} diff --git a/vendor/github.com/golang/protobuf/proto/text_parser_test.go b/vendor/github.com/golang/protobuf/proto/text_parser_test.go deleted file mode 100644 index a8198087..00000000 --- a/vendor/github.com/golang/protobuf/proto/text_parser_test.go +++ /dev/null @@ -1,706 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2010 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package proto_test - -import ( - "fmt" - "math" - "testing" - - . "github.com/golang/protobuf/proto" - proto3pb "github.com/golang/protobuf/proto/proto3_proto" - . "github.com/golang/protobuf/proto/test_proto" -) - -type UnmarshalTextTest struct { - in string - err string // if "", no error expected - out *MyMessage -} - -func buildExtStructTest(text string) UnmarshalTextTest { - msg := &MyMessage{ - Count: Int32(42), - } - SetExtension(msg, E_Ext_More, &Ext{ - Data: String("Hello, world!"), - }) - return UnmarshalTextTest{in: text, out: msg} -} - -func buildExtDataTest(text string) UnmarshalTextTest { - msg := &MyMessage{ - Count: Int32(42), - } - SetExtension(msg, E_Ext_Text, String("Hello, world!")) - SetExtension(msg, E_Ext_Number, Int32(1729)) - return UnmarshalTextTest{in: text, out: msg} -} - -func buildExtRepStringTest(text string) UnmarshalTextTest { - msg := &MyMessage{ - Count: Int32(42), - } - if err := SetExtension(msg, E_Greeting, []string{"bula", "hola"}); err != nil { - panic(err) - } - return UnmarshalTextTest{in: text, out: msg} -} - -var unMarshalTextTests = []UnmarshalTextTest{ - // Basic - { - in: " count:42\n name:\"Dave\" ", - out: &MyMessage{ - Count: Int32(42), - Name: String("Dave"), - }, - }, - - // Empty quoted string - { - in: `count:42 name:""`, - out: &MyMessage{ - Count: Int32(42), - Name: String(""), - }, - }, - - // Quoted string concatenation with double quotes - { - in: `count:42 name: "My name is "` + "\n" + `"elsewhere"`, - out: &MyMessage{ - Count: Int32(42), - Name: String("My name is elsewhere"), - }, - }, - - // Quoted string concatenation with single quotes - { - in: "count:42 name: 'My name is '\n'elsewhere'", - out: &MyMessage{ - Count: Int32(42), - Name: String("My name is elsewhere"), - }, - }, - - // Quoted string concatenations with mixed quotes - { - in: "count:42 name: 'My name is '\n\"elsewhere\"", - out: &MyMessage{ - Count: Int32(42), - Name: String("My name is elsewhere"), - }, - }, - { - in: "count:42 name: \"My name is \"\n'elsewhere'", - out: &MyMessage{ - Count: Int32(42), - Name: String("My name is elsewhere"), - }, - }, - - // Quoted string with escaped apostrophe - { - in: `count:42 name: "HOLIDAY - New Year\'s Day"`, - out: &MyMessage{ - Count: Int32(42), - Name: String("HOLIDAY - New Year's Day"), - }, - }, - - // Quoted string with single quote - { - in: `count:42 name: 'Roger "The Ramster" Ramjet'`, - out: &MyMessage{ - Count: Int32(42), - Name: String(`Roger "The Ramster" Ramjet`), - }, - }, - - // Quoted string with all the accepted special characters from the C++ test - { - in: `count:42 name: ` + "\"\\\"A string with \\' characters \\n and \\r newlines and \\t tabs and \\001 slashes \\\\ and multiple spaces\"", - out: &MyMessage{ - Count: Int32(42), - Name: String("\"A string with ' characters \n and \r newlines and \t tabs and \001 slashes \\ and multiple spaces"), - }, - }, - - // Quoted string with quoted backslash - { - in: `count:42 name: "\\'xyz"`, - out: &MyMessage{ - Count: Int32(42), - Name: String(`\'xyz`), - }, - }, - - // Quoted string with UTF-8 bytes. - { - in: "count:42 name: '\303\277\302\201\x00\xAB\xCD\xEF'", - out: &MyMessage{ - Count: Int32(42), - Name: String("\303\277\302\201\x00\xAB\xCD\xEF"), - }, - }, - - // Quoted string with unicode escapes. - { - in: `count: 42 name: "\u0047\U00000047\uffff\U0010ffff"`, - out: &MyMessage{ - Count: Int32(42), - Name: String("GG\uffff\U0010ffff"), - }, - }, - - // Bad quoted string - { - in: `inner: < host: "\0" >` + "\n", - err: `line 1.15: invalid quoted string "\0": \0 requires 2 following digits`, - }, - - // Bad \u escape - { - in: `count: 42 name: "\u000"`, - err: `line 1.16: invalid quoted string "\u000": \u requires 4 following digits`, - }, - - // Bad \U escape - { - in: `count: 42 name: "\U0000000"`, - err: `line 1.16: invalid quoted string "\U0000000": \U requires 8 following digits`, - }, - - // Bad \U escape - { - in: `count: 42 name: "\xxx"`, - err: `line 1.16: invalid quoted string "\xxx": \xxx contains non-hexadecimal digits`, - }, - - // Number too large for int64 - { - in: "count: 1 others { key: 123456789012345678901 }", - err: "line 1.23: invalid int64: 123456789012345678901", - }, - - // Number too large for int32 - { - in: "count: 1234567890123", - err: "line 1.7: invalid int32: 1234567890123", - }, - - // Number in hexadecimal - { - in: "count: 0x2beef", - out: &MyMessage{ - Count: Int32(0x2beef), - }, - }, - - // Number in octal - { - in: "count: 024601", - out: &MyMessage{ - Count: Int32(024601), - }, - }, - - // Floating point number with "f" suffix - { - in: "count: 4 others:< weight: 17.0f >", - out: &MyMessage{ - Count: Int32(4), - Others: []*OtherMessage{ - { - Weight: Float32(17), - }, - }, - }, - }, - - // Floating point positive infinity - { - in: "count: 4 bigfloat: inf", - out: &MyMessage{ - Count: Int32(4), - Bigfloat: Float64(math.Inf(1)), - }, - }, - - // Floating point negative infinity - { - in: "count: 4 bigfloat: -inf", - out: &MyMessage{ - Count: Int32(4), - Bigfloat: Float64(math.Inf(-1)), - }, - }, - - // Number too large for float32 - { - in: "others:< weight: 12345678901234567890123456789012345678901234567890 >", - err: "line 1.17: invalid float32: 12345678901234567890123456789012345678901234567890", - }, - - // Number posing as a quoted string - { - in: `inner: < host: 12 >` + "\n", - err: `line 1.15: invalid string: 12`, - }, - - // Quoted string posing as int32 - { - in: `count: "12"`, - err: `line 1.7: invalid int32: "12"`, - }, - - // Quoted string posing a float32 - { - in: `others:< weight: "17.4" >`, - err: `line 1.17: invalid float32: "17.4"`, - }, - - // unclosed bracket doesn't cause infinite loop - { - in: `[`, - err: `line 1.0: unclosed type_url or extension name`, - }, - - // Enum - { - in: `count:42 bikeshed: BLUE`, - out: &MyMessage{ - Count: Int32(42), - Bikeshed: MyMessage_BLUE.Enum(), - }, - }, - - // Repeated field - { - in: `count:42 pet: "horsey" pet:"bunny"`, - out: &MyMessage{ - Count: Int32(42), - Pet: []string{"horsey", "bunny"}, - }, - }, - - // Repeated field with list notation - { - in: `count:42 pet: ["horsey", "bunny"]`, - out: &MyMessage{ - Count: Int32(42), - Pet: []string{"horsey", "bunny"}, - }, - }, - - // Repeated message with/without colon and <>/{} - { - in: `count:42 others:{} others{} others:<> others:{}`, - out: &MyMessage{ - Count: Int32(42), - Others: []*OtherMessage{ - {}, - {}, - {}, - {}, - }, - }, - }, - - // Missing colon for inner message - { - in: `count:42 inner < host: "cauchy.syd" >`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("cauchy.syd"), - }, - }, - }, - - // Missing colon for string field - { - in: `name "Dave"`, - err: `line 1.5: expected ':', found "\"Dave\""`, - }, - - // Missing colon for int32 field - { - in: `count 42`, - err: `line 1.6: expected ':', found "42"`, - }, - - // Missing required field - { - in: `name: "Pawel"`, - err: fmt.Sprintf(`proto: required field "%T.count" not set`, MyMessage{}), - out: &MyMessage{ - Name: String("Pawel"), - }, - }, - - // Missing required field in a required submessage - { - in: `count: 42 we_must_go_deeper < leo_finally_won_an_oscar <> >`, - err: fmt.Sprintf(`proto: required field "%T.host" not set`, InnerMessage{}), - out: &MyMessage{ - Count: Int32(42), - WeMustGoDeeper: &RequiredInnerMessage{LeoFinallyWonAnOscar: &InnerMessage{}}, - }, - }, - - // Repeated non-repeated field - { - in: `name: "Rob" name: "Russ"`, - err: `line 1.12: non-repeated field "name" was repeated`, - }, - - // Group - { - in: `count: 17 SomeGroup { group_field: 12 }`, - out: &MyMessage{ - Count: Int32(17), - Somegroup: &MyMessage_SomeGroup{ - GroupField: Int32(12), - }, - }, - }, - - // Semicolon between fields - { - in: `count:3;name:"Calvin"`, - out: &MyMessage{ - Count: Int32(3), - Name: String("Calvin"), - }, - }, - // Comma between fields - { - in: `count:4,name:"Ezekiel"`, - out: &MyMessage{ - Count: Int32(4), - Name: String("Ezekiel"), - }, - }, - - // Boolean false - { - in: `count:42 inner { host: "example.com" connected: false }`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("example.com"), - Connected: Bool(false), - }, - }, - }, - // Boolean true - { - in: `count:42 inner { host: "example.com" connected: true }`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("example.com"), - Connected: Bool(true), - }, - }, - }, - // Boolean 0 - { - in: `count:42 inner { host: "example.com" connected: 0 }`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("example.com"), - Connected: Bool(false), - }, - }, - }, - // Boolean 1 - { - in: `count:42 inner { host: "example.com" connected: 1 }`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("example.com"), - Connected: Bool(true), - }, - }, - }, - // Boolean f - { - in: `count:42 inner { host: "example.com" connected: f }`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("example.com"), - Connected: Bool(false), - }, - }, - }, - // Boolean t - { - in: `count:42 inner { host: "example.com" connected: t }`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("example.com"), - Connected: Bool(true), - }, - }, - }, - // Boolean False - { - in: `count:42 inner { host: "example.com" connected: False }`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("example.com"), - Connected: Bool(false), - }, - }, - }, - // Boolean True - { - in: `count:42 inner { host: "example.com" connected: True }`, - out: &MyMessage{ - Count: Int32(42), - Inner: &InnerMessage{ - Host: String("example.com"), - Connected: Bool(true), - }, - }, - }, - - // Extension - buildExtStructTest(`count: 42 [test_proto.Ext.more]:`), - buildExtStructTest(`count: 42 [test_proto.Ext.more] {data:"Hello, world!"}`), - buildExtDataTest(`count: 42 [test_proto.Ext.text]:"Hello, world!" [test_proto.Ext.number]:1729`), - buildExtRepStringTest(`count: 42 [test_proto.greeting]:"bula" [test_proto.greeting]:"hola"`), - - // Big all-in-one - { - in: "count:42 # Meaning\n" + - `name:"Dave" ` + - `quote:"\"I didn't want to go.\"" ` + - `pet:"bunny" ` + - `pet:"kitty" ` + - `pet:"horsey" ` + - `inner:<` + - ` host:"footrest.syd" ` + - ` port:7001 ` + - ` connected:true ` + - `> ` + - `others:<` + - ` key:3735928559 ` + - ` value:"\x01A\a\f" ` + - `> ` + - `others:<` + - " weight:58.9 # Atomic weight of Co\n" + - ` inner:<` + - ` host:"lesha.mtv" ` + - ` port:8002 ` + - ` >` + - `>`, - out: &MyMessage{ - Count: Int32(42), - Name: String("Dave"), - Quote: String(`"I didn't want to go."`), - Pet: []string{"bunny", "kitty", "horsey"}, - Inner: &InnerMessage{ - Host: String("footrest.syd"), - Port: Int32(7001), - Connected: Bool(true), - }, - Others: []*OtherMessage{ - { - Key: Int64(3735928559), - Value: []byte{0x1, 'A', '\a', '\f'}, - }, - { - Weight: Float32(58.9), - Inner: &InnerMessage{ - Host: String("lesha.mtv"), - Port: Int32(8002), - }, - }, - }, - }, - }, -} - -func TestUnmarshalText(t *testing.T) { - for i, test := range unMarshalTextTests { - pb := new(MyMessage) - err := UnmarshalText(test.in, pb) - if test.err == "" { - // We don't expect failure. - if err != nil { - t.Errorf("Test %d: Unexpected error: %v", i, err) - } else if !Equal(pb, test.out) { - t.Errorf("Test %d: Incorrect populated \nHave: %v\nWant: %v", - i, pb, test.out) - } - } else { - // We do expect failure. - if err == nil { - t.Errorf("Test %d: Didn't get expected error: %v", i, test.err) - } else if err.Error() != test.err { - t.Errorf("Test %d: Incorrect error.\nHave: %v\nWant: %v", - i, err.Error(), test.err) - } else if _, ok := err.(*RequiredNotSetError); ok && test.out != nil && !Equal(pb, test.out) { - t.Errorf("Test %d: Incorrect populated \nHave: %v\nWant: %v", - i, pb, test.out) - } - } - } -} - -func TestUnmarshalTextCustomMessage(t *testing.T) { - msg := &textMessage{} - if err := UnmarshalText("custom", msg); err != nil { - t.Errorf("Unexpected error from custom unmarshal: %v", err) - } - if UnmarshalText("not custom", msg) == nil { - t.Errorf("Didn't get expected error from custom unmarshal") - } -} - -// Regression test; this caused a panic. -func TestRepeatedEnum(t *testing.T) { - pb := new(RepeatedEnum) - if err := UnmarshalText("color: RED", pb); err != nil { - t.Fatal(err) - } - exp := &RepeatedEnum{ - Color: []RepeatedEnum_Color{RepeatedEnum_RED}, - } - if !Equal(pb, exp) { - t.Errorf("Incorrect populated \nHave: %v\nWant: %v", pb, exp) - } -} - -func TestProto3TextParsing(t *testing.T) { - m := new(proto3pb.Message) - const in = `name: "Wallace" true_scotsman: true` - want := &proto3pb.Message{ - Name: "Wallace", - TrueScotsman: true, - } - if err := UnmarshalText(in, m); err != nil { - t.Fatal(err) - } - if !Equal(m, want) { - t.Errorf("\n got %v\nwant %v", m, want) - } -} - -func TestMapParsing(t *testing.T) { - m := new(MessageWithMap) - const in = `name_mapping: name_mapping:` + - `msg_mapping:,>` + // separating commas are okay - `msg_mapping>` + // no colon after "value" - `msg_mapping:>` + // omitted key - `msg_mapping:` + // omitted value - `byte_mapping:` + - `byte_mapping:<>` // omitted key and value - want := &MessageWithMap{ - NameMapping: map[int32]string{ - 1: "Beatles", - 1234: "Feist", - }, - MsgMapping: map[int64]*FloatingPoint{ - -4: {F: Float64(2.0)}, - -2: {F: Float64(4.0)}, - 0: {F: Float64(5.0)}, - 1: nil, - }, - ByteMapping: map[bool][]byte{ - false: nil, - true: []byte("so be it"), - }, - } - if err := UnmarshalText(in, m); err != nil { - t.Fatal(err) - } - if !Equal(m, want) { - t.Errorf("\n got %v\nwant %v", m, want) - } -} - -func TestOneofParsing(t *testing.T) { - const in = `name:"Shrek"` - m := new(Communique) - want := &Communique{Union: &Communique_Name{"Shrek"}} - if err := UnmarshalText(in, m); err != nil { - t.Fatal(err) - } - if !Equal(m, want) { - t.Errorf("\n got %v\nwant %v", m, want) - } - - const inOverwrite = `name:"Shrek" number:42` - m = new(Communique) - testErr := "line 1.13: field 'number' would overwrite already parsed oneof 'Union'" - if err := UnmarshalText(inOverwrite, m); err == nil { - t.Errorf("TestOneofParsing: Didn't get expected error: %v", testErr) - } else if err.Error() != testErr { - t.Errorf("TestOneofParsing: Incorrect error.\nHave: %v\nWant: %v", - err.Error(), testErr) - } - -} - -var benchInput string - -func init() { - benchInput = "count: 4\n" - for i := 0; i < 1000; i++ { - benchInput += "pet: \"fido\"\n" - } - - // Check it is valid input. - pb := new(MyMessage) - err := UnmarshalText(benchInput, pb) - if err != nil { - panic("Bad benchmark input: " + err.Error()) - } -} - -func BenchmarkUnmarshalText(b *testing.B) { - pb := new(MyMessage) - for i := 0; i < b.N; i++ { - UnmarshalText(benchInput, pb) - } - b.SetBytes(int64(len(benchInput))) -} diff --git a/vendor/github.com/golang/protobuf/proto/text_test.go b/vendor/github.com/golang/protobuf/proto/text_test.go deleted file mode 100644 index 3c8b033c..00000000 --- a/vendor/github.com/golang/protobuf/proto/text_test.go +++ /dev/null @@ -1,518 +0,0 @@ -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2010 The Go Authors. All rights reserved. -// https://github.com/golang/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package proto_test - -import ( - "bytes" - "errors" - "io/ioutil" - "math" - "strings" - "sync" - "testing" - - "github.com/golang/protobuf/proto" - - proto3pb "github.com/golang/protobuf/proto/proto3_proto" - pb "github.com/golang/protobuf/proto/test_proto" - anypb "github.com/golang/protobuf/ptypes/any" -) - -// textMessage implements the methods that allow it to marshal and unmarshal -// itself as text. -type textMessage struct { -} - -func (*textMessage) MarshalText() ([]byte, error) { - return []byte("custom"), nil -} - -func (*textMessage) UnmarshalText(bytes []byte) error { - if string(bytes) != "custom" { - return errors.New("expected 'custom'") - } - return nil -} - -func (*textMessage) Reset() {} -func (*textMessage) String() string { return "" } -func (*textMessage) ProtoMessage() {} - -func newTestMessage() *pb.MyMessage { - msg := &pb.MyMessage{ - Count: proto.Int32(42), - Name: proto.String("Dave"), - Quote: proto.String(`"I didn't want to go."`), - Pet: []string{"bunny", "kitty", "horsey"}, - Inner: &pb.InnerMessage{ - Host: proto.String("footrest.syd"), - Port: proto.Int32(7001), - Connected: proto.Bool(true), - }, - Others: []*pb.OtherMessage{ - { - Key: proto.Int64(0xdeadbeef), - Value: []byte{1, 65, 7, 12}, - }, - { - Weight: proto.Float32(6.022), - Inner: &pb.InnerMessage{ - Host: proto.String("lesha.mtv"), - Port: proto.Int32(8002), - }, - }, - }, - Bikeshed: pb.MyMessage_BLUE.Enum(), - Somegroup: &pb.MyMessage_SomeGroup{ - GroupField: proto.Int32(8), - }, - // One normally wouldn't do this. - // This is an undeclared tag 13, as a varint (wire type 0) with value 4. - XXX_unrecognized: []byte{13<<3 | 0, 4}, - } - ext := &pb.Ext{ - Data: proto.String("Big gobs for big rats"), - } - if err := proto.SetExtension(msg, pb.E_Ext_More, ext); err != nil { - panic(err) - } - greetings := []string{"adg", "easy", "cow"} - if err := proto.SetExtension(msg, pb.E_Greeting, greetings); err != nil { - panic(err) - } - - // Add an unknown extension. We marshal a pb.Ext, and fake the ID. - b, err := proto.Marshal(&pb.Ext{Data: proto.String("3G skiing")}) - if err != nil { - panic(err) - } - b = append(proto.EncodeVarint(201<<3|proto.WireBytes), b...) - proto.SetRawExtension(msg, 201, b) - - // Extensions can be plain fields, too, so let's test that. - b = append(proto.EncodeVarint(202<<3|proto.WireVarint), 19) - proto.SetRawExtension(msg, 202, b) - - return msg -} - -const text = `count: 42 -name: "Dave" -quote: "\"I didn't want to go.\"" -pet: "bunny" -pet: "kitty" -pet: "horsey" -inner: < - host: "footrest.syd" - port: 7001 - connected: true -> -others: < - key: 3735928559 - value: "\001A\007\014" -> -others: < - weight: 6.022 - inner: < - host: "lesha.mtv" - port: 8002 - > -> -bikeshed: BLUE -SomeGroup { - group_field: 8 -} -/* 2 unknown bytes */ -13: 4 -[test_proto.Ext.more]: < - data: "Big gobs for big rats" -> -[test_proto.greeting]: "adg" -[test_proto.greeting]: "easy" -[test_proto.greeting]: "cow" -/* 13 unknown bytes */ -201: "\t3G skiing" -/* 3 unknown bytes */ -202: 19 -` - -func TestMarshalText(t *testing.T) { - buf := new(bytes.Buffer) - if err := proto.MarshalText(buf, newTestMessage()); err != nil { - t.Fatalf("proto.MarshalText: %v", err) - } - s := buf.String() - if s != text { - t.Errorf("Got:\n===\n%v===\nExpected:\n===\n%v===\n", s, text) - } -} - -func TestMarshalTextCustomMessage(t *testing.T) { - buf := new(bytes.Buffer) - if err := proto.MarshalText(buf, &textMessage{}); err != nil { - t.Fatalf("proto.MarshalText: %v", err) - } - s := buf.String() - if s != "custom" { - t.Errorf("Got %q, expected %q", s, "custom") - } -} -func TestMarshalTextNil(t *testing.T) { - want := "" - tests := []proto.Message{nil, (*pb.MyMessage)(nil)} - for i, test := range tests { - buf := new(bytes.Buffer) - if err := proto.MarshalText(buf, test); err != nil { - t.Fatal(err) - } - if got := buf.String(); got != want { - t.Errorf("%d: got %q want %q", i, got, want) - } - } -} - -func TestMarshalTextUnknownEnum(t *testing.T) { - // The Color enum only specifies values 0-2. - m := &pb.MyMessage{Bikeshed: pb.MyMessage_Color(3).Enum()} - got := m.String() - const want = `bikeshed:3 ` - if got != want { - t.Errorf("\n got %q\nwant %q", got, want) - } -} - -func TestTextOneof(t *testing.T) { - tests := []struct { - m proto.Message - want string - }{ - // zero message - {&pb.Communique{}, ``}, - // scalar field - {&pb.Communique{Union: &pb.Communique_Number{4}}, `number:4`}, - // message field - {&pb.Communique{Union: &pb.Communique_Msg{ - &pb.Strings{StringField: proto.String("why hello!")}, - }}, `msg:`}, - // bad oneof (should not panic) - {&pb.Communique{Union: &pb.Communique_Msg{nil}}, `msg:/* nil */`}, - } - for _, test := range tests { - got := strings.TrimSpace(test.m.String()) - if got != test.want { - t.Errorf("\n got %s\nwant %s", got, test.want) - } - } -} - -func BenchmarkMarshalTextBuffered(b *testing.B) { - buf := new(bytes.Buffer) - m := newTestMessage() - for i := 0; i < b.N; i++ { - buf.Reset() - proto.MarshalText(buf, m) - } -} - -func BenchmarkMarshalTextUnbuffered(b *testing.B) { - w := ioutil.Discard - m := newTestMessage() - for i := 0; i < b.N; i++ { - proto.MarshalText(w, m) - } -} - -func compact(src string) string { - // s/[ \n]+/ /g; s/ $//; - dst := make([]byte, len(src)) - space, comment := false, false - j := 0 - for i := 0; i < len(src); i++ { - if strings.HasPrefix(src[i:], "/*") { - comment = true - i++ - continue - } - if comment && strings.HasPrefix(src[i:], "*/") { - comment = false - i++ - continue - } - if comment { - continue - } - c := src[i] - if c == ' ' || c == '\n' { - space = true - continue - } - if j > 0 && (dst[j-1] == ':' || dst[j-1] == '<' || dst[j-1] == '{') { - space = false - } - if c == '{' { - space = false - } - if space { - dst[j] = ' ' - j++ - space = false - } - dst[j] = c - j++ - } - if space { - dst[j] = ' ' - j++ - } - return string(dst[0:j]) -} - -var compactText = compact(text) - -func TestCompactText(t *testing.T) { - s := proto.CompactTextString(newTestMessage()) - if s != compactText { - t.Errorf("Got:\n===\n%v===\nExpected:\n===\n%v\n===\n", s, compactText) - } -} - -func TestStringEscaping(t *testing.T) { - testCases := []struct { - in *pb.Strings - out string - }{ - { - // Test data from C++ test (TextFormatTest.StringEscape). - // Single divergence: we don't escape apostrophes. - &pb.Strings{StringField: proto.String("\"A string with ' characters \n and \r newlines and \t tabs and \001 slashes \\ and multiple spaces")}, - "string_field: \"\\\"A string with ' characters \\n and \\r newlines and \\t tabs and \\001 slashes \\\\ and multiple spaces\"\n", - }, - { - // Test data from the same C++ test. - &pb.Strings{StringField: proto.String("\350\260\267\346\255\214")}, - "string_field: \"\\350\\260\\267\\346\\255\\214\"\n", - }, - { - // Some UTF-8. - &pb.Strings{StringField: proto.String("\x00\x01\xff\x81")}, - `string_field: "\000\001\377\201"` + "\n", - }, - } - - for i, tc := range testCases { - var buf bytes.Buffer - if err := proto.MarshalText(&buf, tc.in); err != nil { - t.Errorf("proto.MarsalText: %v", err) - continue - } - s := buf.String() - if s != tc.out { - t.Errorf("#%d: Got:\n%s\nExpected:\n%s\n", i, s, tc.out) - continue - } - - // Check round-trip. - pb := new(pb.Strings) - if err := proto.UnmarshalText(s, pb); err != nil { - t.Errorf("#%d: UnmarshalText: %v", i, err) - continue - } - if !proto.Equal(pb, tc.in) { - t.Errorf("#%d: Round-trip failed:\nstart: %v\n end: %v", i, tc.in, pb) - } - } -} - -// A limitedWriter accepts some output before it fails. -// This is a proxy for something like a nearly-full or imminently-failing disk, -// or a network connection that is about to die. -type limitedWriter struct { - b bytes.Buffer - limit int -} - -var outOfSpace = errors.New("proto: insufficient space") - -func (w *limitedWriter) Write(p []byte) (n int, err error) { - var avail = w.limit - w.b.Len() - if avail <= 0 { - return 0, outOfSpace - } - if len(p) <= avail { - return w.b.Write(p) - } - n, _ = w.b.Write(p[:avail]) - return n, outOfSpace -} - -func TestMarshalTextFailing(t *testing.T) { - // Try lots of different sizes to exercise more error code-paths. - for lim := 0; lim < len(text); lim++ { - buf := new(limitedWriter) - buf.limit = lim - err := proto.MarshalText(buf, newTestMessage()) - // We expect a certain error, but also some partial results in the buffer. - if err != outOfSpace { - t.Errorf("Got:\n===\n%v===\nExpected:\n===\n%v===\n", err, outOfSpace) - } - s := buf.b.String() - x := text[:buf.limit] - if s != x { - t.Errorf("Got:\n===\n%v===\nExpected:\n===\n%v===\n", s, x) - } - } -} - -func TestFloats(t *testing.T) { - tests := []struct { - f float64 - want string - }{ - {0, "0"}, - {4.7, "4.7"}, - {math.Inf(1), "inf"}, - {math.Inf(-1), "-inf"}, - {math.NaN(), "nan"}, - } - for _, test := range tests { - msg := &pb.FloatingPoint{F: &test.f} - got := strings.TrimSpace(msg.String()) - want := `f:` + test.want - if got != want { - t.Errorf("f=%f: got %q, want %q", test.f, got, want) - } - } -} - -func TestRepeatedNilText(t *testing.T) { - m := &pb.MessageList{ - Message: []*pb.MessageList_Message{ - nil, - &pb.MessageList_Message{ - Name: proto.String("Horse"), - }, - nil, - }, - } - want := `Message -Message { - name: "Horse" -} -Message -` - if s := proto.MarshalTextString(m); s != want { - t.Errorf(" got: %s\nwant: %s", s, want) - } -} - -func TestProto3Text(t *testing.T) { - tests := []struct { - m proto.Message - want string - }{ - // zero message - {&proto3pb.Message{}, ``}, - // zero message except for an empty byte slice - {&proto3pb.Message{Data: []byte{}}, ``}, - // trivial case - {&proto3pb.Message{Name: "Rob", HeightInCm: 175}, `name:"Rob" height_in_cm:175`}, - // empty map - {&pb.MessageWithMap{}, ``}, - // non-empty map; map format is the same as a repeated struct, - // and they are sorted by key (numerically for numeric keys). - { - &pb.MessageWithMap{NameMapping: map[int32]string{ - -1: "Negatory", - 7: "Lucky", - 1234: "Feist", - 6345789: "Otis", - }}, - `name_mapping: ` + - `name_mapping: ` + - `name_mapping: ` + - `name_mapping:`, - }, - // map with nil value; not well-defined, but we shouldn't crash - { - &pb.MessageWithMap{MsgMapping: map[int64]*pb.FloatingPoint{7: nil}}, - `msg_mapping:`, - }, - } - for _, test := range tests { - got := strings.TrimSpace(test.m.String()) - if got != test.want { - t.Errorf("\n got %s\nwant %s", got, test.want) - } - } -} - -func TestRacyMarshal(t *testing.T) { - // This test should be run with the race detector. - - any := &pb.MyMessage{Count: proto.Int32(47), Name: proto.String("David")} - proto.SetExtension(any, pb.E_Ext_Text, proto.String("bar")) - b, err := proto.Marshal(any) - if err != nil { - panic(err) - } - m := &proto3pb.Message{ - Name: "David", - ResultCount: 47, - Anything: &anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(any), Value: b}, - } - - wantText := proto.MarshalTextString(m) - wantBytes, err := proto.Marshal(m) - if err != nil { - t.Fatalf("proto.Marshal error: %v", err) - } - - var wg sync.WaitGroup - defer wg.Wait() - wg.Add(20) - for i := 0; i < 10; i++ { - go func() { - defer wg.Done() - got := proto.MarshalTextString(m) - if got != wantText { - t.Errorf("proto.MarshalTextString = %q, want %q", got, wantText) - } - }() - go func() { - defer wg.Done() - got, err := proto.Marshal(m) - if !bytes.Equal(got, wantBytes) || err != nil { - t.Errorf("proto.Marshal = (%x, %v), want (%x, nil)", got, err, wantBytes) - } - }() - } -} diff --git a/vendor/github.com/golang/protobuf/regenerate.sh b/vendor/github.com/golang/protobuf/regenerate.sh deleted file mode 100755 index dc7e2d1f..00000000 --- a/vendor/github.com/golang/protobuf/regenerate.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -set -e - -# Install the working tree's protoc-gen-gen in a tempdir. -tmpdir=$(mktemp -d -t regen-wkt.XXXXXX) -trap 'rm -rf $tmpdir' EXIT -mkdir -p $tmpdir/bin -PATH=$tmpdir/bin:$PATH -GOBIN=$tmpdir/bin go install ./protoc-gen-go - -# Public imports require at least Go 1.9. -supportTypeAliases="" -if go list -f '{{context.ReleaseTags}}' runtime | grep -q go1.9; then - supportTypeAliases=1 -fi - -# Generate various test protos. -PROTO_DIRS=( - conformance/internal/conformance_proto - jsonpb/jsonpb_test_proto - proto - protoc-gen-go/testdata -) -for dir in ${PROTO_DIRS[@]}; do - for p in `find $dir -name "*.proto"`; do - if [[ $p == */import_public/* && ! $supportTypeAliases ]]; then - echo "# $p (skipped)" - continue; - fi - echo "# $p" - protoc -I$dir --go_out=plugins=grpc,paths=source_relative:$dir $p - done -done - -# Deriving the location of the source protos from the path to the -# protoc binary may be a bit odd, but this is what protoc itself does. -PROTO_INCLUDE=$(dirname $(dirname $(which protoc)))/include - -# Well-known types. -WKT_PROTOS=(any duration empty struct timestamp wrappers) -for p in ${WKT_PROTOS[@]}; do - echo "# google/protobuf/$p.proto" - protoc --go_out=paths=source_relative:$tmpdir google/protobuf/$p.proto - cp $tmpdir/google/protobuf/$p.pb.go ptypes/$p - cp $PROTO_INCLUDE/google/protobuf/$p.proto ptypes/$p -done - -# descriptor.proto. -echo "# google/protobuf/descriptor.proto" -protoc --go_out=paths=source_relative:$tmpdir google/protobuf/descriptor.proto -cp $tmpdir/google/protobuf/descriptor.pb.go protoc-gen-go/descriptor -cp $PROTO_INCLUDE/google/protobuf/descriptor.proto protoc-gen-go/descriptor diff --git a/vendor/github.com/google/go-containerregistry/pkg/authn/BUILD.bazel b/vendor/github.com/google/go-containerregistry/pkg/authn/BUILD.bazel deleted file mode 100644 index 398defc7..00000000 --- a/vendor/github.com/google/go-containerregistry/pkg/authn/BUILD.bazel +++ /dev/null @@ -1,31 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "go_default_library", - srcs = [ - "anon.go", - "auth.go", - "authn.go", - "basic.go", - "bearer.go", - "doc.go", - "helper.go", - "keychain.go", - ], - importpath = "github.com/google/go-containerregistry/pkg/authn", - visibility = ["//visibility:public"], - deps = ["//pkg/name:go_default_library"], -) - -go_test( - name = "go_default_test", - srcs = [ - "anon_test.go", - "basic_test.go", - "bearer_test.go", - "helper_test.go", - "keychain_test.go", - ], - embed = [":go_default_library"], - deps = ["//pkg/name:go_default_library"], -) diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/BUILD.bazel b/vendor/github.com/google/go-containerregistry/pkg/name/BUILD.bazel deleted file mode 100644 index ac3eaf78..00000000 --- a/vendor/github.com/google/go-containerregistry/pkg/name/BUILD.bazel +++ /dev/null @@ -1,28 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "go_default_library", - srcs = [ - "check.go", - "digest.go", - "errors.go", - "ref.go", - "registry.go", - "repository.go", - "tag.go", - ], - importpath = "github.com/google/go-containerregistry/pkg/name", - visibility = ["//visibility:public"], -) - -go_test( - name = "go_default_test", - srcs = [ - "digest_test.go", - "ref_test.go", - "registry_test.go", - "repository_test.go", - "tag_test.go", - ], - embed = [":go_default_library"], -) diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/BUILD.bazel b/vendor/github.com/google/go-containerregistry/pkg/v1/BUILD.bazel deleted file mode 100644 index 487268de..00000000 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/BUILD.bazel +++ /dev/null @@ -1,27 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "go_default_library", - srcs = [ - "config.go", - "doc.go", - "hash.go", - "image.go", - "layer.go", - "manifest.go", - "zz_deepcopy_generated.go", - ], - importpath = "github.com/google/go-containerregistry/pkg/v1", - visibility = ["//visibility:public"], - deps = ["//pkg/v1/types:go_default_library"], -) - -go_test( - name = "go_default_test", - srcs = [ - "hash_test.go", - "manifest_test.go", - ], - embed = [":go_default_library"], - deps = ["//vendor/github.com/google/go-cmp/cmp:go_default_library"], -) diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/BUILD.bazel b/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/BUILD.bazel deleted file mode 100644 index c6e1526e..00000000 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/BUILD.bazel +++ /dev/null @@ -1,38 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "go_default_library", - srcs = [ - "doc.go", - "image.go", - "write.go", - ], - data = [ - "//pkg/v1/tarball:test_image_1.tar", # keep - ], - importpath = "github.com/google/go-containerregistry/pkg/v1/daemon", - visibility = ["//visibility:public"], - deps = [ - "//pkg/name:go_default_library", - "//pkg/v1:go_default_library", - "//pkg/v1/tarball:go_default_library", - "//vendor/github.com/docker/docker/api/types:go_default_library", - "//vendor/github.com/docker/docker/client:go_default_library", - "//vendor/github.com/pkg/errors:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = [ - "image_test.go", - "write_test.go", - ], - data = ["//pkg/v1/tarball:test_image_1.tar"], # keep - embed = [":go_default_library"], - deps = [ - "//pkg/name:go_default_library", - "//pkg/v1/tarball:go_default_library", - "//vendor/github.com/docker/docker/api/types:go_default_library", - ], -) diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/empty/BUILD.bazel b/vendor/github.com/google/go-containerregistry/pkg/v1/empty/BUILD.bazel deleted file mode 100644 index a4b207af..00000000 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/empty/BUILD.bazel +++ /dev/null @@ -1,18 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "go_default_library", - srcs = [ - "doc.go", - "image.go", - ], - importpath = "github.com/google/go-containerregistry/pkg/v1/empty", - visibility = ["//visibility:public"], - deps = ["//pkg/v1/random:go_default_library"], -) - -go_test( - name = "go_default_test", - srcs = ["image_test.go"], - embed = [":go_default_library"], -) diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/BUILD.bazel b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/BUILD.bazel deleted file mode 100644 index 49fcaf3c..00000000 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/BUILD.bazel +++ /dev/null @@ -1,96 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "go_default_library", - srcs = [ - "doc.go", - "mutate.go", - "rebase.go", - ], - importpath = "github.com/google/go-containerregistry/pkg/v1/mutate", - visibility = ["//visibility:public"], - deps = [ - "//pkg/v1:go_default_library", - "//pkg/v1/empty:go_default_library", - "//pkg/v1/partial:go_default_library", - "//pkg/v1/types:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = [ - "mutate_test.go", - "rebase_test.go", - ], - data = glob(["testdata/**"]) + [ - ":whiteout_image.tar", - ":overwritten_file.tar", - ":source_image.tar", # keep - ], - embed = [":go_default_library"], - deps = [ - "//pkg/v1:go_default_library", - "//pkg/v1/random:go_default_library", - "//pkg/v1/tarball:go_default_library", - "//vendor/github.com/google/go-cmp/cmp:go_default_library", - ], -) - -load( - "@io_bazel_rules_docker//container:container.bzl", - "container_image", - "container_layer", -) - -container_image( - name = "source_image", - files = [ - "testdata/bar", - "testdata/foo", - ], -) - -container_layer( - name = "base_layer", - files = [ - "testdata/whiteout/bar.txt", - "testdata/whiteout/foo.txt", - ], -) - -container_layer( - name = "whiteout_layer", - files = [ - "testdata/whiteout/.wh.foo.txt", - ], -) - -container_image( - name = "whiteout_image", - layers = [ - ":base_layer", - ":whiteout_layer", - ], -) - -container_layer( - name = "unmodified_foo", - files = [ - "testdata/whiteout/foo.txt", - ], -) - -container_layer( - name = "symlinked_foo", - files = ["testdata/whiteout/bar.txt"], - symlinks = {"foo.txt": "bar.txt"}, -) - -container_image( - name = "overwritten_file", - layers = [ - ":unmodified_foo", - ":symlinked_foo", - ], -) diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/partial/BUILD.bazel b/vendor/github.com/google/go-containerregistry/pkg/v1/partial/BUILD.bazel deleted file mode 100644 index 9b93d905..00000000 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/partial/BUILD.bazel +++ /dev/null @@ -1,19 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "compressed.go", - "doc.go", - "image.go", - "uncompressed.go", - "with.go", - ], - importpath = "github.com/google/go-containerregistry/pkg/v1/partial", - visibility = ["//visibility:public"], - deps = [ - "//pkg/v1:go_default_library", - "//pkg/v1/types:go_default_library", - "//pkg/v1/v1util:go_default_library", - ], -) diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/random/BUILD.bazel b/vendor/github.com/google/go-containerregistry/pkg/v1/random/BUILD.bazel deleted file mode 100644 index 6ab9996b..00000000 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/random/BUILD.bazel +++ /dev/null @@ -1,23 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "go_default_library", - srcs = [ - "doc.go", - "image.go", - ], - importpath = "github.com/google/go-containerregistry/pkg/v1/random", - visibility = ["//visibility:public"], - deps = [ - "//pkg/v1:go_default_library", - "//pkg/v1/partial:go_default_library", - "//pkg/v1/types:go_default_library", - "//pkg/v1/v1util:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = ["image_test.go"], - embed = [":go_default_library"], -) diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/BUILD.bazel b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/BUILD.bazel deleted file mode 100644 index 8ba6f8fc..00000000 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/BUILD.bazel +++ /dev/null @@ -1,47 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "go_default_library", - srcs = [ - "delete.go", - "doc.go", - "error.go", - "image.go", - "list.go", - "mount.go", - "write.go", - ], - importpath = "github.com/google/go-containerregistry/pkg/v1/remote", - visibility = ["//visibility:public"], - deps = [ - "//pkg/authn:go_default_library", - "//pkg/name:go_default_library", - "//pkg/v1:go_default_library", - "//pkg/v1/partial:go_default_library", - "//pkg/v1/remote/transport:go_default_library", - "//pkg/v1/types:go_default_library", - "//pkg/v1/v1util:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = [ - "delete_test.go", - "error_test.go", - "image_test.go", - "list_test.go", - "write_test.go", - ], - embed = [":go_default_library"], - deps = [ - "//pkg/authn:go_default_library", - "//pkg/name:go_default_library", - "//pkg/v1:go_default_library", - "//pkg/v1/random:go_default_library", - "//pkg/v1/remote/transport:go_default_library", - "//pkg/v1/types:go_default_library", - "//pkg/v1/v1util:go_default_library", - "//vendor/github.com/google/go-cmp/cmp:go_default_library", - ], -) diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/BUILD.bazel b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/BUILD.bazel deleted file mode 100644 index 3b026c07..00000000 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/BUILD.bazel +++ /dev/null @@ -1,37 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "go_default_library", - srcs = [ - "basic.go", - "bearer.go", - "doc.go", - "ping.go", - "scheme.go", - "scope.go", - "transport.go", - ], - importpath = "github.com/google/go-containerregistry/pkg/v1/remote/transport", - visibility = ["//visibility:public"], - deps = [ - "//pkg/authn:go_default_library", - "//pkg/name:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = [ - "basic_test.go", - "bearer_test.go", - "ping_test.go", - "scheme_test.go", - "transport_test.go", - ], - embed = [":go_default_library"], - deps = [ - "//pkg/authn:go_default_library", - "//pkg/name:go_default_library", - "//vendor/github.com/google/go-cmp/cmp:go_default_library", - ], -) diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/BUILD.bazel b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/BUILD.bazel deleted file mode 100644 index ea7ac490..00000000 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/BUILD.bazel +++ /dev/null @@ -1,86 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "go_default_library", - srcs = [ - "doc.go", - "image.go", - "layer.go", - "write.go", - ], - importpath = "github.com/google/go-containerregistry/pkg/v1/tarball", - visibility = ["//visibility:public"], - deps = [ - "//pkg/name:go_default_library", - "//pkg/v1:go_default_library", - "//pkg/v1/partial:go_default_library", - "//pkg/v1/types:go_default_library", - "//pkg/v1/v1util:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = [ - "image_test.go", - "layer_test.go", - "write_test.go", - ], - data = glob(["testdata/**"]) + [ - ":test_image_1.tar", # keep - ":test_image_2.tar", # keep - ":test_bundle.tar", # keep - ":content.tar", # keep - ], - embed = [":go_default_library"], - deps = [ - "//pkg/name:go_default_library", - "//pkg/v1:go_default_library", - "//pkg/v1/random:go_default_library", - "//vendor/github.com/google/go-cmp/cmp:go_default_library", - ], -) - -load( - "@io_bazel_rules_docker//container:container.bzl", - "container_image", - "container_bundle", -) - -container_image( - name = "test_image_1", - files = [ - "testdata/bar", - "testdata/foo", - ], - visibility = ["//visibility:public"], -) - -container_image( - name = "test_image_2", - files = [ - "testdata/bat/bat", - "testdata/baz", - ], -) - -container_bundle( - name = "test_bundle", - images = { - "test_image_1": ":test_image_1", - "test_image_2": ":test_image_2", - }, -) - -load( - "@bazel_tools//tools/build_defs/pkg:pkg.bzl", - "pkg_tar", -) - -pkg_tar( - name = "content", - srcs = [ - "testdata/bat/bat", - "testdata/baz", - ], -) diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/v1util/BUILD.bazel b/vendor/github.com/google/go-containerregistry/pkg/v1/v1util/BUILD.bazel deleted file mode 100644 index f9fc9b10..00000000 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/v1util/BUILD.bazel +++ /dev/null @@ -1,25 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "go_default_library", - srcs = [ - "and_closer.go", - "nop.go", - "verify.go", - "zip.go", - ], - importpath = "github.com/google/go-containerregistry/pkg/v1/v1util", - visibility = ["//visibility:public"], - deps = ["//pkg/v1:go_default_library"], -) - -go_test( - name = "go_default_test", - srcs = [ - "and_closer_test.go", - "verify_test.go", - "zip_test.go", - ], - embed = [":go_default_library"], - deps = ["//pkg/v1:go_default_library"], -) 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 3a1f51fc..00000000 --- a/vendor/github.com/google/go-github/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -sudo: false -language: go -go: - - "1.11.x" - - "1.10.x" - - "1.9.x" - - master -env: - global: - - GO111MODULE=on -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 3e2483d6..00000000 --- a/vendor/github.com/google/go-github/README.md +++ /dev/null @@ -1,262 +0,0 @@ -# go-github # - -[![GoDoc](https://godoc.org/github.com/google/go-github/github?status.svg)](https://godoc.org/github.com/google/go-github/github) [![Build Status](https://travis-ci.org/google/go-github.svg?branch=master)](https://travis-ci.org/google/go-github) [![Test Coverage](https://coveralls.io/repos/google/go-github/badge.svg?branch=master)](https://coveralls.io/r/google/go-github?branch=master) [![Discuss at go-github@googlegroups.com](https://img.shields.io/badge/discuss-go--github%40googlegroups.com-blue.svg)](https://groups.google.com/group/go-github) - -go-github is a Go client library for accessing the [GitHub API v3][]. - -go-github requires Go version 1.9 or greater. - -If you're interested in using the [GraphQL API v4][], the recommended library is -[shurcooL/githubv4][]. - -## Usage ## - -```go -import "github.com/google/go-github/v18/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(context.Background(), "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(context.Background(), "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/. - -NOTE: Using the [context](https://godoc.org/context) package, one can easily -pass cancelation signals and deadlines to various services of the client for -handling a request. In case there is no context available, then `context.Background()` -can be used as a starting point. - -For more sample code snippets, head over to the -[example](https://github.com/google/go-github/tree/master/example) directory. - -### 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/githubv4]: https://github.com/shurcooL/githubv4 - -### 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]. - -[roadmap]: https://docs.google.com/spreadsheet/ccc?key=0ApoVX4GOiXr-dGNKN1pObFh6ek1DR2FKUjBNZ1FmaEE&usp=sharing - -## Contributing ## -I would like to cover the entire GitHub API and contributions are of course always welcome. The -calling pattern is pretty well established, so adding new methods is relatively -straightforward. See [`CONTRIBUTING.md`](CONTRIBUTING.md) for details. - -## Versioning ## - -In general, go-github follows [semver](https://semver.org/) as closely as we -can for tagging releases of the package. For self-contained libraries, the -application of semantic versioning is relatively straightforward and generally -understood. But because go-github is a client library for the GitHub API, which -itself changes behavior, and because we are typically pretty aggressive about -implementing preview features of the GitHub API, we've adopted the following -versioning policy: - -* We increment the **major version** with any incompatible change to - non-preview functionality, including changes to the exported Go API surface - or behavior of the API. -* We increment the **minor version** with any backwards-compatible changes to - functionality, as well as any changes to preview functionality in the GitHub - API. GitHub makes no guarantee about the stability of preview functionality, - so neither do we consider it a stable part of the go-github API. -* We increment the **patch version** with any backwards-compatible bug fixes. - -Preview functionality may take the form of entire methods or simply additional -data returned from an otherwise non-preview method. Refer to the GitHub API -documentation for details on preview functionality. - -## 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/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 a36b253d..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, time.January, 02, 15, 04, 05, 0, time.UTC), - Before: time.Date(2007, time.March, 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, time.January, 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, time.January, 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 8a122478..00000000 --- a/vendor/github.com/google/go-github/github/activity_star_test.go +++ /dev/null @@ -1,185 +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 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", strings.Join([]string{mediaTypeStarringPreview, mediaTypeTopicsPreview}, ", ")) - 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", strings.Join([]string{mediaTypeStarringPreview, mediaTypeTopicsPreview}, ", ")) - 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 0c1f86c7..00000000 --- a/vendor/github.com/google/go-github/github/apps_marketplace_test.go +++ /dev/null @@ -1,194 +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") - 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") - 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") - 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") - 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") - 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") - 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") - 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") - 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 f56c1c44..00000000 --- a/vendor/github.com/google/go-github/github/apps_test.go +++ /dev/null @@ -1,270 +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 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, - "app_id":1, - "target_id":1, - "target_type": "Organization", - "permissions": { - "metadata": "read", - "contents": "read", - "issues": "write", - "single_file": "write" - }, - "events": [ - "push", - "pull_request" - ], - "single_file_name": "config.yml", - "repository_selection": "selected", - "created_at": "2018-01-01T00:00:00Z", - "updated_at": "2018-01-01T00:00:00Z"}]`, - ) - }) - - 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) - } - - date := Timestamp{Time: time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)} - want := []*Installation{{ - ID: Int64(1), - AppID: Int64(1), - TargetID: Int64(1), - TargetType: String("Organization"), - SingleFileName: String("config.yml"), - RepositorySelection: String("selected"), - Permissions: &InstallationPermissions{ - Metadata: String("read"), - Contents: String("read"), - Issues: String("write"), - SingleFile: String("write")}, - Events: []string{"push", "pull_request"}, - CreatedAt: &date, - UpdatedAt: &date, - }} - 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, "app_id":1, "target_id":1, "target_type": "Organization"}`) - }) - - installation, _, err := client.Apps.GetInstallation(context.Background(), 1) - if err != nil { - t.Errorf("Apps.GetInstallation returned error: %v", err) - } - - want := &Installation{ID: Int64(1), AppID: Int64(1), TargetID: Int64(1), TargetType: String("Organization")} - 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, "app_id":1, "target_id":1, "target_type": "Organization"}]}`) - }) - - 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), AppID: Int64(1), TargetID: Int64(1), TargetType: String("Organization")}} - 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) - } -} - -func TestAppsService_FindOrganizationInstallation(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/orgs/o/installation", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeIntegrationPreview) - fmt.Fprint(w, `{"id":1, "app_id":1, "target_id":1, "target_type": "Organization"}`) - }) - - installation, _, err := client.Apps.FindOrganizationInstallation(context.Background(), "o") - if err != nil { - t.Errorf("Apps.FindOrganizationInstallation returned error: %v", err) - } - - want := &Installation{ID: Int64(1), AppID: Int64(1), TargetID: Int64(1), TargetType: String("Organization")} - if !reflect.DeepEqual(installation, want) { - t.Errorf("Apps.FindOrganizationInstallation returned %+v, want %+v", installation, want) - } -} - -func TestAppsService_FindRepositoryInstallation(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/installation", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeIntegrationPreview) - fmt.Fprint(w, `{"id":1, "app_id":1, "target_id":1, "target_type": "Organization"}`) - }) - - installation, _, err := client.Apps.FindRepositoryInstallation(context.Background(), "o", "r") - if err != nil { - t.Errorf("Apps.FindRepositoryInstallation returned error: %v", err) - } - - want := &Installation{ID: Int64(1), AppID: Int64(1), TargetID: Int64(1), TargetType: String("Organization")} - if !reflect.DeepEqual(installation, want) { - t.Errorf("Apps.FindRepositoryInstallation returned %+v, want %+v", installation, want) - } -} - -func TestAppsService_FindRepositoryInstallationByID(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repositories/1/installation", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeIntegrationPreview) - fmt.Fprint(w, `{"id":1, "app_id":1, "target_id":1, "target_type": "Organization"}`) - }) - - installation, _, err := client.Apps.FindRepositoryInstallationByID(context.Background(), 1) - if err != nil { - t.Errorf("Apps.FindRepositoryInstallationByID returned error: %v", err) - } - - want := &Installation{ID: Int64(1), AppID: Int64(1), TargetID: Int64(1), TargetType: String("Organization")} - if !reflect.DeepEqual(installation, want) { - t.Errorf("Apps.FindRepositoryInstallationByID returned %+v, want %+v", installation, want) - } -} - -func TestAppsService_FindUserInstallation(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/users/u/installation", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeIntegrationPreview) - fmt.Fprint(w, `{"id":1, "app_id":1, "target_id":1, "target_type": "User"}`) - }) - - installation, _, err := client.Apps.FindUserInstallation(context.Background(), "u") - if err != nil { - t.Errorf("Apps.FindUserInstallation returned error: %v", err) - } - - want := &Installation{ID: Int64(1), AppID: Int64(1), TargetID: Int64(1), TargetType: String("User")} - if !reflect.DeepEqual(installation, want) { - t.Errorf("Apps.FindUserInstallation returned %+v, want %+v", installation, 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/checks_test.go b/vendor/github.com/google/go-github/github/checks_test.go deleted file mode 100644 index 3170f70d..00000000 --- a/vendor/github.com/google/go-github/github/checks_test.go +++ /dev/null @@ -1,479 +0,0 @@ -// Copyright 2018 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 TestChecksService_GetCheckRun(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/check-runs/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeCheckRunsPreview) - fmt.Fprint(w, `{ - "id": 1, - "name":"testCheckRun", - "status": "completed", - "conclusion": "neutral", - "started_at": "2018-05-04T01:14:52Z", - "completed_at": "2018-05-04T01:14:52Z"}`) - }) - checkRun, _, err := client.Checks.GetCheckRun(context.Background(), "o", "r", 1) - if err != nil { - t.Errorf("Checks.GetCheckRun return error: %v", err) - } - startedAt, _ := time.Parse(time.RFC3339, "2018-05-04T01:14:52Z") - completeAt, _ := time.Parse(time.RFC3339, "2018-05-04T01:14:52Z") - - want := &CheckRun{ - ID: Int64(1), - Status: String("completed"), - Conclusion: String("neutral"), - StartedAt: &Timestamp{startedAt}, - CompletedAt: &Timestamp{completeAt}, - Name: String("testCheckRun"), - } - if !reflect.DeepEqual(checkRun, want) { - t.Errorf("Checks.GetCheckRun return %+v, want %+v", checkRun, want) - } -} - -func TestChecksService_GetCheckSuite(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/check-suites/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeCheckRunsPreview) - fmt.Fprint(w, `{ - "id": 1, - "head_branch":"master", - "head_sha": "deadbeef", - "conclusion": "neutral", - "before": "deadbeefb", - "after": "deadbeefa", - "status": "completed"}`) - }) - checkSuite, _, err := client.Checks.GetCheckSuite(context.Background(), "o", "r", 1) - if err != nil { - t.Errorf("Checks.GetCheckSuite return error: %v", err) - } - want := &CheckSuite{ - ID: Int64(1), - HeadBranch: String("master"), - HeadSHA: String("deadbeef"), - AfterSHA: String("deadbeefa"), - BeforeSHA: String("deadbeefb"), - Status: String("completed"), - Conclusion: String("neutral"), - } - if !reflect.DeepEqual(checkSuite, want) { - t.Errorf("Checks.GetCheckSuite return %+v, want %+v", checkSuite, want) - } -} - -func TestChecksService_CreateCheckRun(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/check-runs", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") - testHeader(t, r, "Accept", mediaTypeCheckRunsPreview) - fmt.Fprint(w, `{ - "id": 1, - "name":"testCreateCheckRun", - "head_sha":"deadbeef", - "status": "in_progress", - "conclusion": null, - "started_at": "2018-05-04T01:14:52Z", - "completed_at": null, - "output":{"title": "Mighty test report", "summary":"", "text":""}}`) - }) - startedAt, _ := time.Parse(time.RFC3339, "2018-05-04T01:14:52Z") - checkRunOpt := CreateCheckRunOptions{ - HeadBranch: "master", - Name: "testCreateCheckRun", - HeadSHA: "deadbeef", - Status: String("in_progress"), - StartedAt: &Timestamp{startedAt}, - Output: &CheckRunOutput{ - Title: String("Mighty test report"), - Summary: String(""), - Text: String(""), - }, - } - - checkRun, _, err := client.Checks.CreateCheckRun(context.Background(), "o", "r", checkRunOpt) - if err != nil { - t.Errorf("Checks.CreateCheckRun return error: %v", err) - } - - want := &CheckRun{ - ID: Int64(1), - Status: String("in_progress"), - StartedAt: &Timestamp{startedAt}, - HeadSHA: String("deadbeef"), - Name: String("testCreateCheckRun"), - Output: &CheckRunOutput{ - Title: String("Mighty test report"), - Summary: String(""), - Text: String(""), - }, - } - if !reflect.DeepEqual(checkRun, want) { - t.Errorf("Checks.CreateCheckRun return %+v, want %+v", checkRun, want) - } -} - -func TestChecksService_ListCheckRunAnnotations(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/check-runs/1/annotations", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeCheckRunsPreview) - testFormValues(t, r, values{ - "page": "1", - }) - fmt.Fprint(w, `[{ - "path": "README.md", - "blob_href": "https://github.com/octocat/Hello-World/blob/837db83be4137ca555d9a5598d0a1ea2987ecfee/README.md", - "start_line": 2, - "end_line": 2, - "annotation_level": "warning", - "message": "Check your spelling for 'banaas'.", - "title": "Spell check", - "raw_details": "Do you mean 'bananas' or 'banana'?"}]`, - ) - }) - - checkRunAnnotations, _, err := client.Checks.ListCheckRunAnnotations(context.Background(), "o", "r", 1, &ListOptions{Page: 1}) - if err != nil { - t.Errorf("Checks.ListCheckRunAnnotations return error: %v", err) - } - - want := []*CheckRunAnnotation{{ - Path: String("README.md"), - BlobHRef: String("https://github.com/octocat/Hello-World/blob/837db83be4137ca555d9a5598d0a1ea2987ecfee/README.md"), - StartLine: Int(2), - EndLine: Int(2), - AnnotationLevel: String("warning"), - Message: String("Check your spelling for 'banaas'."), - RawDetails: String("Do you mean 'bananas' or 'banana'?"), - Title: String("Spell check"), - }} - - if !reflect.DeepEqual(checkRunAnnotations, want) { - t.Errorf("Checks.ListCheckRunAnnotations returned %+v, want %+v", checkRunAnnotations, want) - } -} - -func TestChecksService_UpdateCheckRun(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/check-runs/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PATCH") - testHeader(t, r, "Accept", mediaTypeCheckRunsPreview) - fmt.Fprint(w, `{ - "id": 1, - "name":"testUpdateCheckRun", - "head_sha":"deadbeef", - "status": "completed", - "conclusion": "neutral", - "started_at": "2018-05-04T01:14:52Z", - "completed_at": "2018-05-04T01:14:52Z", - "output":{"title": "Mighty test report", "summary":"There are 0 failures, 2 warnings and 1 notice", "text":"You may have misspelled some words."}}`) - }) - startedAt, _ := time.Parse(time.RFC3339, "2018-05-04T01:14:52Z") - updateCheckRunOpt := UpdateCheckRunOptions{ - HeadBranch: String("master"), - Name: "testUpdateCheckRun", - HeadSHA: String("deadbeef"), - Status: String("completed"), - CompletedAt: &Timestamp{startedAt}, - Output: &CheckRunOutput{ - Title: String("Mighty test report"), - Summary: String("There are 0 failures, 2 warnings and 1 notice"), - Text: String("You may have misspelled some words."), - }, - } - - checkRun, _, err := client.Checks.UpdateCheckRun(context.Background(), "o", "r", 1, updateCheckRunOpt) - if err != nil { - t.Errorf("Checks.UpdateCheckRun return error: %v", err) - } - - want := &CheckRun{ - ID: Int64(1), - Status: String("completed"), - StartedAt: &Timestamp{startedAt}, - CompletedAt: &Timestamp{startedAt}, - Conclusion: String("neutral"), - HeadSHA: String("deadbeef"), - Name: String("testUpdateCheckRun"), - Output: &CheckRunOutput{ - Title: String("Mighty test report"), - Summary: String("There are 0 failures, 2 warnings and 1 notice"), - Text: String("You may have misspelled some words."), - }, - } - if !reflect.DeepEqual(checkRun, want) { - t.Errorf("Checks.UpdateCheckRun return %+v, want %+v", checkRun, want) - } -} - -func TestChecksService_ListCheckRunsForRef(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/commits/master/check-runs", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeCheckRunsPreview) - testFormValues(t, r, values{ - "check_name": "testing", - "page": "1", - "status": "completed", - "filter": "all", - }) - fmt.Fprint(w, `{"total_count":1, - "check_runs": [{ - "id": 1, - "head_sha": "deadbeef", - "status": "completed", - "conclusion": "neutral", - "started_at": "2018-05-04T01:14:52Z", - "completed_at": "2018-05-04T01:14:52Z"}]}`, - ) - }) - - opt := &ListCheckRunsOptions{ - CheckName: String("testing"), - Status: String("completed"), - Filter: String("all"), - ListOptions: ListOptions{Page: 1}, - } - checkRuns, _, err := client.Checks.ListCheckRunsForRef(context.Background(), "o", "r", "master", opt) - if err != nil { - t.Errorf("Checks.ListCheckRunsForRef return error: %v", err) - } - startedAt, _ := time.Parse(time.RFC3339, "2018-05-04T01:14:52Z") - want := &ListCheckRunsResults{ - Total: Int(1), - CheckRuns: []*CheckRun{{ - ID: Int64(1), - Status: String("completed"), - StartedAt: &Timestamp{startedAt}, - CompletedAt: &Timestamp{startedAt}, - Conclusion: String("neutral"), - HeadSHA: String("deadbeef"), - }}, - } - - if !reflect.DeepEqual(checkRuns, want) { - t.Errorf("Checks.ListCheckRunsForRef returned %+v, want %+v", checkRuns, want) - } -} - -func TestChecksService_ListCheckRunsCheckSuite(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/check-suites/1/check-runs", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeCheckRunsPreview) - testFormValues(t, r, values{ - "check_name": "testing", - "page": "1", - "status": "completed", - "filter": "all", - }) - fmt.Fprint(w, `{"total_count":1, - "check_runs": [{ - "id": 1, - "head_sha": "deadbeef", - "status": "completed", - "conclusion": "neutral", - "started_at": "2018-05-04T01:14:52Z", - "completed_at": "2018-05-04T01:14:52Z"}]}`, - ) - }) - - opt := &ListCheckRunsOptions{ - CheckName: String("testing"), - Status: String("completed"), - Filter: String("all"), - ListOptions: ListOptions{Page: 1}, - } - checkRuns, _, err := client.Checks.ListCheckRunsCheckSuite(context.Background(), "o", "r", 1, opt) - if err != nil { - t.Errorf("Checks.ListCheckRunsCheckSuite return error: %v", err) - } - startedAt, _ := time.Parse(time.RFC3339, "2018-05-04T01:14:52Z") - want := &ListCheckRunsResults{ - Total: Int(1), - CheckRuns: []*CheckRun{{ - ID: Int64(1), - Status: String("completed"), - StartedAt: &Timestamp{startedAt}, - CompletedAt: &Timestamp{startedAt}, - Conclusion: String("neutral"), - HeadSHA: String("deadbeef"), - }}, - } - - if !reflect.DeepEqual(checkRuns, want) { - t.Errorf("Checks.ListCheckRunsCheckSuite returned %+v, want %+v", checkRuns, want) - } -} - -func TestChecksService_ListCheckSuiteForRef(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/commits/master/check-suites", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeCheckRunsPreview) - testFormValues(t, r, values{ - "check_name": "testing", - "page": "1", - "app_id": "2", - }) - fmt.Fprint(w, `{"total_count":1, - "check_suites": [{ - "id": 1, - "head_sha": "deadbeef", - "head_branch": "master", - "status": "completed", - "conclusion": "neutral", - "before": "deadbeefb", - "after": "deadbeefa"}]}`, - ) - }) - - opt := &ListCheckSuiteOptions{ - CheckName: String("testing"), - AppID: Int(2), - ListOptions: ListOptions{Page: 1}, - } - checkSuites, _, err := client.Checks.ListCheckSuitesForRef(context.Background(), "o", "r", "master", opt) - if err != nil { - t.Errorf("Checks.ListCheckSuitesForRef return error: %v", err) - } - want := &ListCheckSuiteResults{ - Total: Int(1), - CheckSuites: []*CheckSuite{{ - ID: Int64(1), - Status: String("completed"), - Conclusion: String("neutral"), - HeadSHA: String("deadbeef"), - HeadBranch: String("master"), - BeforeSHA: String("deadbeefb"), - AfterSHA: String("deadbeefa"), - }}, - } - - if !reflect.DeepEqual(checkSuites, want) { - t.Errorf("Checks.ListCheckSuitesForRef returned %+v, want %+v", checkSuites, want) - } -} - -func TestChecksService_SetCheckSuitePreferences(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/check-suites/preferences", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PATCH") - testHeader(t, r, "Accept", mediaTypeCheckRunsPreview) - fmt.Fprint(w, `{"preferences":{"auto_trigger_checks":[{"app_id": 2,"setting": false}]}}`) - }) - p := &PreferenceList{ - AutoTriggerChecks: []*AutoTriggerCheck{{ - AppID: Int64(2), - Setting: Bool(false), - }}, - } - opt := CheckSuitePreferenceOptions{PreferenceList: p} - prefResults, _, err := client.Checks.SetCheckSuitePreferences(context.Background(), "o", "r", opt) - if err != nil { - t.Errorf("Checks.SetCheckSuitePreferences return error: %v", err) - } - - want := &CheckSuitePreferenceResults{ - Preferences: p, - } - - if !reflect.DeepEqual(prefResults, want) { - t.Errorf("Checks.SetCheckSuitePreferences return %+v, want %+v", prefResults, want) - } -} - -func TestChecksService_CreateCheckSuite(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/check-suites", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") - testHeader(t, r, "Accept", mediaTypeCheckRunsPreview) - fmt.Fprint(w, `{ - "id": 2, - "head_branch":"master", - "head_sha":"deadbeef", - "status": "completed", - "conclusion": "neutral", - "before": "deadbeefb", - "after": "deadbeefa"}`) - }) - - checkSuiteOpt := CreateCheckSuiteOptions{ - HeadSHA: "deadbeef", - HeadBranch: String("master"), - } - - checkSuite, _, err := client.Checks.CreateCheckSuite(context.Background(), "o", "r", checkSuiteOpt) - if err != nil { - t.Errorf("Checks.CreateCheckSuite return error: %v", err) - } - - want := &CheckSuite{ - ID: Int64(2), - Status: String("completed"), - HeadSHA: String("deadbeef"), - HeadBranch: String("master"), - Conclusion: String("neutral"), - BeforeSHA: String("deadbeefb"), - AfterSHA: String("deadbeefa"), - } - if !reflect.DeepEqual(checkSuite, want) { - t.Errorf("Checks.CreateCheckSuite return %+v, want %+v", checkSuite, want) - } -} - -func TestChecksService_ReRequestCheckSuite(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/check-suites/1/rerequest", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") - testHeader(t, r, "Accept", mediaTypeCheckRunsPreview) - w.WriteHeader(http.StatusCreated) - }) - resp, err := client.Checks.ReRequestCheckSuite(context.Background(), "o", "r", 1) - if err != nil { - t.Errorf("Checks.ReRequestCheckSuite return error: %v", err) - } - if got, want := resp.StatusCode, http.StatusCreated; got != want { - t.Errorf("Checks.ReRequestCheckSuite = %v, want %v", got, want) - } -} 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 942b0b7d..00000000 --- a/vendor/github.com/google/go-github/github/examples_test.go +++ /dev/null @@ -1,168 +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/v18/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 ExampleRepositoriesService_CreateFile() { - // In this example we're creating a new file in a repository using the - // Contents API. Only 1 file per commit can be managed through that API. - - // Note that authentication is needed here as you are performing a modification - // so you will need to modify the example to provide an oauth client to - // github.NewClient() instead of nil. See the following documentation for more - // information on how to authenticate with the client: - // https://godoc.org/github.com/google/go-github/github#hdr-Authentication - client := github.NewClient(nil) - - ctx := context.Background() - fileContent := []byte("This is the content of my file\nand the 2nd line of it") - - // Note: the file needs to be absent from the repository as you are not - // specifying a SHA reference here. - opts := &github.RepositoryContentFileOptions{ - Message: github.String("This is my commit message"), - Content: fileContent, - Branch: github.String("master"), - Committer: &github.CommitAuthor{Name: github.String("FirstName LastName"), Email: github.String("user@example.com")}, - } - _, _, err := client.Repositories.CreateFile(ctx, "myOrganization", "myRepository", "myNewFile.md", opts) - if err != nil { - fmt.Println(err) - return - } -} - -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... - } -} - -func ExamplePullRequestsService_Create() { - // In this example we're creating a PR and displaying the HTML url at the end. - - // Note that authentication is needed here as you are performing a modification - // so you will need to modify the example to provide an oauth client to - // github.NewClient() instead of nil. See the following documentation for more - // information on how to authenticate with the client: - // https://godoc.org/github.com/google/go-github/github#hdr-Authentication - client := github.NewClient(nil) - - newPR := &github.NewPullRequest{ - Title: github.String("My awesome pull request"), - Head: github.String("branch_to_merge"), - Base: github.String("master"), - Body: github.String("This is the description of the PR created with the package `github.com/google/go-github/github`"), - MaintainerCanModify: github.Bool(true), - } - - pr, _, err := client.PullRequests.Create(context.Background(), "myOrganization", "myRepository", newPR) - if err != nil { - fmt.Println(err) - return - } - - fmt.Printf("PR created: %s\n", pr.GetHTMLURL()) -} - -func ExampleTeamsService_ListTeams() { - // This example shows how to get a team ID corresponding to a given team name. - - // Note that authentication is needed here as you are performing a lookup on - // an organization's administrative configuration, so you will need to modify - // the example to provide an oauth client to github.NewClient() instead of nil. - // See the following documentation for more information on how to authenticate - // with the client: - // https://godoc.org/github.com/google/go-github/github#hdr-Authentication - client := github.NewClient(nil) - - teamName := "Developers team" - ctx := context.Background() - opts := &github.ListOptions{} - - for { - teams, resp, err := client.Teams.ListTeams(ctx, "myOrganization", opts) - if err != nil { - fmt.Println(err) - return - } - for _, t := range teams { - if t.GetName() == teamName { - fmt.Printf("Team %q has ID %d\n", teamName, t.GetID()) - return - } - } - if resp.NextPage == 0 { - break - } - opts.Page = resp.NextPage - } - - fmt.Printf("Team %q was not found\n", teamName) -} 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 3d31c9ac..00000000 --- a/vendor/github.com/google/go-github/github/gists_test.go +++ /dev/null @@ -1,534 +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") - 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") - 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") - 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") - 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") - 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") - 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") - 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") - 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") - 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, time.January, 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") - 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") - 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") - 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, time.January, 1, 00, 00, 00, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2013, time.January, 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 9945d352..00000000 --- a/vendor/github.com/google/go-github/github/git_blobs_test.go +++ /dev/null @@ -1,124 +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 ( - "bytes" - "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") - - 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_GetBlobRaw(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", "application/vnd.github.v3.raw") - - fmt.Fprint(w, `raw contents here`) - }) - - blob, _, err := client.Git.GetBlobRaw(context.Background(), "o", "r", "s") - if err != nil { - t.Errorf("Git.GetBlobRaw returned error: %v", err) - } - - want := []byte("raw contents here") - if !bytes.Equal(blob, want) { - t.Errorf("GetBlobRaw returned %q, want %q", blob, want) - } -} - -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") - - 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 ff8827f9..00000000 --- a/vendor/github.com/google/go-github/github/git_commits_test.go +++ /dev/null @@ -1,90 +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_GetCommit(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/git/commits/s", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeGitSigningPreview) - 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") - - 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 3cae3c08..00000000 --- a/vendor/github.com/google/go-github/github/git_refs_test.go +++ /dev/null @@ -1,429 +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") - 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") - 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") - 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") - 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") - 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") - 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") - 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") - 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") - 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 0b11c64c..00000000 --- a/vendor/github.com/google/go-github/github/git_tags_test.go +++ /dev/null @@ -1,68 +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_GetTag(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/git/tags/s", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeGitSigningPreview) - 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") - 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 1f7024fc..00000000 --- a/vendor/github.com/google/go-github/github/git_trees_test.go +++ /dev/null @@ -1,195 +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" } ], - "truncated": true - }`) - }) - - 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"), - }, - }, - Truncated: Bool(true), - } - 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"), - }, - }, - nil, - } - - 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"), - }, - }, - nil, - } - - 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 da29e1ec..00000000 --- a/vendor/github.com/google/go-github/github/github_test.go +++ /dev/null @@ -1,1083 +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, time.July, 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, time.July, 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, time.July, 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 is returned when the response indicates that -// the client has triggered an abuse detection mechanism on GitHub Enterprise. -func TestDo_rateLimit_abuseRateLimitErrorEnterprise(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. - // This response returns a documentation url like the one returned for GitHub Enterprise, this - // url changes between versions but follows roughly the same format. - 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/enterprise/2.12/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, time.March, 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, time.July, 1, 17, 47, 53, 0, time.UTC).Local()}, - }, - Search: &Rate{ - Limit: 3, - Remaining: 2, - Reset: Timestamp{time.Date(2013, time.July, 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 6437d880..00000000 --- a/vendor/github.com/google/go-github/github/issues_labels_test.go +++ /dev/null @@ -1,360 +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", mediaTypeLabelDescriptionSearchPreview) - 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", mediaTypeLabelDescriptionSearchPreview) - fmt.Fprint(w, `{"url":"u", "name": "n", "color": "c", "description": "d"}`) - }) - - 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"), Description: String("d")} - 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", mediaTypeLabelDescriptionSearchPreview) - 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", mediaTypeLabelDescriptionSearchPreview) - 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", mediaTypeLabelDescriptionSearchPreview) - 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", mediaTypeLabelDescriptionSearchPreview) - 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) { - testHeader(t, r, "Accept", mediaTypeLabelDescriptionSearchPreview) - 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", mediaTypeLabelDescriptionSearchPreview) - 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") - testHeader(t, r, "Accept", mediaTypeLabelDescriptionSearchPreview) - }) - - _, 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", mediaTypeLabelDescriptionSearchPreview) - 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 019f00a8..00000000 --- a/vendor/github.com/google/go-github/github/issues_milestones_test.go +++ /dev/null @@ -1,174 +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") - 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") - 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") - 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") - 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 22190a02..00000000 --- a/vendor/github.com/google/go-github/github/issues_test.go +++ /dev/null @@ -1,328 +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, mediaTypeLabelDescriptionSearchPreview, mediaTypeLockReasonPreview} - 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, mediaTypeLabelDescriptionSearchPreview, mediaTypeLockReasonPreview} - 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, mediaTypeLabelDescriptionSearchPreview, mediaTypeLockReasonPreview} - 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, mediaTypeLabelDescriptionSearchPreview, mediaTypeIntegrationPreview} - 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, mediaTypeLabelDescriptionSearchPreview, mediaTypeLockReasonPreview} - 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", mediaTypeLabelDescriptionSearchPreview) - 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", mediaTypeLabelDescriptionSearchPreview) - 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, nil); err != nil { - t.Errorf("Issues.Lock returned error: %v", err) - } -} - -func TestIssuesService_LockWithReason(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") - testHeader(t, r, "Accept", mediaTypeLockReasonPreview) - w.WriteHeader(http.StatusNoContent) - }) - - opt := &LockIssueOptions{LockReason: "off-topic"} - - if _, err := client.Issues.Lock(context.Background(), "o", "r", 1, opt); 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 a71f6a4e..00000000 --- a/vendor/github.com/google/go-github/github/licenses_test.go +++ /dev/null @@ -1,68 +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") - 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") - 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 0b677cac..00000000 --- a/vendor/github.com/google/go-github/github/messages_test.go +++ /dev/null @@ -1,338 +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: &CheckRunEvent{}, - messageType: "check_run", - }, - { - payload: &CheckSuiteEvent{}, - messageType: "check_suite", - }, - { - 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/migrations_user_test.go b/vendor/github.com/google/go-github/github/migrations_user_test.go deleted file mode 100644 index c271e02a..00000000 --- a/vendor/github.com/google/go-github/github/migrations_user_test.go +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright 2018 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_StartUserMigration(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/user/migrations", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") - testHeader(t, r, "Accept", mediaTypeMigrationsPreview) - - w.WriteHeader(http.StatusCreated) - w.Write(userMigrationJSON) - }) - - opt := &UserMigrationOptions{ - LockRepositories: true, - ExcludeAttachments: false, - } - - got, _, err := client.Migrations.StartUserMigration(context.Background(), []string{"r"}, opt) - if err != nil { - t.Errorf("StartUserMigration returned error: %v", err) - } - - want := wantUserMigration - if !reflect.DeepEqual(want, got) { - t.Errorf("StartUserMigration = %v, want = %v", got, want) - } -} - -func TestMigrationService_ListUserMigrations(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/user/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]", userMigrationJSON))) - }) - - got, _, err := client.Migrations.ListUserMigrations(context.Background()) - if err != nil { - t.Errorf("ListUserMigrations returned error %v", err) - } - - want := []*UserMigration{wantUserMigration} - if !reflect.DeepEqual(want, got) { - t.Errorf("ListUserMigrations = %v, want = %v", got, want) - } -} - -func TestMigrationService_UserMigrationStatus(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/user/migrations/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeMigrationsPreview) - - w.WriteHeader(http.StatusOK) - w.Write(userMigrationJSON) - }) - - got, _, err := client.Migrations.UserMigrationStatus(context.Background(), 1) - if err != nil { - t.Errorf("UserMigrationStatus returned error %v", err) - } - - want := wantUserMigration - if !reflect.DeepEqual(want, got) { - t.Errorf("UserMigrationStatus = %v, want = %v", got, want) - } -} - -func TestMigrationService_UserMigrationArchiveURL(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/user/migrations/1/archive", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeMigrationsPreview) - - http.Redirect(w, r, "/go-github", http.StatusFound) - }) - - mux.HandleFunc("/go-github", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - - w.WriteHeader(http.StatusOK) - }) - - got, err := client.Migrations.UserMigrationArchiveURL(context.Background(), 1) - if err != nil { - t.Errorf("UserMigrationArchiveURL returned error %v", err) - } - - want := "/go-github" - if !strings.HasSuffix(got, want) { - t.Errorf("UserMigrationArchiveURL = %v, want = %v", got, want) - } -} - -func TestMigrationService_DeleteUserMigration(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/user/migrations/1/archive", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") - testHeader(t, r, "Accept", mediaTypeMigrationsPreview) - - w.WriteHeader(http.StatusNoContent) - }) - - got, err := client.Migrations.DeleteUserMigration(context.Background(), 1) - if err != nil { - t.Errorf("DeleteUserMigration returned error %v", err) - } - - if got.StatusCode != http.StatusNoContent { - t.Errorf("DeleteUserMigration returned status = %v, want = %v", got.StatusCode, http.StatusNoContent) - } -} - -func TestMigrationService_UnlockUserRepo(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/user/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) - }) - - got, err := client.Migrations.UnlockUserRepo(context.Background(), 1, "r") - if err != nil { - t.Errorf("UnlockUserRepo returned error %v", err) - } - - if got.StatusCode != http.StatusNoContent { - t.Errorf("UnlockUserRepo returned status = %v, want = %v", got.StatusCode, http.StatusNoContent) - } -} - -var userMigrationJSON = []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 wantUserMigration = &UserMigration{ - 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 b7144f90..00000000 --- a/vendor/github.com/google/go-github/github/misc_test.go +++ /dev/null @@ -1,234 +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"], "importer":["i"], "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"}, - Importer: []string{"i"}, - - 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 1e8ac8cb..00000000 --- a/vendor/github.com/google/go-github/github/orgs_hooks_test.go +++ /dev/null @@ -1,177 +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_CreateHook(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - input := &Hook{Name: String("t"), CreatedAt: &referenceTime} - - mux.HandleFunc("/orgs/o/hooks", func(w http.ResponseWriter, r *http.Request) { - v := new(createHookRequest) - json.NewDecoder(r.Body).Decode(v) - - testMethod(t, r, "POST") - want := &createHookRequest{Name: String("t")} - if !reflect.DeepEqual(v, want) { - t.Errorf("Request body = %+v, want %+v", v, want) - } - - fmt.Fprint(w, `{"id":1}`) - }) - - hook, _, err := client.Organizations.CreateHook(context.Background(), "o", input) - if err != nil { - t.Errorf("Organizations.CreateHook returned error: %v", err) - } - - want := &Hook{ID: Int64(1)} - if !reflect.DeepEqual(hook, want) { - t.Errorf("Organizations.CreateHook returned %+v, want %+v", hook, want) - } -} - -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 e524d03f..00000000 --- a/vendor/github.com/google/go-github/github/orgs_members_test.go +++ /dev/null @@ -1,535 +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 - }, - "team_count": 2, - "invitation_team_url": "https://api.github.com/organizations/2/invitations/1/teams" - } - ]`) - }) - - 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, time.January, 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), - }, - TeamCount: Int(2), - InvitationTeamURL: String("https://api.github.com/organizations/2/invitations/1/teams"), - }} - - if !reflect.DeepEqual(invitations, want) { - t.Errorf("Organizations.ListPendingOrgInvitations returned %+v, want %+v", invitations, want) - } -} - -func TestOrganizationsService_CreateOrgInvitation(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - input := &CreateOrgInvitationOptions{ - Email: String("octocat@github.com"), - Role: String("direct_member"), - TeamID: []int64{ - 12, - 26, - }, - } - - mux.HandleFunc("/orgs/o/invitations", func(w http.ResponseWriter, r *http.Request) { - v := new(CreateOrgInvitationOptions) - json.NewDecoder(r.Body).Decode(v) - - testMethod(t, r, "POST") - testHeader(t, r, "Accept", mediaTypeOrganizationInvitationPreview) - if !reflect.DeepEqual(v, input) { - t.Errorf("Request body = %+v, want %+v", v, input) - } - - fmt.Fprintln(w, `{"email": "octocat@github.com"}`) - - }) - - invitations, _, err := client.Organizations.CreateOrgInvitation(context.Background(), "o", input) - if err != nil { - t.Errorf("Organizations.CreateOrgInvitation returned error: %v", err) - } - - want := &Invitation{Email: String("octocat@github.com")} - if !reflect.DeepEqual(invitations, want) { - t.Errorf("Organizations.ListPendingOrgInvitations returned %+v, want %+v", invitations, want) - } -} - -func TestOrganizationsService_ListOrgInvitationTeams(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/orgs/o/invitations/22/teams", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testFormValues(t, r, values{"page": "1"}) - testHeader(t, r, "Accept", mediaTypeOrganizationInvitationPreview) - fmt.Fprint(w, `[ - { - "id": 1, - "url": "https://api.github.com/teams/1", - "name": "Justice League", - "slug": "justice-league", - "description": "A great team.", - "privacy": "closed", - "permission": "admin", - "members_url": "https://api.github.com/teams/1/members{/member}", - "repositories_url": "https://api.github.com/teams/1/repos" - } - ]`) - }) - - opt := &ListOptions{Page: 1} - invitations, _, err := client.Organizations.ListOrgInvitationTeams(context.Background(), "o", "22", opt) - if err != nil { - t.Errorf("Organizations.ListOrgInvitationTeams returned error: %v", err) - } - - want := []*Team{ - { - ID: Int64(1), - URL: String("https://api.github.com/teams/1"), - Name: String("Justice League"), - Slug: String("justice-league"), - Description: String("A great team."), - Privacy: String("closed"), - Permission: String("admin"), - MembersURL: String("https://api.github.com/teams/1/members{/member}"), - RepositoriesURL: String("https://api.github.com/teams/1/repos"), - }, - } - - if !reflect.DeepEqual(invitations, want) { - t.Errorf("Organizations.ListOrgInvitationTeams 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 efea5cb4..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: String("Project Name"), Body: String("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_test.go b/vendor/github.com/google/go-github/github/orgs_test.go deleted file mode 100644 index 9fe484db..00000000 --- a/vendor/github.com/google/go-github/github/orgs_test.go +++ /dev/null @@ -1,173 +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 := int64(1342004) - mux.HandleFunc("/organizations", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - 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") - 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") - 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") - 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") - 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") - 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 9f12272a..00000000 --- a/vendor/github.com/google/go-github/github/projects_test.go +++ /dev/null @@ -1,384 +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" - "strings" - "testing" -) - -func TestProjectsService_UpdateProject(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - input := &ProjectOptions{ - Name: String("Project Name"), - Body: String("Project body."), - State: String("open"), - Public: Bool(true), - - OrganizationPermission: String("read"), - } - - 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() - - acceptHeaders := []string{mediaTypeProjectsPreview} - mux.HandleFunc("/projects/1/columns", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", ")) - 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{ - "archived_state": "all", - "page": "2"}) - fmt.Fprint(w, `[{"id":1}]`) - }) - - opt := &ProjectCardListOptions{ - ArchivedState: String("all"), - ListOptions: 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, "archived":false}`) - }) - - 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), Archived: Bool(false)} - 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 76b78cf7..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, "pull_request_review_id":42}]`) - }) - - 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), PullRequestReviewID: Int64(42)}} - 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 7c550e1b..00000000 --- a/vendor/github.com/google/go-github/github/pulls_reviewers_test.go +++ /dev/null @@ -1,101 +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") - 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") - 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") - 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 696a1c7f..00000000 --- a/vendor/github.com/google/go-github/github/pulls_test.go +++ /dev/null @@ -1,585 +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() - - acceptHeaders := []string{mediaTypeLabelDescriptionSearchPreview, mediaTypeLockReasonPreview} - mux.HandleFunc("/repos/o/r/pulls", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", ")) - 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() - - acceptHeaders := []string{mediaTypeLabelDescriptionSearchPreview, mediaTypeLockReasonPreview} - mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", ")) - 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_links(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, - "_links":{ - "self":{"href":"https://api.github.com/repos/octocat/Hello-World/pulls/1347"}, - "html":{"href":"https://github.com/octocat/Hello-World/pull/1347"}, - "issue":{"href":"https://api.github.com/repos/octocat/Hello-World/issues/1347"}, - "comments":{"href":"https://api.github.com/repos/octocat/Hello-World/issues/1347/comments"}, - "review_comments":{"href":"https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments"}, - "review_comment":{"href":"https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}"}, - "commits":{"href":"https://api.github.com/repos/octocat/Hello-World/pulls/1347/commits"}, - "statuses":{"href":"https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e"} - } - }`) - }) - - 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), - Links: &PRLinks{ - Self: &PRLink{ - HRef: String("https://api.github.com/repos/octocat/Hello-World/pulls/1347"), - }, HTML: &PRLink{ - HRef: String("https://github.com/octocat/Hello-World/pull/1347"), - }, Issue: &PRLink{ - HRef: String("https://api.github.com/repos/octocat/Hello-World/issues/1347"), - }, Comments: &PRLink{ - HRef: String("https://api.github.com/repos/octocat/Hello-World/issues/1347/comments"), - }, ReviewComments: &PRLink{ - HRef: String("https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments"), - }, ReviewComment: &PRLink{ - HRef: String("https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}"), - }, Commits: &PRLink{ - HRef: String("https://api.github.com/repos/octocat/Hello-World/pulls/1347/commits"), - }, Statuses: &PRLink{ - HRef: String("https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e"), - }, - }, - } - if !reflect.DeepEqual(pull, want) { - t.Errorf("PullRequests.Get returned %+v, want %+v", pull, want) - } -} - -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", mediaTypeLabelDescriptionSearchPreview) - 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 - acceptHeaders := []string{mediaTypeLabelDescriptionSearchPreview, mediaTypeLockReasonPreview} - 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", strings.Join(acceptHeaders, ", ")) - 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 e1baec3f..00000000 --- a/vendor/github.com/google/go-github/github/reactions_test.go +++ /dev/null @@ -1,293 +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) - } - want := []*Reaction{{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}} - if !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) - } - want := []*Reaction{{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}} - if !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) - } - want := []*Reaction{{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}} - if !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) - } - want := []*Reaction{{ID: Int64(1), User: &User{Login: String("l"), ID: Int64(2)}, Content: String("+1")}} - if !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_ListTeamDiscussionReactions(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/teams/1/discussions/2/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.ListTeamDiscussionReactions(context.Background(), 1, 2, nil) - if err != nil { - t.Errorf("ListTeamDiscussionReactions 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("ListTeamDiscussionReactions = %+v, want %+v", got, want) - } -} - -func TestReactionsService_CreateTeamDiscussionReaction(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/teams/1/discussions/2/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.CreateTeamDiscussionReaction(context.Background(), 1, 2, "+1") - if err != nil { - t.Errorf("CreateTeamDiscussionReaction 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("CreateTeamDiscussionReaction = %+v, want %+v", got, want) - } -} - -func TestReactionService_ListTeamDiscussionCommentReactions(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/teams/1/discussions/2/comments/3/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.ListTeamDiscussionCommentReactions(context.Background(), 1, 2, 3, nil) - if err != nil { - t.Errorf("ListTeamDiscussionCommentReactions 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("ListTeamDiscussionCommentReactions = %+v, want %+v", got, want) - } -} - -func TestReactionService_CreateTeamDiscussionCommentReaction(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/teams/1/discussions/2/comments/3/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.CreateTeamDiscussionCommentReaction(context.Background(), 1, 2, 3, "+1") - if err != nil { - t.Errorf("CreateTeamDiscussionCommentReaction 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("CreateTeamDiscussionCommentReaction = %+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 6092af0b..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, time.February, 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 29bab8d2..00000000 --- a/vendor/github.com/google/go-github/github/repos_contents_test.go +++ /dev/null @@ -1,389 +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(%s, %s) returned unexpected error: %v", - stringOrNil(tt.encoding), stringOrNil(tt.content), err) - } - if err == nil && tt.wantErr { - t.Errorf("RepositoryContent(%s, %s) did not return unexpected error", - stringOrNil(tt.encoding), stringOrNil(tt.content)) - } - if want := tt.want; got != want { - t.Errorf("RepositoryContent.GetContent returned %+v, want %+v", got, want) - } - } -} - -// stringOrNil converts a potentially null string pointer to string. -// For non-nil input pointer, the returned string is enclosed in double-quotes. -func stringOrNil(s *string) string { - if s == nil { - return "" - } - return fmt.Sprintf("%q", *s) -} - -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 f6f333aa..00000000 --- a/vendor/github.com/google/go-github/github/repos_deployments_test.go +++ /dev/null @@ -1,161 +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_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") - 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") - 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)} - - 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", mediaTypeDeploymentStatusPreview) - 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") - 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() - - mux.HandleFunc("/repos/o/r/deployments/3/statuses/4", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeDeploymentStatusPreview) - 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)} - - 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", mediaTypeDeploymentStatusPreview) - 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 065f5927..00000000 --- a/vendor/github.com/google/go-github/github/repos_forks_test.go +++ /dev/null @@ -1,105 +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_deferred(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"}) - // This response indicates the fork will happen asynchronously. - w.WriteHeader(http.StatusAccepted) - fmt.Fprint(w, `{"id":1}`) - }) - - opt := &RepositoryCreateForkOptions{Organization: "o"} - repo, _, err := client.Repositories.CreateFork(context.Background(), "o", "r", opt) - if _, ok := err.(*AcceptedError); !ok { - t.Errorf("Repositories.CreateFork returned error: %v (want AcceptedError)", 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 851b68ff..00000000 --- a/vendor/github.com/google/go-github/github/repos_hooks_test.go +++ /dev/null @@ -1,199 +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"), CreatedAt: &referenceTime} - - mux.HandleFunc("/repos/o/r/hooks", func(w http.ResponseWriter, r *http.Request) { - v := new(createHookRequest) - json.NewDecoder(r.Body).Decode(v) - - testMethod(t, r, "POST") - want := &createHookRequest{Name: String("t")} - if !reflect.DeepEqual(v, want) { - t.Errorf("Request body = %+v, want %+v", v, want) - } - - 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_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_prereceive_hooks_test.go b/vendor/github.com/google/go-github/github/repos_prereceive_hooks_test.go deleted file mode 100644 index 8660e594..00000000 --- a/vendor/github.com/google/go-github/github/repos_prereceive_hooks_test.go +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright 2018 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_ListPreReceiveHooks(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/pre-receive-hooks", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypePreReceiveHooksPreview) - testFormValues(t, r, values{"page": "2"}) - fmt.Fprint(w, `[{"id":1}, {"id":2}]`) - }) - - opt := &ListOptions{Page: 2} - - hooks, _, err := client.Repositories.ListPreReceiveHooks(context.Background(), "o", "r", opt) - if err != nil { - t.Errorf("Repositories.ListHooks returned error: %v", err) - } - - want := []*PreReceiveHook{{ID: Int64(1)}, {ID: Int64(2)}} - if !reflect.DeepEqual(hooks, want) { - t.Errorf("Repositories.ListPreReceiveHooks returned %+v, want %+v", hooks, want) - } -} - -func TestRepositoriesService_ListPreReceiveHooks_invalidOwner(t *testing.T) { - client, _, _, teardown := setup() - defer teardown() - - _, _, err := client.Repositories.ListPreReceiveHooks(context.Background(), "%", "%", nil) - testURLParseError(t, err) -} - -func TestRepositoriesService_GetPreReceiveHook(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/pre-receive-hooks/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypePreReceiveHooksPreview) - fmt.Fprint(w, `{"id":1}`) - }) - - hook, _, err := client.Repositories.GetPreReceiveHook(context.Background(), "o", "r", 1) - if err != nil { - t.Errorf("Repositories.GetPreReceiveHook returned error: %v", err) - } - - want := &PreReceiveHook{ID: Int64(1)} - if !reflect.DeepEqual(hook, want) { - t.Errorf("Repositories.GetPreReceiveHook returned %+v, want %+v", hook, want) - } -} - -func TestRepositoriesService_GetPreReceiveHook_invalidOwner(t *testing.T) { - client, _, _, teardown := setup() - defer teardown() - - _, _, err := client.Repositories.GetPreReceiveHook(context.Background(), "%", "%", 1) - testURLParseError(t, err) -} - -func TestRepositoriesService_UpdatePreReceiveHook(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - input := &PreReceiveHook{Name: String("t")} - - mux.HandleFunc("/repos/o/r/pre-receive-hooks/1", func(w http.ResponseWriter, r *http.Request) { - v := new(PreReceiveHook) - 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.UpdatePreReceiveHook(context.Background(), "o", "r", 1, input) - if err != nil { - t.Errorf("Repositories.UpdatePreReceiveHook returned error: %v", err) - } - - want := &PreReceiveHook{ID: Int64(1)} - if !reflect.DeepEqual(hook, want) { - t.Errorf("Repositories.UpdatePreReceiveHook returned %+v, want %+v", hook, want) - } -} - -func TestRepositoriesService_PreReceiveHook_invalidOwner(t *testing.T) { - client, _, _, teardown := setup() - defer teardown() - - _, _, err := client.Repositories.UpdatePreReceiveHook(context.Background(), "%", "%", 1, nil) - testURLParseError(t, err) -} - -func TestRepositoriesService_DeletePreReceiveHook(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/repos/o/r/pre-receive-hooks/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") - }) - - _, err := client.Repositories.DeletePreReceiveHook(context.Background(), "o", "r", 1) - if err != nil { - t.Errorf("Repositories.DeletePreReceiveHook returned error: %v", err) - } -} - -func TestRepositoriesService_DeletePreReceiveHook_invalidOwner(t *testing.T) { - client, _, _, teardown := setup() - defer teardown() - - _, err := client.Repositories.DeletePreReceiveHook(context.Background(), "%", "%", 1) - testURLParseError(t, err) -} 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 2d54eaa1..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: String("Project Name"), Body: String("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 d9a93324..00000000 --- a/vendor/github.com/google/go-github/github/repos_releases_test.go +++ /dev/null @@ -1,385 +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"), - // Fields to be removed: - ID: Int64(2), - CreatedAt: &Timestamp{referenceTime}, - PublishedAt: &Timestamp{referenceTime}, - URL: String("http://url/"), - HTMLURL: String("http://htmlurl/"), - AssetsURL: String("http://assetsurl/"), - Assets: []ReleaseAsset{{ID: Int64(5)}}, - UploadURL: String("http://uploadurl/"), - ZipballURL: String("http://zipballurl/"), - TarballURL: String("http://tarballurl/"), - Author: &User{Name: String("octocat")}, - NodeID: String("nodeid"), - } - - mux.HandleFunc("/repos/o/r/releases", func(w http.ResponseWriter, r *http.Request) { - v := new(repositoryReleaseRequest) - json.NewDecoder(r.Body).Decode(v) - - testMethod(t, r, "POST") - want := &repositoryReleaseRequest{Name: String("v1.0")} - if !reflect.DeepEqual(v, want) { - t.Errorf("Request body = %+v, want %+v", v, want) - } - 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"), - // Fields to be removed: - ID: Int64(2), - CreatedAt: &Timestamp{referenceTime}, - PublishedAt: &Timestamp{referenceTime}, - URL: String("http://url/"), - HTMLURL: String("http://htmlurl/"), - AssetsURL: String("http://assetsurl/"), - Assets: []ReleaseAsset{{ID: Int64(5)}}, - UploadURL: String("http://uploadurl/"), - ZipballURL: String("http://zipballurl/"), - TarballURL: String("http://tarballurl/"), - Author: &User{Name: String("octocat")}, - NodeID: String("nodeid"), - } - - mux.HandleFunc("/repos/o/r/releases/1", func(w http.ResponseWriter, r *http.Request) { - v := new(repositoryReleaseRequest) - json.NewDecoder(r.Body).Decode(v) - - testMethod(t, r, "PATCH") - want := &repositoryReleaseRequest{Name: String("n")} - if !reflect.DeepEqual(v, want) { - t.Errorf("Request body = %+v, want %+v", v, want) - } - 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 e0d7be77..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, time.May, 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, time.May, 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, time.April, 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 08d64412..00000000 --- a/vendor/github.com/google/go-github/github/repos_test.go +++ /dev/null @@ -1,1238 +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{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{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{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{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"), - Archived: Bool(true), // not passed along. - } - - mux.HandleFunc("/user/repos", func(w http.ResponseWriter, r *http.Request) { - v := new(createRepoRequest) - json.NewDecoder(r.Body).Decode(v) - - testMethod(t, r, "POST") - want := &createRepoRequest{Name: String("n")} - if !reflect.DeepEqual(v, want) { - t.Errorf("Request body = %+v, want %+v", v, want) - } - - 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"), - Archived: Bool(true), // not passed along. - } - - mux.HandleFunc("/orgs/o/repos", func(w http.ResponseWriter, r *http.Request) { - v := new(createRepoRequest) - json.NewDecoder(r.Body).Decode(v) - - testMethod(t, r, "POST") - want := &createRepoRequest{Name: String("n")} - if !reflect.DeepEqual(v, want) { - t.Errorf("Request body = %+v, want %+v", v, want) - } - - 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_Get(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - acceptHeaders := []string{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") - 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") - // TODO: remove custom Accept header when this API fully launches - testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - 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") - // TODO: remove custom Accept header when this API fully launches - testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - 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") - // TODO: remove custom Accept header when this API fully launches - testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - 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, - "required_approving_review_count":1 - }, - "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, - RequiredApprovingReviewCount: 1, - }, - 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) - } - - // TODO: remove custom Accept header when this API fully launches - testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - 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") - // TODO: remove custom Accept header when this API fully launches - testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - 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") - // TODO: remove custom Accept header when this API fully launches - testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - 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_UpdateRequiredStatusChecks(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - input := &RequiredStatusChecksRequest{ - Strict: Bool(true), - Contexts: []string{"continuous-integration"}, - } - - mux.HandleFunc("/repos/o/r/branches/b/protection/required_status_checks", func(w http.ResponseWriter, r *http.Request) { - v := new(RequiredStatusChecksRequest) - 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", mediaTypeV3) - fmt.Fprintf(w, `{"strict":true,"contexts":["continuous-integration"]}`) - }) - - statusChecks, _, err := client.Repositories.UpdateRequiredStatusChecks(context.Background(), "o", "r", "b", input) - if err != nil { - t.Errorf("Repositories.UpdateRequiredStatusChecks returned error: %v", err) - } - - want := &RequiredStatusChecks{ - Strict: true, - Contexts: []string{"continuous-integration"}, - } - if !reflect.DeepEqual(statusChecks, want) { - t.Errorf("Repositories.UpdateRequiredStatusChecks returned %+v, want %+v", statusChecks, 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") - // TODO: remove custom Accept header when this API fully launches - testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - 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") - // TODO: remove custom Accept header when this API fully launches - testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - fmt.Fprintf(w, `{ - "dismissal_restrictions":{ - "users":[{"id":1,"login":"u"}], - "teams":[{"id":2,"slug":"t"}] - }, - "dismiss_stale_reviews":true, - "require_code_owner_reviews":true, - "required_approving_review_count":1 - }`) - }) - - 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, - RequiredApprovingReviewCount: 1, - } - - 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) - } - // TODO: remove custom Accept header when this API fully launches - testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - fmt.Fprintf(w, `{ - "dismissal_restrictions":{ - "users":[{"id":1,"login":"u"}], - "teams":[{"id":2,"slug":"t"}] - }, - "dismiss_stale_reviews":true, - "require_code_owner_reviews":true, - "required_approving_review_count":3 - }`) - }) - - 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, - RequiredApprovingReviewCount: 3, - } - 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") - // TODO: remove custom Accept header when this API fully launches - testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - testBody(t, r, `{"dismissal_restrictions":[]}`+"\n") - fmt.Fprintf(w, `{"dismissal_restrictions":{"users":[],"teams":[]},"dismiss_stale_reviews":true,"require_code_owner_reviews":true,"required_approving_review_count":1}`) - }) - - 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, - RequiredApprovingReviewCount: 1, - } - 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", mediaTypeRequiredApprovingReviewsPreview) - 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", mediaTypeRequiredApprovingReviewsPreview) - 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", mediaTypeRequiredApprovingReviewsPreview) - 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", mediaTypeRequiredApprovingReviewsPreview) - 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{} - - got, err := json.Marshal(req) - if err != nil { - t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned error: %v", err) - } - - want := `{"dismiss_stale_reviews":false,"require_code_owner_reviews":false,"required_approving_review_count":0}` - if want != string(got) { - t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned %+v, want %+v", string(got), want) - } - - req = PullRequestReviewsEnforcementRequest{ - DismissalRestrictionsRequest: &DismissalRestrictionsRequest{}, - } - - got, 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,"required_approving_review_count":0}` - if want != string(got) { - t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned %+v, want %+v", string(got), want) - } - - req = PullRequestReviewsEnforcementRequest{ - DismissalRestrictionsRequest: &DismissalRestrictionsRequest{ - Users: &[]string{}, - Teams: &[]string{}, - }, - } - - got, err = json.Marshal(req) - if err != nil { - t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned error: %v", err) - } - - want = `{"dismissal_restrictions":{"users":[],"teams":[]},"dismiss_stale_reviews":false,"require_code_owner_reviews":false,"required_approving_review_count":0}` - if want != string(got) { - t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned %+v, want %+v", string(got), 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 f6e40d21..00000000 --- a/vendor/github.com/google/go-github/github/search_test.go +++ /dev/null @@ -1,351 +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_withQualifiersNoOpts(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - const q = "gopher is:issue label:bug language:go pushed:>=2018-01-01 stars:>=200" - - var requestURI string - mux.HandleFunc("/search/issues", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testFormValues(t, r, values{ - "q": q, - }) - requestURI = r.RequestURI - - fmt.Fprint(w, `{"total_count": 4, "incomplete_results": true, "items": [{"number":1},{"number":2}]}`) - }) - - opts := &SearchOptions{} - result, _, err := client.Search.Issues(context.Background(), q, opts) - if err != nil { - t.Errorf("Search.Issues returned error: %v", err) - } - - if want := "/api-v3/search/issues?q=gopher+is:issue+label:bug+language:go+pushed:%3E=2018-01-01+stars:%3E=200"; requestURI != want { - t.Fatalf("URI encoding failed: got %v, want %v", requestURI, want) - } - - 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_withQualifiersAndOpts(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - const q = "gopher is:issue label:bug language:go pushed:>=2018-01-01 stars:>=200" - - var requestURI string - mux.HandleFunc("/search/issues", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testFormValues(t, r, values{ - "q": q, - "sort": "forks", - }) - requestURI = r.RequestURI - - fmt.Fprint(w, `{"total_count": 4, "incomplete_results": true, "items": [{"number":1},{"number":2}]}`) - }) - - opts := &SearchOptions{Sort: "forks"} - result, _, err := client.Search.Issues(context.Background(), q, opts) - if err != nil { - t.Errorf("Search.Issues returned error: %v", err) - } - - if want := "/api-v3/search/issues?q=gopher+is:issue+label:bug+language:go+pushed:%3E=2018-01-01+stars:%3E=200&sort=forks"; requestURI != want { - t.Fatalf("URI encoding failed: got %v, want %v", requestURI, want) - } - - 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) - } -} - -func TestSearchService_Labels(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/search/labels", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testFormValues(t, r, values{ - "repository_id": "1234", - "q": "blah", - "sort": "updated", - "order": "desc", - "page": "2", - "per_page": "2", - }) - - fmt.Fprint(w, `{"total_count": 4, "incomplete_results": false, "items": [{"id": 1234, "name":"bug", "description": "some text"},{"id": 4567, "name":"feature"}]}`) - }) - - opts := &SearchOptions{Sort: "updated", Order: "desc", ListOptions: ListOptions{Page: 2, PerPage: 2}} - result, _, err := client.Search.Labels(context.Background(), 1234, "blah", opts) - if err != nil { - t.Errorf("Search.Code returned error: %v", err) - } - - want := &LabelsSearchResult{ - Total: Int(4), - IncompleteResults: Bool(false), - Labels: []*LabelResult{ - {ID: Int64(1234), Name: String("bug"), Description: String("some text")}, - {ID: Int64(4567), Name: String("feature")}, - }, - } - if !reflect.DeepEqual(result, want) { - t.Errorf("Search.Labels 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 e16d4a54..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, time.January, 02, 15, 04, 05, 0, time.UTC)}, - `github.Timestamp{2006-01-02 15:04:05 +0000 UTC}`, - }, - { - &Timestamp{time.Date(2006, time.January, 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{ID:1, Config:map[]}`}, - {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/teams_discussion_comments_test.go b/vendor/github.com/google/go-github/github/teams_discussion_comments_test.go deleted file mode 100644 index f4c9f96f..00000000 --- a/vendor/github.com/google/go-github/github/teams_discussion_comments_test.go +++ /dev/null @@ -1,203 +0,0 @@ -// Copyright 2018 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 TestTeamsService_ListComments(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/teams/2/discussions/3/comments", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeTeamDiscussionsPreview) - testFormValues(t, r, values{ - "direction": "desc", - }) - fmt.Fprintf(w, - `[ - { - "author": { - "login": "author", - "id": 0, - "avatar_url": "https://avatars1.githubusercontent.com/u/0?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/author", - "html_url": "https://github.com/author", - "followers_url": "https://api.github.com/users/author/followers", - "following_url": "https://api.github.com/users/author/following{/other_user}", - "gists_url": "https://api.github.com/users/author/gists{/gist_id}", - "starred_url": "https://api.github.com/users/author/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/author/subscriptions", - "organizations_url": "https://api.github.com/users/author/orgs", - "repos_url": "https://api.github.com/users/author/repos", - "events_url": "https://api.github.com/users/author/events{/privacy}", - "received_events_url": "https://api.github.com/users/author/received_events", - "type": "User", - "site_admin": false - }, - "body": "comment", - "body_html": "

comment

", - "body_version": "version", - "created_at": "2018-01-01T00:00:00Z", - "last_edited_at": null, - "discussion_url": "https://api.github.com/teams/2/discussions/3", - "html_url": "https://github.com/orgs/1/teams/2/discussions/3/comments/4", - "node_id": "node", - "number": 4, - "updated_at": "2018-01-01T00:00:00Z", - "url": "https://api.github.com/teams/2/discussions/3/comments/4" - } - ]`) - }) - - comments, _, err := client.Teams.ListComments(context.Background(), 2, 3, &DiscussionCommentListOptions{"desc"}) - if err != nil { - t.Errorf("Teams.ListComments returned error: %v", err) - } - - want := []*DiscussionComment{ - { - Author: &User{ - Login: String("author"), - ID: Int64(0), - AvatarURL: String("https://avatars1.githubusercontent.com/u/0?v=4"), - GravatarID: String(""), - URL: String("https://api.github.com/users/author"), - HTMLURL: String("https://github.com/author"), - FollowersURL: String("https://api.github.com/users/author/followers"), - FollowingURL: String("https://api.github.com/users/author/following{/other_user}"), - GistsURL: String("https://api.github.com/users/author/gists{/gist_id}"), - StarredURL: String("https://api.github.com/users/author/starred{/owner}{/repo}"), - SubscriptionsURL: String("https://api.github.com/users/author/subscriptions"), - OrganizationsURL: String("https://api.github.com/users/author/orgs"), - ReposURL: String("https://api.github.com/users/author/repos"), - EventsURL: String("https://api.github.com/users/author/events{/privacy}"), - ReceivedEventsURL: String("https://api.github.com/users/author/received_events"), - Type: String("User"), - SiteAdmin: Bool(false), - }, - Body: String("comment"), - BodyHTML: String("

comment

"), - BodyVersion: String("version"), - CreatedAt: &Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)}, - LastEditedAt: nil, - DiscussionURL: String("https://api.github.com/teams/2/discussions/3"), - HTMLURL: String("https://github.com/orgs/1/teams/2/discussions/3/comments/4"), - NodeID: String("node"), - Number: Int(4), - UpdatedAt: &Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)}, - URL: String("https://api.github.com/teams/2/discussions/3/comments/4"), - }, - } - if !reflect.DeepEqual(comments, want) { - t.Errorf("Teams.ListComments returned %+v, want %+v", comments, want) - } -} - -func TestTeamsService_GetComment(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/teams/2/discussions/3/comments/4", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeTeamDiscussionsPreview) - fmt.Fprint(w, `{"number":4}`) - }) - - comment, _, err := client.Teams.GetComment(context.Background(), 2, 3, 4) - if err != nil { - t.Errorf("Teams.GetComment returned error: %v", err) - } - - want := &DiscussionComment{Number: Int(4)} - if !reflect.DeepEqual(comment, want) { - t.Errorf("Teams.GetComment returned %+v, want %+v", comment, want) - } -} - -func TestTeamsService_CreateComment(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - input := DiscussionComment{Body: String("c")} - - mux.HandleFunc("/teams/2/discussions/3/comments", func(w http.ResponseWriter, r *http.Request) { - v := new(DiscussionComment) - json.NewDecoder(r.Body).Decode(v) - - testMethod(t, r, "POST") - testHeader(t, r, "Accept", mediaTypeTeamDiscussionsPreview) - if !reflect.DeepEqual(v, &input) { - t.Errorf("Request body = %+v, want %+v", v, input) - } - - fmt.Fprint(w, `{"number":4}`) - }) - - comment, _, err := client.Teams.CreateComment(context.Background(), 2, 3, input) - if err != nil { - t.Errorf("Teams.CreateComment returned error: %v", err) - } - - want := &DiscussionComment{Number: Int(4)} - if !reflect.DeepEqual(comment, want) { - t.Errorf("Teams.CreateComment returned %+v, want %+v", comment, want) - } -} - -func TestTeamsService_EditComment(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - input := DiscussionComment{Body: String("e")} - - mux.HandleFunc("/teams/2/discussions/3/comments/4", func(w http.ResponseWriter, r *http.Request) { - v := new(DiscussionComment) - json.NewDecoder(r.Body).Decode(v) - - testMethod(t, r, "PATCH") - testHeader(t, r, "Accept", mediaTypeTeamDiscussionsPreview) - if !reflect.DeepEqual(v, &input) { - t.Errorf("Request body = %+v, want %+v", v, input) - } - - fmt.Fprint(w, `{"number":4}`) - }) - - comment, _, err := client.Teams.EditComment(context.Background(), 2, 3, 4, input) - if err != nil { - t.Errorf("Teams.EditComment returned error: %v", err) - } - - want := &DiscussionComment{Number: Int(4)} - if !reflect.DeepEqual(comment, want) { - t.Errorf("Teams.EditComment returned %+v, want %+v", comment, want) - } -} - -func TestTeamsService_DeleteComment(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/teams/2/discussions/3/comments/4", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") - testHeader(t, r, "Accept", mediaTypeTeamDiscussionsPreview) - }) - - _, err := client.Teams.DeleteComment(context.Background(), 2, 3, 4) - if err != nil { - t.Errorf("Teams.DeleteComment returned error: %v", err) - } -} diff --git a/vendor/github.com/google/go-github/github/teams_discussions_test.go b/vendor/github.com/google/go-github/github/teams_discussions_test.go deleted file mode 100644 index c588c228..00000000 --- a/vendor/github.com/google/go-github/github/teams_discussions_test.go +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright 2018 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 TestTeamsService_ListDiscussions(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/teams/2/discussions", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeTeamDiscussionsPreview) - testFormValues(t, r, values{ - "direction": "desc", - }) - fmt.Fprintf(w, - `[ - { - "author": { - "login": "author", - "id": 0, - "avatar_url": "https://avatars1.githubusercontent.com/u/0?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/author", - "html_url": "https://github.com/author", - "followers_url": "https://api.github.com/users/author/followers", - "following_url": "https://api.github.com/users/author/following{/other_user}", - "gists_url": "https://api.github.com/users/author/gists{/gist_id}", - "starred_url": "https://api.github.com/users/author/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/author/subscriptions", - "organizations_url": "https://api.github.com/users/author/orgs", - "repos_url": "https://api.github.com/users/author/repos", - "events_url": "https://api.github.com/users/author/events{/privacy}", - "received_events_url": "https://api.github.com/users/author/received_events", - "type": "User", - "site_admin": false - }, - "body": "test", - "body_html": "

test

", - "body_version": "version", - "comments_count": 1, - "comments_url": "https://api.github.com/teams/2/discussions/3/comments", - "created_at": "2018-01-01T00:00:00Z", - "last_edited_at": null, - "html_url": "https://github.com/orgs/1/teams/2/discussions/3", - "node_id": "node", - "number": 3, - "pinned": false, - "private": false, - "team_url": "https://api.github.com/teams/2", - "title": "test", - "updated_at": "2018-01-01T00:00:00Z", - "url": "https://api.github.com/teams/2/discussions/3" - } - ]`) - }) - discussions, _, err := client.Teams.ListDiscussions(context.Background(), 2, &DiscussionListOptions{"desc"}) - if err != nil { - t.Errorf("Teams.ListDiscussions returned error: %v", err) - } - - want := []*TeamDiscussion{ - { - Author: &User{ - Login: String("author"), - ID: Int64(0), - AvatarURL: String("https://avatars1.githubusercontent.com/u/0?v=4"), - GravatarID: String(""), - URL: String("https://api.github.com/users/author"), - HTMLURL: String("https://github.com/author"), - FollowersURL: String("https://api.github.com/users/author/followers"), - FollowingURL: String("https://api.github.com/users/author/following{/other_user}"), - GistsURL: String("https://api.github.com/users/author/gists{/gist_id}"), - StarredURL: String("https://api.github.com/users/author/starred{/owner}{/repo}"), - SubscriptionsURL: String("https://api.github.com/users/author/subscriptions"), - OrganizationsURL: String("https://api.github.com/users/author/orgs"), - ReposURL: String("https://api.github.com/users/author/repos"), - EventsURL: String("https://api.github.com/users/author/events{/privacy}"), - ReceivedEventsURL: String("https://api.github.com/users/author/received_events"), - Type: String("User"), - SiteAdmin: Bool(false), - }, - Body: String("test"), - BodyHTML: String("

test

"), - BodyVersion: String("version"), - CommentsCount: Int(1), - CommentsURL: String("https://api.github.com/teams/2/discussions/3/comments"), - CreatedAt: &Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)}, - LastEditedAt: nil, - HTMLURL: String("https://github.com/orgs/1/teams/2/discussions/3"), - NodeID: String("node"), - Number: Int(3), - Pinned: Bool(false), - Private: Bool(false), - TeamURL: String("https://api.github.com/teams/2"), - Title: String("test"), - UpdatedAt: &Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)}, - URL: String("https://api.github.com/teams/2/discussions/3"), - }, - } - if !reflect.DeepEqual(discussions, want) { - t.Errorf("Teams.ListDiscussions returned %+v, want %+v", discussions, want) - } -} - -func TestTeamsService_GetDiscussion(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/teams/2/discussions/3", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeTeamDiscussionsPreview) - fmt.Fprint(w, `{"number":3}`) - }) - - discussion, _, err := client.Teams.GetDiscussion(context.Background(), 2, 3) - if err != nil { - t.Errorf("Teams.GetDiscussion returned error: %v", err) - } - - want := &TeamDiscussion{Number: Int(3)} - if !reflect.DeepEqual(discussion, want) { - t.Errorf("Teams.GetDiscussion returned %+v, want %+v", discussion, want) - } -} - -func TestTeamsService_CreateDiscussion(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - input := TeamDiscussion{Title: String("c_t"), Body: String("c_b")} - - mux.HandleFunc("/teams/2/discussions", func(w http.ResponseWriter, r *http.Request) { - v := new(TeamDiscussion) - json.NewDecoder(r.Body).Decode(v) - - testMethod(t, r, "POST") - testHeader(t, r, "Accept", mediaTypeTeamDiscussionsPreview) - if !reflect.DeepEqual(v, &input) { - t.Errorf("Request body = %+v, want %+v", v, input) - } - - fmt.Fprint(w, `{"number":3}`) - }) - - comment, _, err := client.Teams.CreateDiscussion(context.Background(), 2, input) - if err != nil { - t.Errorf("Teams.CreateDiscussion returned error: %v", err) - } - - want := &TeamDiscussion{Number: Int(3)} - if !reflect.DeepEqual(comment, want) { - t.Errorf("Teams.CreateDiscussion returned %+v, want %+v", comment, want) - } -} - -func TestTeamsService_EditDiscussion(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - input := TeamDiscussion{Title: String("e_t"), Body: String("e_b")} - - mux.HandleFunc("/teams/2/discussions/3", func(w http.ResponseWriter, r *http.Request) { - v := new(TeamDiscussion) - json.NewDecoder(r.Body).Decode(v) - - testMethod(t, r, "PATCH") - testHeader(t, r, "Accept", mediaTypeTeamDiscussionsPreview) - if !reflect.DeepEqual(v, &input) { - t.Errorf("Request body = %+v, want %+v", v, input) - } - - fmt.Fprint(w, `{"number":3}`) - }) - - comment, _, err := client.Teams.EditDiscussion(context.Background(), 2, 3, input) - if err != nil { - t.Errorf("Teams.EditDiscussion returned error: %v", err) - } - - want := &TeamDiscussion{Number: Int(3)} - if !reflect.DeepEqual(comment, want) { - t.Errorf("Teams.EditDiscussion returned %+v, want %+v", comment, want) - } -} - -func TestTeamsService_DeleteDiscussion(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/teams/2/discussions/3", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") - testHeader(t, r, "Accept", mediaTypeTeamDiscussionsPreview) - }) - - _, err := client.Teams.DeleteDiscussion(context.Background(), 2, 3) - if err != nil { - t.Errorf("Teams.DeleteDiscussion returned error: %v", err) - } -} diff --git a/vendor/github.com/google/go-github/github/teams_members_test.go b/vendor/github.com/google/go-github/github/teams_members_test.go deleted file mode 100644 index 2489da0e..00000000 --- a/vendor/github.com/google/go-github/github/teams_members_test.go +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright 2018 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 TestTeamsService__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 := &TeamListTeamMembersOptions{Role: "member", ListOptions: ListOptions{Page: 2}} - members, _, err := client.Teams.ListTeamMembers(context.Background(), 1, opt) - if err != nil { - t.Errorf("Teams.ListTeamMembers returned error: %v", err) - } - - want := []*User{{ID: Int64(1)}} - if !reflect.DeepEqual(members, want) { - t.Errorf("Teams.ListTeamMembers returned %+v, want %+v", members, want) - } -} - -func TestTeamsService__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.Teams.IsTeamMember(context.Background(), 1, "u") - if err != nil { - t.Errorf("Teams.IsTeamMember returned error: %v", err) - } - if want := true; member != want { - t.Errorf("Teams.IsTeamMember returned %+v, want %+v", member, want) - } -} - -// ensure that a 404 response is interpreted as "false" and not an error -func TestTeamsService__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.Teams.IsTeamMember(context.Background(), 1, "u") - if err != nil { - t.Errorf("Teams.IsTeamMember returned error: %+v", err) - } - if want := false; member != want { - t.Errorf("Teams.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 TestTeamsService__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.Teams.IsTeamMember(context.Background(), 1, "u") - if err == nil { - t.Errorf("Expected HTTP 400 response") - } - if want := false; member != want { - t.Errorf("Teams.IsTeamMember returned %+v, want %+v", member, want) - } -} - -func TestTeamsService__IsTeamMember_invalidUser(t *testing.T) { - client, _, _, teardown := setup() - defer teardown() - - _, _, err := client.Teams.IsTeamMember(context.Background(), 1, "%") - testURLParseError(t, err) -} - -func TestTeamsService__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.Teams.GetTeamMembership(context.Background(), 1, "u") - if err != nil { - t.Errorf("Teams.GetTeamMembership returned error: %v", err) - } - - want := &Membership{URL: String("u"), State: String("active")} - if !reflect.DeepEqual(membership, want) { - t.Errorf("Teams.GetTeamMembership returned %+v, want %+v", membership, want) - } -} - -func TestTeamsService__AddTeamMembership(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - opt := &TeamAddTeamMembershipOptions{Role: "maintainer"} - - mux.HandleFunc("/teams/1/memberships/u", func(w http.ResponseWriter, r *http.Request) { - v := new(TeamAddTeamMembershipOptions) - 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.Teams.AddTeamMembership(context.Background(), 1, "u", opt) - if err != nil { - t.Errorf("Teams.AddTeamMembership returned error: %v", err) - } - - want := &Membership{URL: String("u"), State: String("pending")} - if !reflect.DeepEqual(membership, want) { - t.Errorf("Teams.AddTeamMembership returned %+v, want %+v", membership, want) - } -} - -func TestTeamsService__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.Teams.RemoveTeamMembership(context.Background(), 1, "u") - if err != nil { - t.Errorf("Teams.RemoveTeamMembership returned error: %v", err) - } -} diff --git a/vendor/github.com/google/go-github/github/teams_test.go b/vendor/github.com/google/go-github/github/teams_test.go deleted file mode 100644 index 89708b4f..00000000 --- a/vendor/github.com/google/go-github/github/teams_test.go +++ /dev/null @@ -1,465 +0,0 @@ -// Copyright 2018 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 TestTeamsService_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.Teams.ListTeams(context.Background(), "o", opt) - if err != nil { - t.Errorf("Teams.ListTeams returned error: %v", err) - } - - want := []*Team{{ID: Int64(1)}} - if !reflect.DeepEqual(teams, want) { - t.Errorf("Teams.ListTeams returned %+v, want %+v", teams, want) - } -} - -func TestTeamsService_ListTeams_invalidOrg(t *testing.T) { - client, _, _, teardown := setup() - defer teardown() - - _, _, err := client.Teams.ListTeams(context.Background(), "%", nil) - testURLParseError(t, err) -} - -func TestTeamsService_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.Teams.GetTeam(context.Background(), 1) - if err != nil { - t.Errorf("Teams.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("Teams.GetTeam returned %+v, want %+v", team, want) - } -} - -func TestTeamsService_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.Teams.GetTeam(context.Background(), 1) - if err != nil { - t.Errorf("Teams.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("Teams.GetTeam returned %+v, want %+v", team, want) - } -} - -func TestTeamsService_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.Teams.CreateTeam(context.Background(), "o", input) - if err != nil { - t.Errorf("Teams.CreateTeam returned error: %v", err) - } - - want := &Team{ID: Int64(1)} - if !reflect.DeepEqual(team, want) { - t.Errorf("Teams.CreateTeam returned %+v, want %+v", team, want) - } -} - -func TestTeamsService_CreateTeam_invalidOrg(t *testing.T) { - client, _, _, teardown := setup() - defer teardown() - - _, _, err := client.Teams.CreateTeam(context.Background(), "%", NewTeam{}) - testURLParseError(t, err) -} - -func TestTeamsService_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.Teams.EditTeam(context.Background(), 1, input) - if err != nil { - t.Errorf("Teams.EditTeam returned error: %v", err) - } - - want := &Team{ID: Int64(1)} - if !reflect.DeepEqual(team, want) { - t.Errorf("Teams.EditTeam returned %+v, want %+v", team, want) - } -} - -func TestTeamsService_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.Teams.DeleteTeam(context.Background(), 1) - if err != nil { - t.Errorf("Teams.DeleteTeam returned error: %v", err) - } -} - -func TestTeamsService_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.Teams.ListChildTeams(context.Background(), 1, opt) - if err != nil { - t.Errorf("Teams.ListTeams returned error: %v", err) - } - - want := []*Team{{ID: Int64(2)}} - if !reflect.DeepEqual(teams, want) { - t.Errorf("Teams.ListTeams returned %+v, want %+v", teams, want) - } -} - -func TestTeamsService_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.Teams.ListTeamRepos(context.Background(), 1, opt) - if err != nil { - t.Errorf("Teams.ListTeamRepos returned error: %v", err) - } - - want := []*Repository{{ID: Int64(1)}} - if !reflect.DeepEqual(members, want) { - t.Errorf("Teams.ListTeamRepos returned %+v, want %+v", members, want) - } -} - -func TestTeamsService_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.Teams.IsTeamRepo(context.Background(), 1, "o", "r") - if err != nil { - t.Errorf("Teams.IsTeamRepo returned error: %v", err) - } - - want := &Repository{ID: Int64(1)} - if !reflect.DeepEqual(repo, want) { - t.Errorf("Teams.IsTeamRepo returned %+v, want %+v", repo, want) - } -} - -func TestTeamsService_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.Teams.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("Teams.IsTeamRepo returned status %d, want %d", got, want) - } - if repo != nil { - t.Errorf("Teams.IsTeamRepo returned %+v, want nil", repo) - } -} - -func TestTeamsService_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.Teams.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("Teams.IsTeamRepo returned status %d, want %d", got, want) - } - if repo != nil { - t.Errorf("Teams.IsTeamRepo returned %+v, want nil", repo) - } -} - -func TestTeamsService_IsTeamRepo_invalidOwner(t *testing.T) { - client, _, _, teardown := setup() - defer teardown() - - _, _, err := client.Teams.IsTeamRepo(context.Background(), 1, "%", "r") - testURLParseError(t, err) -} - -func TestTeamsService_AddTeamRepo(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - opt := &TeamAddTeamRepoOptions{Permission: "admin"} - - mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { - v := new(TeamAddTeamRepoOptions) - 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.Teams.AddTeamRepo(context.Background(), 1, "o", "r", opt) - if err != nil { - t.Errorf("Teams.AddTeamRepo returned error: %v", err) - } -} - -func TestTeamsService_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.Teams.AddTeamRepo(context.Background(), 1, "o", "r", nil) - if err == nil { - t.Errorf("Expcted error to be returned") - } -} - -func TestTeamsService_AddTeamRepo_invalidOwner(t *testing.T) { - client, _, _, teardown := setup() - defer teardown() - - _, err := client.Teams.AddTeamRepo(context.Background(), 1, "%", "r", nil) - testURLParseError(t, err) -} - -func TestTeamsService_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.Teams.RemoveTeamRepo(context.Background(), 1, "o", "r") - if err != nil { - t.Errorf("Teams.RemoveTeamRepo returned error: %v", err) - } -} - -func TestTeamsService_RemoveTeamRepo_invalidOwner(t *testing.T) { - client, _, _, teardown := setup() - defer teardown() - - _, err := client.Teams.RemoveTeamRepo(context.Background(), 1, "%", "r") - testURLParseError(t, err) -} - -func TestTeamsService_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.Teams.ListUserTeams(context.Background(), opt) - if err != nil { - t.Errorf("Teams.ListUserTeams returned error: %v", err) - } - - want := []*Team{{ID: Int64(1)}} - if !reflect.DeepEqual(teams, want) { - t.Errorf("Teams.ListUserTeams returned %+v, want %+v", teams, want) - } -} - -func TestTeamsService_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.Teams.ListPendingTeamInvitations(context.Background(), 1, opt) - if err != nil { - t.Errorf("Teams.ListPendingTeamInvitations returned error: %v", err) - } - - createdAt := time.Date(2017, time.January, 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("Teams.ListPendingTeamInvitations returned %+v, want %+v", invitations, want) - } -} 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 dc09eaf9..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, time.January, 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 b0119087..00000000 --- a/vendor/github.com/google/go-github/github/users_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" - "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_GetHovercard(t *testing.T) { - client, mux, _, teardown := setup() - defer teardown() - - mux.HandleFunc("/users/u/hovercard", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeHovercardPreview) - testFormValues(t, r, values{"subject_type": "repository", "subject_id": "20180408"}) - fmt.Fprint(w, `{"contexts": [{"message":"Owns this repository", "octicon": "repo"}]}`) - }) - - opt := &HovercardOptions{SubjectType: "repository", SubjectID: "20180408"} - hovercard, _, err := client.Users.GetHovercard(context.Background(), "u", opt) - if err != nil { - t.Errorf("Users.GetHovercard returned error: %v", err) - } - - want := &Hovercard{Contexts: []*UserContext{{Message: String("Owns this repository"), Octicon: String("repo")}}} - if !reflect.DeepEqual(hovercard, want) { - t.Errorf("Users.GetHovercard returned %+v, want %+v", hovercard, 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/go.mod b/vendor/github.com/google/go-github/go.mod deleted file mode 100644 index 9fb89f5d..00000000 --- a/vendor/github.com/google/go-github/go.mod +++ /dev/null @@ -1,11 +0,0 @@ -module github.com/google/go-github/v18 - -require ( - github.com/golang/protobuf v1.2.0 // indirect - github.com/google/go-querystring v1.0.0 - golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac - golang.org/x/net v0.0.0-20180826012351-8a410e7b638d // indirect - golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be - golang.org/x/sys v0.0.0-20180824143301-4910a1d54f87 // indirect - google.golang.org/appengine v1.1.0 -) diff --git a/vendor/github.com/google/go-github/go.sum b/vendor/github.com/google/go-github/go.sum deleted file mode 100644 index 058a096e..00000000 --- a/vendor/github.com/google/go-github/go.sum +++ /dev/null @@ -1,16 +0,0 @@ -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 h1:zLTLjkaOFEFIOxY5BWLFLwh+cL8vOBW4XJ2aqLE/Tf0= -github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac h1:7d7lG9fHOLdL6jZPtnV4LpI41SbohIJ1Atq7U991dMg= -golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d h1:g9qWBGx4puODJTMVyoPrpoxPFgVGd+z1DZwjfRu4d0I= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sys v0.0.0-20180824143301-4910a1d54f87 h1:GqwDwfvIpC33dK9bA1fD+JiDUNsuAiQiEkpHqUKze4o= -golang.org/x/sys v0.0.0-20180824143301-4910a1d54f87/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -google.golang.org/appengine v1.1.0 h1:igQkv0AAhEIvTEpD5LIpAfav2eeVO9HBTjvKHVJPRSs= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 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:** [![Build Status](https://drone.io/github.com/google/go-querystring/status.png)](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/go.mod b/vendor/github.com/google/go-querystring/go.mod deleted file mode 100644 index 45dca2d3..00000000 --- a/vendor/github.com/google/go-querystring/go.mod +++ /dev/null @@ -1 +0,0 @@ -module github.com/google/go-querystring 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/opencontainers/runc/Godeps/_workspace/src/github.com/Sirupsen/logrus/LICENSE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/Sirupsen/logrus/LICENSE new file mode 100644 index 00000000..f090cb42 --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/Sirupsen/logrus/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Simon Eskildsen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/codegangsta/cli/LICENSE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/codegangsta/cli/LICENSE new file mode 100644 index 00000000..5515ccfb --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/codegangsta/cli/LICENSE @@ -0,0 +1,21 @@ +Copyright (C) 2013 Jeremy Saenz +All Rights Reserved. + +MIT LICENSE + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/coreos/go-systemd/LICENSE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/coreos/go-systemd/LICENSE new file mode 100644 index 00000000..37ec93a1 --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/coreos/go-systemd/LICENSE @@ -0,0 +1,191 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/LICENSE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/LICENSE new file mode 100644 index 00000000..c7a3f0cf --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/LICENSE @@ -0,0 +1,191 @@ + + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2013-2015 Docker, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/NOTICE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/NOTICE new file mode 100644 index 00000000..6e6f469a --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/NOTICE @@ -0,0 +1,19 @@ +Docker +Copyright 2012-2015 Docker, Inc. + +This product includes software developed at Docker, Inc. (https://www.docker.com). + +This product contains software (https://github.com/kr/pty) developed +by Keith Rarick, licensed under the MIT License. + +The following is courtesy of our legal counsel: + + +Use and transfer of Docker may be subject to certain restrictions by the +United States and other governments. +It is your responsibility to ensure that your use and/or transfer does not +violate applicable laws. + +For more information, please see https://www.bis.doc.gov + +See also https://www.apache.org/dev/crypto.html and/or seek legal counsel. diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim/LICENSE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim/LICENSE new file mode 100644 index 00000000..e67cdabd --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2013 Honza Pokorny +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/docs/project/images/red_notice.png b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/docs/project/images/red_notice.png new file mode 100644 index 00000000..8839723a Binary files /dev/null and b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/docs/project/images/red_notice.png differ diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/pkg/mflag/LICENSE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/pkg/mflag/LICENSE new file mode 100644 index 00000000..ac74d8f0 --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/pkg/mflag/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014-2015 The Docker & Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/pkg/symlink/LICENSE.APACHE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/pkg/symlink/LICENSE.APACHE new file mode 100644 index 00000000..9e4bd4db --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/pkg/symlink/LICENSE.APACHE @@ -0,0 +1,191 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2014-2015 Docker, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/pkg/symlink/LICENSE.BSD b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/pkg/symlink/LICENSE.BSD new file mode 100644 index 00000000..ac74d8f0 --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/pkg/symlink/LICENSE.BSD @@ -0,0 +1,27 @@ +Copyright (c) 2014-2015 The Docker & Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/go-units/LICENSE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/go-units/LICENSE new file mode 100644 index 00000000..b55b37bc --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/go-units/LICENSE @@ -0,0 +1,191 @@ + + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2015 Docker, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/godbus/dbus/LICENSE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/godbus/dbus/LICENSE new file mode 100644 index 00000000..670d88fc --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/godbus/dbus/LICENSE @@ -0,0 +1,25 @@ +Copyright (c) 2013, Georg Reinke (), Google +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/golang/protobuf/LICENSE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/golang/protobuf/LICENSE new file mode 100644 index 00000000..1b1b1921 --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/golang/protobuf/LICENSE @@ -0,0 +1,31 @@ +Go support for Protocol Buffers - Google's data interchange format + +Copyright 2010 The Go Authors. All rights reserved. +https://github.com/golang/protobuf + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runtime-spec/LICENSE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runtime-spec/LICENSE new file mode 100644 index 00000000..bdc40365 --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runtime-spec/LICENSE @@ -0,0 +1,191 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2015 The Linux Foundation. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/pquerna/ffjson/LICENSE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/pquerna/ffjson/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/pquerna/ffjson/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/pquerna/ffjson/NOTICE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/pquerna/ffjson/NOTICE new file mode 100644 index 00000000..405a4961 --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/pquerna/ffjson/NOTICE @@ -0,0 +1,8 @@ +ffjson +Copyright (c) 2014, Paul Querna + +This product includes software developed by +Paul Querna (http://paul.querna.org/). + +Portions of this software were developed as +part of Go, Copyright (c) 2012 The Go Authors. \ No newline at end of file diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/seccomp/libseccomp-golang/LICENSE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/seccomp/libseccomp-golang/LICENSE new file mode 100644 index 00000000..81cf60de --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/seccomp/libseccomp-golang/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2015 Matthew Heon +Copyright (c) 2015 Paul Moore +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: +- Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/syndtr/gocapability/LICENSE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/syndtr/gocapability/LICENSE new file mode 100644 index 00000000..80dd96de --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/syndtr/gocapability/LICENSE @@ -0,0 +1,24 @@ +Copyright 2013 Suryandaru Triandana +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/vishvananda/netlink/LICENSE b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/vishvananda/netlink/LICENSE new file mode 100644 index 00000000..9f64db85 --- /dev/null +++ b/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/vishvananda/netlink/LICENSE @@ -0,0 +1,192 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2014 Vishvananda Ishaya. + Copyright 2014 Docker, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/testdata/LICENSE.golden b/vendor/github.com/spf13/cobra/cobra/cmd/testdata/LICENSE.golden new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/vendor/github.com/spf13/cobra/cobra/cmd/testdata/LICENSE.golden @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/golang.org/x/oauth2/.travis.yml b/vendor/golang.org/x/oauth2/.travis.yml deleted file mode 100644 index fa139db2..00000000 --- a/vendor/golang.org/x/oauth2/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: go - -go: - - tip - -install: - - export GOPATH="$HOME/gopath" - - mkdir -p "$GOPATH/src/golang.org/x" - - mv "$TRAVIS_BUILD_DIR" "$GOPATH/src/golang.org/x/oauth2" - - go get -v -t -d golang.org/x/oauth2/... - -script: - - go test -v golang.org/x/oauth2/... diff --git a/vendor/golang.org/x/oauth2/CONTRIBUTING.md b/vendor/golang.org/x/oauth2/CONTRIBUTING.md deleted file mode 100644 index dfbed62c..00000000 --- a/vendor/golang.org/x/oauth2/CONTRIBUTING.md +++ /dev/null @@ -1,26 +0,0 @@ -# Contributing to Go - -Go is an open source project. - -It is the work of hundreds of contributors. We appreciate your help! - -## Filing issues - -When [filing an issue](https://github.com/golang/oauth2/issues), make sure to answer these five questions: - -1. What version of Go are you using (`go version`)? -2. What operating system and processor architecture are you using? -3. What did you do? -4. What did you expect to see? -5. What did you see instead? - -General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. -The gophers there will answer or ask you to file an issue if you've tripped over a bug. - -## Contributing code - -Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) -before sending patches. - -Unless otherwise noted, the Go source files are distributed under -the BSD-style license found in the LICENSE file. diff --git a/vendor/golang.org/x/oauth2/README.md b/vendor/golang.org/x/oauth2/README.md deleted file mode 100644 index eb8dcee1..00000000 --- a/vendor/golang.org/x/oauth2/README.md +++ /dev/null @@ -1,77 +0,0 @@ -# OAuth2 for Go - -[![Build Status](https://travis-ci.org/golang/oauth2.svg?branch=master)](https://travis-ci.org/golang/oauth2) -[![GoDoc](https://godoc.org/golang.org/x/oauth2?status.svg)](https://godoc.org/golang.org/x/oauth2) - -oauth2 package contains a client implementation for OAuth 2.0 spec. - -## Installation - -~~~~ -go get golang.org/x/oauth2 -~~~~ - -Or you can manually git clone the repository to -`$(go env GOPATH)/src/golang.org/x/oauth2`. - -See godoc for further documentation and examples. - -* [godoc.org/golang.org/x/oauth2](http://godoc.org/golang.org/x/oauth2) -* [godoc.org/golang.org/x/oauth2/google](http://godoc.org/golang.org/x/oauth2/google) - - -## App Engine - -In change 96e89be (March 2015), we removed the `oauth2.Context2` type in favor -of the [`context.Context`](https://golang.org/x/net/context#Context) type from -the `golang.org/x/net/context` package - -This means it's no longer possible to use the "Classic App Engine" -`appengine.Context` type with the `oauth2` package. (You're using -Classic App Engine if you import the package `"appengine"`.) - -To work around this, you may use the new `"google.golang.org/appengine"` -package. This package has almost the same API as the `"appengine"` package, -but it can be fetched with `go get` and used on "Managed VMs" and well as -Classic App Engine. - -See the [new `appengine` package's readme](https://github.com/golang/appengine#updating-a-go-app-engine-app) -for information on updating your app. - -If you don't want to update your entire app to use the new App Engine packages, -you may use both sets of packages in parallel, using only the new packages -with the `oauth2` package. - -```go -import ( - "golang.org/x/net/context" - "golang.org/x/oauth2" - "golang.org/x/oauth2/google" - newappengine "google.golang.org/appengine" - newurlfetch "google.golang.org/appengine/urlfetch" - - "appengine" -) - -func handler(w http.ResponseWriter, r *http.Request) { - var c appengine.Context = appengine.NewContext(r) - c.Infof("Logging a message with the old package") - - var ctx context.Context = newappengine.NewContext(r) - client := &http.Client{ - Transport: &oauth2.Transport{ - Source: google.AppEngineTokenSource(ctx, "scope"), - Base: &newurlfetch.Transport{Context: ctx}, - }, - } - client.Get("...") -} -``` - -## Report Issues / Send Patches - -This repository uses Gerrit for code changes. To learn how to submit changes to -this repository, see https://golang.org/doc/contribute.html. - -The main issue tracker for the oauth2 repository is located at -https://github.com/golang/oauth2/issues. diff --git a/vendor/golang.org/x/oauth2/example_test.go b/vendor/golang.org/x/oauth2/example_test.go deleted file mode 100644 index fc2f793b..00000000 --- a/vendor/golang.org/x/oauth2/example_test.go +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2014 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 oauth2_test - -import ( - "context" - "fmt" - "log" - "net/http" - "time" - - "golang.org/x/oauth2" -) - -func ExampleConfig() { - ctx := context.Background() - conf := &oauth2.Config{ - ClientID: "YOUR_CLIENT_ID", - ClientSecret: "YOUR_CLIENT_SECRET", - Scopes: []string{"SCOPE1", "SCOPE2"}, - Endpoint: oauth2.Endpoint{ - AuthURL: "https://provider.com/o/oauth2/auth", - TokenURL: "https://provider.com/o/oauth2/token", - }, - } - - // Redirect user to consent page to ask for permission - // for the scopes specified above. - url := conf.AuthCodeURL("state", oauth2.AccessTypeOffline) - fmt.Printf("Visit the URL for the auth dialog: %v", url) - - // Use the authorization code that is pushed to the redirect - // URL. Exchange will do the handshake to retrieve the - // initial access token. The HTTP Client returned by - // conf.Client will refresh the token as necessary. - var code string - if _, err := fmt.Scan(&code); err != nil { - log.Fatal(err) - } - tok, err := conf.Exchange(ctx, code) - if err != nil { - log.Fatal(err) - } - - client := conf.Client(ctx, tok) - client.Get("...") -} - -func ExampleConfig_customHTTP() { - ctx := context.Background() - - conf := &oauth2.Config{ - ClientID: "YOUR_CLIENT_ID", - ClientSecret: "YOUR_CLIENT_SECRET", - Scopes: []string{"SCOPE1", "SCOPE2"}, - Endpoint: oauth2.Endpoint{ - TokenURL: "https://provider.com/o/oauth2/token", - AuthURL: "https://provider.com/o/oauth2/auth", - }, - } - - // Redirect user to consent page to ask for permission - // for the scopes specified above. - url := conf.AuthCodeURL("state", oauth2.AccessTypeOffline) - fmt.Printf("Visit the URL for the auth dialog: %v", url) - - // Use the authorization code that is pushed to the redirect - // URL. Exchange will do the handshake to retrieve the - // initial access token. The HTTP Client returned by - // conf.Client will refresh the token as necessary. - var code string - if _, err := fmt.Scan(&code); err != nil { - log.Fatal(err) - } - - // Use the custom HTTP client when requesting a token. - httpClient := &http.Client{Timeout: 2 * time.Second} - ctx = context.WithValue(ctx, oauth2.HTTPClient, httpClient) - - tok, err := conf.Exchange(ctx, code) - if err != nil { - log.Fatal(err) - } - - client := conf.Client(ctx, tok) - _ = client -} diff --git a/vendor/golang.org/x/oauth2/internal/token_test.go b/vendor/golang.org/x/oauth2/internal/token_test.go deleted file mode 100644 index 7b52e511..00000000 --- a/vendor/golang.org/x/oauth2/internal/token_test.go +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2014 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 internal - -import ( - "fmt" - "io" - "net/http" - "net/http/httptest" - "net/url" - "testing" - - "golang.org/x/net/context" -) - -func TestRegisterBrokenAuthHeaderProvider(t *testing.T) { - RegisterBrokenAuthHeaderProvider("https://aaa.com/") - tokenURL := "https://aaa.com/token" - if providerAuthHeaderWorks(tokenURL) { - t.Errorf("got %q as unbroken; want broken", tokenURL) - } -} - -func TestRetrieveTokenBustedNoSecret(t *testing.T) { - const clientID = "client-id" - - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if got, want := r.FormValue("client_id"), clientID; got != want { - t.Errorf("client_id = %q; want %q", got, want) - } - if got, want := r.FormValue("client_secret"), ""; got != want { - t.Errorf("client_secret = %q; want empty", got) - } - w.Header().Set("Content-Type", "application/json") - io.WriteString(w, `{"access_token": "ACCESS_TOKEN", "token_type": "bearer"}`) - })) - defer ts.Close() - - RegisterBrokenAuthHeaderProvider(ts.URL) - _, err := RetrieveToken(context.Background(), clientID, "", ts.URL, url.Values{}) - if err != nil { - t.Errorf("RetrieveToken = %v; want no error", err) - } -} - -func Test_providerAuthHeaderWorks(t *testing.T) { - for _, p := range brokenAuthHeaderProviders { - if providerAuthHeaderWorks(p) { - t.Errorf("got %q as unbroken; want broken", p) - } - p := fmt.Sprintf("%ssomesuffix", p) - if providerAuthHeaderWorks(p) { - t.Errorf("got %q as unbroken; want broken", p) - } - } - p := "https://api.not-in-the-list-example.com/" - if !providerAuthHeaderWorks(p) { - t.Errorf("got %q as unbroken; want broken", p) - } -} - -func TestProviderAuthHeaderWorksDomain(t *testing.T) { - tests := []struct { - tokenURL string - wantWorks bool - }{ - {"https://dev-12345.okta.com/token-url", false}, - {"https://dev-12345.oktapreview.com/token-url", false}, - {"https://dev-12345.okta.org/token-url", true}, - {"https://foo.bar.force.com/token-url", false}, - {"https://foo.force.com/token-url", false}, - {"https://force.com/token-url", true}, - } - - for _, test := range tests { - got := providerAuthHeaderWorks(test.tokenURL) - if got != test.wantWorks { - t.Errorf("providerAuthHeaderWorks(%q) = %v; want %v", test.tokenURL, got, test.wantWorks) - } - } -} - -func TestRetrieveTokenWithContexts(t *testing.T) { - const clientID = "client-id" - - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - io.WriteString(w, `{"access_token": "ACCESS_TOKEN", "token_type": "bearer"}`) - })) - defer ts.Close() - - _, err := RetrieveToken(context.Background(), clientID, "", ts.URL, url.Values{}) - if err != nil { - t.Errorf("RetrieveToken (with background context) = %v; want no error", err) - } - - retrieved := make(chan struct{}) - cancellingts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - <-retrieved - })) - defer cancellingts.Close() - - ctx, cancel := context.WithCancel(context.Background()) - cancel() - _, err = RetrieveToken(ctx, clientID, "", cancellingts.URL, url.Values{}) - close(retrieved) - if err == nil { - t.Errorf("RetrieveToken (with cancelled context) = nil; want error") - } -} diff --git a/vendor/golang.org/x/oauth2/oauth2_test.go b/vendor/golang.org/x/oauth2/oauth2_test.go deleted file mode 100644 index ef12ebc5..00000000 --- a/vendor/golang.org/x/oauth2/oauth2_test.go +++ /dev/null @@ -1,551 +0,0 @@ -// Copyright 2014 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 oauth2 - -import ( - "errors" - "fmt" - "io/ioutil" - "net/http" - "net/http/httptest" - "net/url" - "testing" - "time" - - "golang.org/x/net/context" -) - -type mockTransport struct { - rt func(req *http.Request) (resp *http.Response, err error) -} - -func (t *mockTransport) RoundTrip(req *http.Request) (resp *http.Response, err error) { - return t.rt(req) -} - -func newConf(url string) *Config { - return &Config{ - ClientID: "CLIENT_ID", - ClientSecret: "CLIENT_SECRET", - RedirectURL: "REDIRECT_URL", - Scopes: []string{"scope1", "scope2"}, - Endpoint: Endpoint{ - AuthURL: url + "/auth", - TokenURL: url + "/token", - }, - } -} - -func TestAuthCodeURL(t *testing.T) { - conf := newConf("server") - url := conf.AuthCodeURL("foo", AccessTypeOffline, ApprovalForce) - const want = "server/auth?access_type=offline&approval_prompt=force&client_id=CLIENT_ID&redirect_uri=REDIRECT_URL&response_type=code&scope=scope1+scope2&state=foo" - if got := url; got != want { - t.Errorf("got auth code URL = %q; want %q", got, want) - } -} - -func TestAuthCodeURL_CustomParam(t *testing.T) { - conf := newConf("server") - param := SetAuthURLParam("foo", "bar") - url := conf.AuthCodeURL("baz", param) - const want = "server/auth?client_id=CLIENT_ID&foo=bar&redirect_uri=REDIRECT_URL&response_type=code&scope=scope1+scope2&state=baz" - if got := url; got != want { - t.Errorf("got auth code = %q; want %q", got, want) - } -} - -func TestAuthCodeURL_Optional(t *testing.T) { - conf := &Config{ - ClientID: "CLIENT_ID", - Endpoint: Endpoint{ - AuthURL: "/auth-url", - TokenURL: "/token-url", - }, - } - url := conf.AuthCodeURL("") - const want = "/auth-url?client_id=CLIENT_ID&response_type=code" - if got := url; got != want { - t.Fatalf("got auth code = %q; want %q", got, want) - } -} - -func TestURLUnsafeClientConfig(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if got, want := r.Header.Get("Authorization"), "Basic Q0xJRU5UX0lEJTNGJTNGOkNMSUVOVF9TRUNSRVQlM0YlM0Y="; got != want { - t.Errorf("Authorization header = %q; want %q", got, want) - } - - w.Header().Set("Content-Type", "application/x-www-form-urlencoded") - w.Write([]byte("access_token=90d64460d14870c08c81352a05dedd3465940a7c&scope=user&token_type=bearer")) - })) - defer ts.Close() - conf := newConf(ts.URL) - conf.ClientID = "CLIENT_ID??" - conf.ClientSecret = "CLIENT_SECRET??" - _, err := conf.Exchange(context.Background(), "exchange-code") - if err != nil { - t.Error(err) - } -} - -func TestExchangeRequest(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.URL.String() != "/token" { - t.Errorf("Unexpected exchange request URL, %v is found.", r.URL) - } - headerAuth := r.Header.Get("Authorization") - if headerAuth != "Basic Q0xJRU5UX0lEOkNMSUVOVF9TRUNSRVQ=" { - t.Errorf("Unexpected authorization header, %v is found.", headerAuth) - } - headerContentType := r.Header.Get("Content-Type") - if headerContentType != "application/x-www-form-urlencoded" { - t.Errorf("Unexpected Content-Type header, %v is found.", headerContentType) - } - body, err := ioutil.ReadAll(r.Body) - if err != nil { - t.Errorf("Failed reading request body: %s.", err) - } - if string(body) != "code=exchange-code&grant_type=authorization_code&redirect_uri=REDIRECT_URL" { - t.Errorf("Unexpected exchange payload, %v is found.", string(body)) - } - w.Header().Set("Content-Type", "application/x-www-form-urlencoded") - w.Write([]byte("access_token=90d64460d14870c08c81352a05dedd3465940a7c&scope=user&token_type=bearer")) - })) - defer ts.Close() - conf := newConf(ts.URL) - tok, err := conf.Exchange(context.Background(), "exchange-code") - if err != nil { - t.Error(err) - } - if !tok.Valid() { - t.Fatalf("Token invalid. Got: %#v", tok) - } - if tok.AccessToken != "90d64460d14870c08c81352a05dedd3465940a7c" { - t.Errorf("Unexpected access token, %#v.", tok.AccessToken) - } - if tok.TokenType != "bearer" { - t.Errorf("Unexpected token type, %#v.", tok.TokenType) - } - scope := tok.Extra("scope") - if scope != "user" { - t.Errorf("Unexpected value for scope: %v", scope) - } -} - -func TestExchangeRequest_CustomParam(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.URL.String() != "/token" { - t.Errorf("Unexpected exchange request URL, %v is found.", r.URL) - } - headerAuth := r.Header.Get("Authorization") - if headerAuth != "Basic Q0xJRU5UX0lEOkNMSUVOVF9TRUNSRVQ=" { - t.Errorf("Unexpected authorization header, %v is found.", headerAuth) - } - headerContentType := r.Header.Get("Content-Type") - if headerContentType != "application/x-www-form-urlencoded" { - t.Errorf("Unexpected Content-Type header, %v is found.", headerContentType) - } - body, err := ioutil.ReadAll(r.Body) - if err != nil { - t.Errorf("Failed reading request body: %s.", err) - } - if string(body) != "code=exchange-code&foo=bar&grant_type=authorization_code&redirect_uri=REDIRECT_URL" { - t.Errorf("Unexpected exchange payload, %v is found.", string(body)) - } - w.Header().Set("Content-Type", "application/x-www-form-urlencoded") - w.Write([]byte("access_token=90d64460d14870c08c81352a05dedd3465940a7c&scope=user&token_type=bearer")) - })) - defer ts.Close() - conf := newConf(ts.URL) - - param := SetAuthURLParam("foo", "bar") - tok, err := conf.Exchange(context.Background(), "exchange-code", param) - if err != nil { - t.Error(err) - } - if !tok.Valid() { - t.Fatalf("Token invalid. Got: %#v", tok) - } - if tok.AccessToken != "90d64460d14870c08c81352a05dedd3465940a7c" { - t.Errorf("Unexpected access token, %#v.", tok.AccessToken) - } - if tok.TokenType != "bearer" { - t.Errorf("Unexpected token type, %#v.", tok.TokenType) - } - scope := tok.Extra("scope") - if scope != "user" { - t.Errorf("Unexpected value for scope: %v", scope) - } -} - -func TestExchangeRequest_JSONResponse(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.URL.String() != "/token" { - t.Errorf("Unexpected exchange request URL, %v is found.", r.URL) - } - headerAuth := r.Header.Get("Authorization") - if headerAuth != "Basic Q0xJRU5UX0lEOkNMSUVOVF9TRUNSRVQ=" { - t.Errorf("Unexpected authorization header, %v is found.", headerAuth) - } - headerContentType := r.Header.Get("Content-Type") - if headerContentType != "application/x-www-form-urlencoded" { - t.Errorf("Unexpected Content-Type header, %v is found.", headerContentType) - } - body, err := ioutil.ReadAll(r.Body) - if err != nil { - t.Errorf("Failed reading request body: %s.", err) - } - if string(body) != "code=exchange-code&grant_type=authorization_code&redirect_uri=REDIRECT_URL" { - t.Errorf("Unexpected exchange payload, %v is found.", string(body)) - } - w.Header().Set("Content-Type", "application/json") - w.Write([]byte(`{"access_token": "90d64460d14870c08c81352a05dedd3465940a7c", "scope": "user", "token_type": "bearer", "expires_in": 86400}`)) - })) - defer ts.Close() - conf := newConf(ts.URL) - tok, err := conf.Exchange(context.Background(), "exchange-code") - if err != nil { - t.Error(err) - } - if !tok.Valid() { - t.Fatalf("Token invalid. Got: %#v", tok) - } - if tok.AccessToken != "90d64460d14870c08c81352a05dedd3465940a7c" { - t.Errorf("Unexpected access token, %#v.", tok.AccessToken) - } - if tok.TokenType != "bearer" { - t.Errorf("Unexpected token type, %#v.", tok.TokenType) - } - scope := tok.Extra("scope") - if scope != "user" { - t.Errorf("Unexpected value for scope: %v", scope) - } - expiresIn := tok.Extra("expires_in") - if expiresIn != float64(86400) { - t.Errorf("Unexpected non-numeric value for expires_in: %v", expiresIn) - } -} - -func TestExtraValueRetrieval(t *testing.T) { - values := url.Values{} - kvmap := map[string]string{ - "scope": "user", "token_type": "bearer", "expires_in": "86400.92", - "server_time": "1443571905.5606415", "referer_ip": "10.0.0.1", - "etag": "\"afZYj912P4alikMz_P11982\"", "request_id": "86400", - "untrimmed": " untrimmed ", - } - for key, value := range kvmap { - values.Set(key, value) - } - - tok := Token{raw: values} - scope := tok.Extra("scope") - if got, want := scope, "user"; got != want { - t.Errorf("got scope = %q; want %q", got, want) - } - serverTime := tok.Extra("server_time") - if got, want := serverTime, 1443571905.5606415; got != want { - t.Errorf("got server_time value = %v; want %v", got, want) - } - refererIP := tok.Extra("referer_ip") - if got, want := refererIP, "10.0.0.1"; got != want { - t.Errorf("got referer_ip value = %v, want %v", got, want) - } - expiresIn := tok.Extra("expires_in") - if got, want := expiresIn, 86400.92; got != want { - t.Errorf("got expires_in value = %v, want %v", got, want) - } - requestID := tok.Extra("request_id") - if got, want := requestID, int64(86400); got != want { - t.Errorf("got request_id value = %v, want %v", got, want) - } - untrimmed := tok.Extra("untrimmed") - if got, want := untrimmed, " untrimmed "; got != want { - t.Errorf("got untrimmed = %q; want %q", got, want) - } -} - -const day = 24 * time.Hour - -func TestExchangeRequest_JSONResponse_Expiry(t *testing.T) { - seconds := int32(day.Seconds()) - for _, c := range []struct { - expires string - want bool - }{ - {fmt.Sprintf(`"expires_in": %d`, seconds), true}, - {fmt.Sprintf(`"expires_in": "%d"`, seconds), true}, // PayPal case - {fmt.Sprintf(`"expires": %d`, seconds), true}, // Facebook case - {`"expires": false`, false}, // wrong type - {`"expires": {}`, false}, // wrong type - {`"expires": "zzz"`, false}, // wrong value - } { - testExchangeRequest_JSONResponse_expiry(t, c.expires, c.want) - } -} - -func testExchangeRequest_JSONResponse_expiry(t *testing.T, exp string, want bool) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - w.Write([]byte(fmt.Sprintf(`{"access_token": "90d", "scope": "user", "token_type": "bearer", %s}`, exp))) - })) - defer ts.Close() - conf := newConf(ts.URL) - t1 := time.Now().Add(day) - tok, err := conf.Exchange(context.Background(), "exchange-code") - t2 := time.Now().Add(day) - - if got := (err == nil); got != want { - if want { - t.Errorf("unexpected error: got %v", err) - } else { - t.Errorf("unexpected success") - } - } - if !want { - return - } - if !tok.Valid() { - t.Fatalf("Token invalid. Got: %#v", tok) - } - expiry := tok.Expiry - if expiry.Before(t1) || expiry.After(t2) { - t.Errorf("Unexpected value for Expiry: %v (shold be between %v and %v)", expiry, t1, t2) - } -} - -func TestExchangeRequest_BadResponse(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - w.Write([]byte(`{"scope": "user", "token_type": "bearer"}`)) - })) - defer ts.Close() - conf := newConf(ts.URL) - _, err := conf.Exchange(context.Background(), "code") - if err == nil { - t.Error("expected error from missing access_token") - } -} - -func TestExchangeRequest_BadResponseType(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - w.Write([]byte(`{"access_token":123, "scope": "user", "token_type": "bearer"}`)) - })) - defer ts.Close() - conf := newConf(ts.URL) - _, err := conf.Exchange(context.Background(), "exchange-code") - if err == nil { - t.Error("expected error from non-string access_token") - } -} - -func TestExchangeRequest_NonBasicAuth(t *testing.T) { - tr := &mockTransport{ - rt: func(r *http.Request) (w *http.Response, err error) { - headerAuth := r.Header.Get("Authorization") - if headerAuth != "" { - t.Errorf("Unexpected authorization header, %v is found.", headerAuth) - } - return nil, errors.New("no response") - }, - } - c := &http.Client{Transport: tr} - conf := &Config{ - ClientID: "CLIENT_ID", - Endpoint: Endpoint{ - AuthURL: "https://accounts.google.com/auth", - TokenURL: "https://accounts.google.com/token", - }, - } - - ctx := context.WithValue(context.Background(), HTTPClient, c) - conf.Exchange(ctx, "code") -} - -func TestPasswordCredentialsTokenRequest(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - defer r.Body.Close() - expected := "/token" - if r.URL.String() != expected { - t.Errorf("URL = %q; want %q", r.URL, expected) - } - headerAuth := r.Header.Get("Authorization") - expected = "Basic Q0xJRU5UX0lEOkNMSUVOVF9TRUNSRVQ=" - if headerAuth != expected { - t.Errorf("Authorization header = %q; want %q", headerAuth, expected) - } - headerContentType := r.Header.Get("Content-Type") - expected = "application/x-www-form-urlencoded" - if headerContentType != expected { - t.Errorf("Content-Type header = %q; want %q", headerContentType, expected) - } - body, err := ioutil.ReadAll(r.Body) - if err != nil { - t.Errorf("Failed reading request body: %s.", err) - } - expected = "grant_type=password&password=password1&scope=scope1+scope2&username=user1" - if string(body) != expected { - t.Errorf("res.Body = %q; want %q", string(body), expected) - } - w.Header().Set("Content-Type", "application/x-www-form-urlencoded") - w.Write([]byte("access_token=90d64460d14870c08c81352a05dedd3465940a7c&scope=user&token_type=bearer")) - })) - defer ts.Close() - conf := newConf(ts.URL) - tok, err := conf.PasswordCredentialsToken(context.Background(), "user1", "password1") - if err != nil { - t.Error(err) - } - if !tok.Valid() { - t.Fatalf("Token invalid. Got: %#v", tok) - } - expected := "90d64460d14870c08c81352a05dedd3465940a7c" - if tok.AccessToken != expected { - t.Errorf("AccessToken = %q; want %q", tok.AccessToken, expected) - } - expected = "bearer" - if tok.TokenType != expected { - t.Errorf("TokenType = %q; want %q", tok.TokenType, expected) - } -} - -func TestTokenRefreshRequest(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.URL.String() == "/somethingelse" { - return - } - if r.URL.String() != "/token" { - t.Errorf("Unexpected token refresh request URL, %v is found.", r.URL) - } - headerContentType := r.Header.Get("Content-Type") - if headerContentType != "application/x-www-form-urlencoded" { - t.Errorf("Unexpected Content-Type header, %v is found.", headerContentType) - } - body, _ := ioutil.ReadAll(r.Body) - if string(body) != "grant_type=refresh_token&refresh_token=REFRESH_TOKEN" { - t.Errorf("Unexpected refresh token payload, %v is found.", string(body)) - } - })) - defer ts.Close() - conf := newConf(ts.URL) - c := conf.Client(context.Background(), &Token{RefreshToken: "REFRESH_TOKEN"}) - c.Get(ts.URL + "/somethingelse") -} - -func TestFetchWithNoRefreshToken(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.URL.String() == "/somethingelse" { - return - } - if r.URL.String() != "/token" { - t.Errorf("Unexpected token refresh request URL, %v is found.", r.URL) - } - headerContentType := r.Header.Get("Content-Type") - if headerContentType != "application/x-www-form-urlencoded" { - t.Errorf("Unexpected Content-Type header, %v is found.", headerContentType) - } - body, _ := ioutil.ReadAll(r.Body) - if string(body) != "client_id=CLIENT_ID&grant_type=refresh_token&refresh_token=REFRESH_TOKEN" { - t.Errorf("Unexpected refresh token payload, %v is found.", string(body)) - } - })) - defer ts.Close() - conf := newConf(ts.URL) - c := conf.Client(context.Background(), nil) - _, err := c.Get(ts.URL + "/somethingelse") - if err == nil { - t.Errorf("Fetch should return an error if no refresh token is set") - } -} - -func TestTokenRetrieveError(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.URL.String() != "/token" { - t.Errorf("Unexpected token refresh request URL, %v is found.", r.URL) - } - w.Header().Set("Content-type", "application/json") - w.WriteHeader(http.StatusBadRequest) - w.Write([]byte(`{"error": "invalid_grant"}`)) - })) - defer ts.Close() - conf := newConf(ts.URL) - _, err := conf.Exchange(context.Background(), "exchange-code") - if err == nil { - t.Fatalf("got no error, expected one") - } - _, ok := err.(*RetrieveError) - if !ok { - t.Fatalf("got %T error, expected *RetrieveError", err) - } - // Test error string for backwards compatibility - expected := fmt.Sprintf("oauth2: cannot fetch token: %v\nResponse: %s", "400 Bad Request", `{"error": "invalid_grant"}`) - if errStr := err.Error(); errStr != expected { - t.Fatalf("got %#v, expected %#v", errStr, expected) - } -} - -func TestRefreshToken_RefreshTokenReplacement(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - w.Write([]byte(`{"access_token":"ACCESS_TOKEN", "scope": "user", "token_type": "bearer", "refresh_token": "NEW_REFRESH_TOKEN"}`)) - return - })) - defer ts.Close() - conf := newConf(ts.URL) - tkr := conf.TokenSource(context.Background(), &Token{RefreshToken: "OLD_REFRESH_TOKEN"}) - tk, err := tkr.Token() - if err != nil { - t.Errorf("got err = %v; want none", err) - return - } - if want := "NEW_REFRESH_TOKEN"; tk.RefreshToken != want { - t.Errorf("RefreshToken = %q; want %q", tk.RefreshToken, want) - } -} - -func TestRefreshToken_RefreshTokenPreservation(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - w.Write([]byte(`{"access_token":"ACCESS_TOKEN", "scope": "user", "token_type": "bearer"}`)) - return - })) - defer ts.Close() - conf := newConf(ts.URL) - const oldRefreshToken = "OLD_REFRESH_TOKEN" - tkr := conf.TokenSource(context.Background(), &Token{RefreshToken: oldRefreshToken}) - tk, err := tkr.Token() - if err != nil { - t.Fatalf("got err = %v; want none", err) - } - if tk.RefreshToken != oldRefreshToken { - t.Errorf("RefreshToken = %q; want %q", tk.RefreshToken, oldRefreshToken) - } -} - -func TestConfigClientWithToken(t *testing.T) { - tok := &Token{ - AccessToken: "abc123", - } - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if got, want := r.Header.Get("Authorization"), fmt.Sprintf("Bearer %s", tok.AccessToken); got != want { - t.Errorf("Authorization header = %q; want %q", got, want) - } - return - })) - defer ts.Close() - conf := newConf(ts.URL) - - c := conf.Client(context.Background(), tok) - req, err := http.NewRequest("GET", ts.URL, nil) - if err != nil { - t.Error(err) - } - _, err = c.Do(req) - if err != nil { - t.Error(err) - } -} diff --git a/vendor/golang.org/x/oauth2/token_test.go b/vendor/golang.org/x/oauth2/token_test.go deleted file mode 100644 index 80db83c2..00000000 --- a/vendor/golang.org/x/oauth2/token_test.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2014 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 oauth2 - -import ( - "testing" - "time" -) - -func TestTokenExtra(t *testing.T) { - type testCase struct { - key string - val interface{} - want interface{} - } - const key = "extra-key" - cases := []testCase{ - {key: key, val: "abc", want: "abc"}, - {key: key, val: 123, want: 123}, - {key: key, val: "", want: ""}, - {key: "other-key", val: "def", want: nil}, - } - for _, tc := range cases { - extra := make(map[string]interface{}) - extra[tc.key] = tc.val - tok := &Token{raw: extra} - if got, want := tok.Extra(key), tc.want; got != want { - t.Errorf("Extra(%q) = %q; want %q", key, got, want) - } - } -} - -func TestTokenExpiry(t *testing.T) { - now := time.Now() - cases := []struct { - name string - tok *Token - want bool - }{ - {name: "12 seconds", tok: &Token{Expiry: now.Add(12 * time.Second)}, want: false}, - {name: "10 seconds", tok: &Token{Expiry: now.Add(expiryDelta)}, want: true}, - {name: "-1 hour", tok: &Token{Expiry: now.Add(-1 * time.Hour)}, want: true}, - } - for _, tc := range cases { - if got, want := tc.tok.expired(), tc.want; got != want { - t.Errorf("expired (%q) = %v; want %v", tc.name, got, want) - } - } -} - -func TestTokenTypeMethod(t *testing.T) { - cases := []struct { - name string - tok *Token - want string - }{ - {name: "bearer-mixed_case", tok: &Token{TokenType: "beAREr"}, want: "Bearer"}, - {name: "default-bearer", tok: &Token{}, want: "Bearer"}, - {name: "basic", tok: &Token{TokenType: "basic"}, want: "Basic"}, - {name: "basic-capitalized", tok: &Token{TokenType: "Basic"}, want: "Basic"}, - {name: "mac", tok: &Token{TokenType: "mac"}, want: "MAC"}, - {name: "mac-caps", tok: &Token{TokenType: "MAC"}, want: "MAC"}, - {name: "mac-mixed_case", tok: &Token{TokenType: "mAc"}, want: "MAC"}, - } - for _, tc := range cases { - if got, want := tc.tok.Type(), tc.want; got != want { - t.Errorf("TokenType(%q) = %v; want %v", tc.name, got, want) - } - } -} diff --git a/vendor/golang.org/x/oauth2/transport_test.go b/vendor/golang.org/x/oauth2/transport_test.go deleted file mode 100644 index faa87d51..00000000 --- a/vendor/golang.org/x/oauth2/transport_test.go +++ /dev/null @@ -1,168 +0,0 @@ -package oauth2 - -import ( - "errors" - "io" - "net/http" - "net/http/httptest" - "testing" - "time" -) - -type tokenSource struct{ token *Token } - -func (t *tokenSource) Token() (*Token, error) { - return t.token, nil -} - -func TestTransportNilTokenSource(t *testing.T) { - tr := &Transport{} - server := newMockServer(func(w http.ResponseWriter, r *http.Request) {}) - defer server.Close() - client := &http.Client{Transport: tr} - resp, err := client.Get(server.URL) - if err == nil { - t.Errorf("got no errors, want an error with nil token source") - } - if resp != nil { - t.Errorf("Response = %v; want nil", resp) - } -} - -type readCloseCounter struct { - CloseCount int - ReadErr error -} - -func (r *readCloseCounter) Read(b []byte) (int, error) { - return 0, r.ReadErr -} - -func (r *readCloseCounter) Close() error { - r.CloseCount++ - return nil -} - -func TestTransportCloseRequestBody(t *testing.T) { - tr := &Transport{} - server := newMockServer(func(w http.ResponseWriter, r *http.Request) {}) - defer server.Close() - client := &http.Client{Transport: tr} - body := &readCloseCounter{ - ReadErr: errors.New("readCloseCounter.Read not implemented"), - } - resp, err := client.Post(server.URL, "application/json", body) - if err == nil { - t.Errorf("got no errors, want an error with nil token source") - } - if resp != nil { - t.Errorf("Response = %v; want nil", resp) - } - if expected := 1; body.CloseCount != expected { - t.Errorf("Body was closed %d times, expected %d", body.CloseCount, expected) - } -} - -func TestTransportCloseRequestBodySuccess(t *testing.T) { - tr := &Transport{ - Source: StaticTokenSource(&Token{ - AccessToken: "abc", - }), - } - server := newMockServer(func(w http.ResponseWriter, r *http.Request) {}) - defer server.Close() - client := &http.Client{Transport: tr} - body := &readCloseCounter{ - ReadErr: io.EOF, - } - resp, err := client.Post(server.URL, "application/json", body) - if err != nil { - t.Errorf("got error %v; expected none", err) - } - if resp == nil { - t.Errorf("Response is nil; expected non-nil") - } - if expected := 1; body.CloseCount != expected { - t.Errorf("Body was closed %d times, expected %d", body.CloseCount, expected) - } -} - -func TestTransportTokenSource(t *testing.T) { - ts := &tokenSource{ - token: &Token{ - AccessToken: "abc", - }, - } - tr := &Transport{ - Source: ts, - } - server := newMockServer(func(w http.ResponseWriter, r *http.Request) { - if got, want := r.Header.Get("Authorization"), "Bearer abc"; got != want { - t.Errorf("Authorization header = %q; want %q", got, want) - } - }) - defer server.Close() - client := &http.Client{Transport: tr} - res, err := client.Get(server.URL) - if err != nil { - t.Fatal(err) - } - res.Body.Close() -} - -// Test for case-sensitive token types, per https://github.com/golang/oauth2/issues/113 -func TestTransportTokenSourceTypes(t *testing.T) { - const val = "abc" - tests := []struct { - key string - val string - want string - }{ - {key: "bearer", val: val, want: "Bearer abc"}, - {key: "mac", val: val, want: "MAC abc"}, - {key: "basic", val: val, want: "Basic abc"}, - } - for _, tc := range tests { - ts := &tokenSource{ - token: &Token{ - AccessToken: tc.val, - TokenType: tc.key, - }, - } - tr := &Transport{ - Source: ts, - } - server := newMockServer(func(w http.ResponseWriter, r *http.Request) { - if got, want := r.Header.Get("Authorization"), tc.want; got != want { - t.Errorf("Authorization header (%q) = %q; want %q", val, got, want) - } - }) - defer server.Close() - client := &http.Client{Transport: tr} - res, err := client.Get(server.URL) - if err != nil { - t.Fatal(err) - } - res.Body.Close() - } -} - -func TestTokenValidNoAccessToken(t *testing.T) { - token := &Token{} - if token.Valid() { - t.Errorf("got valid with no access token; want invalid") - } -} - -func TestExpiredWithExpiry(t *testing.T) { - token := &Token{ - Expiry: time.Now().Add(-5 * time.Hour), - } - if token.Valid() { - t.Errorf("got valid with expired token; want invalid") - } -} - -func newMockServer(handler func(w http.ResponseWriter, r *http.Request)) *httptest.Server { - return httptest.NewServer(http.HandlerFunc(handler)) -} diff --git a/vendor/google.golang.org/appengine/.travis.yml b/vendor/google.golang.org/appengine/.travis.yml deleted file mode 100644 index 7ef8b6c7..00000000 --- a/vendor/google.golang.org/appengine/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: go - -go: - - 1.6.x - - 1.7.x - - 1.8.x - - 1.9.x - -go_import_path: google.golang.org/appengine - -install: - - go get -u -v $(go list -f '{{join .Imports "\n"}}{{"\n"}}{{join .TestImports "\n"}}' ./... | sort | uniq | grep -v appengine) - - mkdir /tmp/sdk - - curl -o /tmp/sdk.zip "https://storage.googleapis.com/appengine-sdks/featured/go_appengine_sdk_linux_amd64-1.9.40.zip" - - unzip -q /tmp/sdk.zip -d /tmp/sdk - - export PATH="$PATH:/tmp/sdk/go_appengine" - - export APPENGINE_DEV_APPSERVER=/tmp/sdk/go_appengine/dev_appserver.py - -script: - - goapp version - - go version - - go test -v google.golang.org/appengine/... - - go test -v -race google.golang.org/appengine/... - - goapp test -v google.golang.org/appengine/... diff --git a/vendor/google.golang.org/appengine/CONTRIBUTING.md b/vendor/google.golang.org/appengine/CONTRIBUTING.md deleted file mode 100644 index ffc29852..00000000 --- a/vendor/google.golang.org/appengine/CONTRIBUTING.md +++ /dev/null @@ -1,90 +0,0 @@ -# Contributing - -1. Sign one of the contributor license agreements below. -1. Get the package: - - `go get -d google.golang.org/appengine` -1. Change into the checked out source: - - `cd $GOPATH/src/google.golang.org/appengine` -1. Fork the repo. -1. Set your fork as a remote: - - `git remote add fork git@github.com:GITHUB_USERNAME/appengine.git` -1. Make changes, commit to your fork. -1. Send a pull request with your changes. - The first line of your commit message is conventionally a one-line summary of the change, prefixed by the primary affected package, and is used as the title of your pull request. - -# Testing - -## Running system tests - -Download and install the [Go App Engine SDK](https://cloud.google.com/appengine/docs/go/download). Make sure the `go_appengine` dir is in your `PATH`. - -Set the `APPENGINE_DEV_APPSERVER` environment variable to `/path/to/go_appengine/dev_appserver.py`. - -Run tests with `goapp test`: - -``` -goapp test -v google.golang.org/appengine/... -``` - -## Contributor License Agreements - -Before we can accept your pull requests you'll need to sign a Contributor -License Agreement (CLA): - -- **If you are an individual writing original source code** and **you own the -intellectual property**, then you'll need to sign an [individual CLA][indvcla]. -- **If you work for a company that wants to allow you to contribute your work**, -then you'll need to sign a [corporate CLA][corpcla]. - -You can sign these electronically (just scroll to the bottom). After that, -we'll be able to accept your pull requests. - -## Contributor Code of Conduct - -As contributors and maintainers of this project, -and in the interest of fostering an open and welcoming community, -we pledge to respect all people who contribute through reporting issues, -posting feature requests, updating documentation, -submitting pull requests or patches, and other activities. - -We are committed to making participation in this project -a harassment-free experience for everyone, -regardless of level of experience, gender, gender identity and expression, -sexual orientation, disability, personal appearance, -body size, race, ethnicity, age, religion, or nationality. - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery -* Personal attacks -* Trolling or insulting/derogatory comments -* Public or private harassment -* Publishing other's private information, -such as physical or electronic -addresses, without explicit permission -* Other unethical or unprofessional conduct. - -Project maintainers have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct. -By adopting this Code of Conduct, -project maintainers commit themselves to fairly and consistently -applying these principles to every aspect of managing this project. -Project maintainers who do not follow or enforce the Code of Conduct -may be permanently removed from the project team. - -This code of conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. - -Instances of abusive, harassing, or otherwise unacceptable behavior -may be reported by opening an issue -or contacting one or more of the project maintainers. - -This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, -available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) - -[indvcla]: https://developers.google.com/open-source/cla/individual -[corpcla]: https://developers.google.com/open-source/cla/corporate diff --git a/vendor/google.golang.org/appengine/README.md b/vendor/google.golang.org/appengine/README.md deleted file mode 100644 index d86768a2..00000000 --- a/vendor/google.golang.org/appengine/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# Go App Engine packages - -[![Build Status](https://travis-ci.org/golang/appengine.svg)](https://travis-ci.org/golang/appengine) - -This repository supports the Go runtime on *App Engine standard*. -It provides APIs for interacting with App Engine services. -Its canonical import path is `google.golang.org/appengine`. - -See https://cloud.google.com/appengine/docs/go/ -for more information. - -File issue reports and feature requests on the [GitHub's issue -tracker](https://github.com/golang/appengine/issues). - -## Upgrading an App Engine app to the flexible environment - -This package does not work on *App Engine flexible*. - -There are many differences between the App Engine standard environment and -the flexible environment. - -See the [documentation on upgrading to the flexible environment](https://cloud.google.com/appengine/docs/flexible/go/upgrading). - -## Directory structure - -The top level directory of this repository is the `appengine` package. It -contains the -basic APIs (e.g. `appengine.NewContext`) that apply across APIs. Specific API -packages are in subdirectories (e.g. `datastore`). - -There is an `internal` subdirectory that contains service protocol buffers, -plus packages required for connectivity to make API calls. App Engine apps -should not directly import any package under `internal`. - -## Updating from legacy (`import "appengine"`) packages - -If you're currently using the bare `appengine` packages -(that is, not these ones, imported via `google.golang.org/appengine`), -then you can use the `aefix` tool to help automate an upgrade to these packages. - -Run `go get google.golang.org/appengine/cmd/aefix` to install it. - -### 1. Update import paths - -The import paths for App Engine packages are now fully qualified, based at `google.golang.org/appengine`. -You will need to update your code to use import paths starting with that; for instance, -code importing `appengine/datastore` will now need to import `google.golang.org/appengine/datastore`. - -### 2. Update code using deprecated, removed or modified APIs - -Most App Engine services are available with exactly the same API. -A few APIs were cleaned up, and there are some differences: - -* `appengine.Context` has been replaced with the `Context` type from `golang.org/x/net/context`. -* Logging methods that were on `appengine.Context` are now functions in `google.golang.org/appengine/log`. -* `appengine.Timeout` has been removed. Use `context.WithTimeout` instead. -* `appengine.Datacenter` now takes a `context.Context` argument. -* `datastore.PropertyLoadSaver` has been simplified to use slices in place of channels. -* `delay.Call` now returns an error. -* `search.FieldLoadSaver` now handles document metadata. -* `urlfetch.Transport` no longer has a Deadline field; set a deadline on the - `context.Context` instead. -* `aetest` no longer declares its own Context type, and uses the standard one instead. -* `taskqueue.QueueStats` no longer takes a maxTasks argument. That argument has been - deprecated and unused for a long time. -* `appengine.BackendHostname` and `appengine.BackendInstance` were for the deprecated backends feature. - Use `appengine.ModuleHostname`and `appengine.ModuleName` instead. -* Most of `appengine/file` and parts of `appengine/blobstore` are deprecated. - Use [Google Cloud Storage](https://godoc.org/cloud.google.com/go/storage) if the - feature you require is not present in the new - [blobstore package](https://google.golang.org/appengine/blobstore). -* `appengine/socket` is not required on App Engine flexible environment / Managed VMs. - Use the standard `net` package instead. diff --git a/vendor/google.golang.org/appengine/appengine.go b/vendor/google.golang.org/appengine/appengine.go deleted file mode 100644 index 76dedc81..00000000 --- a/vendor/google.golang.org/appengine/appengine.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2011 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -// Package appengine provides basic functionality for Google App Engine. -// -// For more information on how to write Go apps for Google App Engine, see: -// https://cloud.google.com/appengine/docs/go/ -package appengine // import "google.golang.org/appengine" - -import ( - "net/http" - - "github.com/golang/protobuf/proto" - "golang.org/x/net/context" - - "google.golang.org/appengine/internal" -) - -// The gophers party all night; the rabbits provide the beats. - -// Main is the principal entry point for an app running in App Engine. -// -// On App Engine Flexible it installs a trivial health checker if one isn't -// already registered, and starts listening on port 8080 (overridden by the -// $PORT environment variable). -// -// See https://cloud.google.com/appengine/docs/flexible/custom-runtimes#health_check_requests -// for details on how to do your own health checking. -// -// On App Engine Standard it ensures the server has started and is prepared to -// receive requests. -// -// Main never returns. -// -// Main is designed so that the app's main package looks like this: -// -// package main -// -// import ( -// "google.golang.org/appengine" -// -// _ "myapp/package0" -// _ "myapp/package1" -// ) -// -// func main() { -// appengine.Main() -// } -// -// The "myapp/packageX" packages are expected to register HTTP handlers -// in their init functions. -func Main() { - internal.Main() -} - -// IsDevAppServer reports whether the App Engine app is running in the -// development App Server. -func IsDevAppServer() bool { - return internal.IsDevAppServer() -} - -// NewContext returns a context for an in-flight HTTP request. -// This function is cheap. -func NewContext(req *http.Request) context.Context { - return internal.ReqContext(req) -} - -// WithContext returns a copy of the parent context -// and associates it with an in-flight HTTP request. -// This function is cheap. -func WithContext(parent context.Context, req *http.Request) context.Context { - return internal.WithContext(parent, req) -} - -// TODO(dsymonds): Add a Call function here? Otherwise other packages can't access internal.Call. - -// BlobKey is a key for a blobstore blob. -// -// Conceptually, this type belongs in the blobstore package, but it lives in -// the appengine package to avoid a circular dependency: blobstore depends on -// datastore, and datastore needs to refer to the BlobKey type. -type BlobKey string - -// GeoPoint represents a location as latitude/longitude in degrees. -type GeoPoint struct { - Lat, Lng float64 -} - -// Valid returns whether a GeoPoint is within [-90, 90] latitude and [-180, 180] longitude. -func (g GeoPoint) Valid() bool { - return -90 <= g.Lat && g.Lat <= 90 && -180 <= g.Lng && g.Lng <= 180 -} - -// APICallFunc defines a function type for handling an API call. -// See WithCallOverride. -type APICallFunc func(ctx context.Context, service, method string, in, out proto.Message) error - -// WithAPICallFunc returns a copy of the parent context -// that will cause API calls to invoke f instead of their normal operation. -// -// This is intended for advanced users only. -func WithAPICallFunc(ctx context.Context, f APICallFunc) context.Context { - return internal.WithCallOverride(ctx, internal.CallOverrideFunc(f)) -} - -// APICall performs an API call. -// -// This is not intended for general use; it is exported for use in conjunction -// with WithAPICallFunc. -func APICall(ctx context.Context, service, method string, in, out proto.Message) error { - return internal.Call(ctx, service, method, in, out) -} diff --git a/vendor/google.golang.org/appengine/appengine_test.go b/vendor/google.golang.org/appengine/appengine_test.go deleted file mode 100644 index f1cf0a1b..00000000 --- a/vendor/google.golang.org/appengine/appengine_test.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2014 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -package appengine - -import ( - "testing" -) - -func TestValidGeoPoint(t *testing.T) { - testCases := []struct { - desc string - pt GeoPoint - want bool - }{ - { - "valid", - GeoPoint{67.21, 13.37}, - true, - }, - { - "high lat", - GeoPoint{-90.01, 13.37}, - false, - }, - { - "low lat", - GeoPoint{90.01, 13.37}, - false, - }, - { - "high lng", - GeoPoint{67.21, 182}, - false, - }, - { - "low lng", - GeoPoint{67.21, -181}, - false, - }, - } - - for _, tc := range testCases { - if got := tc.pt.Valid(); got != tc.want { - t.Errorf("%s: got %v, want %v", tc.desc, got, tc.want) - } - } -} diff --git a/vendor/google.golang.org/appengine/appengine_vm.go b/vendor/google.golang.org/appengine/appengine_vm.go deleted file mode 100644 index f4b645aa..00000000 --- a/vendor/google.golang.org/appengine/appengine_vm.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -// +build !appengine - -package appengine - -import ( - "golang.org/x/net/context" - - "google.golang.org/appengine/internal" -) - -// BackgroundContext returns a context not associated with a request. -// This should only be used when not servicing a request. -// This only works in App Engine "flexible environment". -func BackgroundContext() context.Context { - return internal.BackgroundContext() -} diff --git a/vendor/google.golang.org/appengine/errors.go b/vendor/google.golang.org/appengine/errors.go deleted file mode 100644 index 16d0772e..00000000 --- a/vendor/google.golang.org/appengine/errors.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2011 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -// This file provides error functions for common API failure modes. - -package appengine - -import ( - "fmt" - - "google.golang.org/appengine/internal" -) - -// IsOverQuota reports whether err represents an API call failure -// due to insufficient available quota. -func IsOverQuota(err error) bool { - callErr, ok := err.(*internal.CallError) - return ok && callErr.Code == 4 -} - -// MultiError is returned by batch operations when there are errors with -// particular elements. Errors will be in a one-to-one correspondence with -// the input elements; successful elements will have a nil entry. -type MultiError []error - -func (m MultiError) Error() string { - s, n := "", 0 - for _, e := range m { - if e != nil { - if n == 0 { - s = e.Error() - } - n++ - } - } - switch n { - case 0: - return "(0 errors)" - case 1: - return s - case 2: - return s + " (and 1 other error)" - } - return fmt.Sprintf("%s (and %d other errors)", s, n-1) -} diff --git a/vendor/google.golang.org/appengine/go.mod b/vendor/google.golang.org/appengine/go.mod deleted file mode 100644 index f449359d..00000000 --- a/vendor/google.golang.org/appengine/go.mod +++ /dev/null @@ -1,7 +0,0 @@ -module google.golang.org/appengine - -require ( - github.com/golang/protobuf v1.2.0 - golang.org/x/net v0.0.0-20180724234803-3673e40ba225 - golang.org/x/text v0.3.0 -) diff --git a/vendor/google.golang.org/appengine/go.sum b/vendor/google.golang.org/appengine/go.sum deleted file mode 100644 index 5e644c2e..00000000 --- a/vendor/google.golang.org/appengine/go.sum +++ /dev/null @@ -1,3 +0,0 @@ -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/vendor/google.golang.org/appengine/identity.go b/vendor/google.golang.org/appengine/identity.go deleted file mode 100644 index b8dcf8f3..00000000 --- a/vendor/google.golang.org/appengine/identity.go +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright 2011 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -package appengine - -import ( - "time" - - "golang.org/x/net/context" - - "google.golang.org/appengine/internal" - pb "google.golang.org/appengine/internal/app_identity" - modpb "google.golang.org/appengine/internal/modules" -) - -// AppID returns the application ID for the current application. -// The string will be a plain application ID (e.g. "appid"), with a -// domain prefix for custom domain deployments (e.g. "example.com:appid"). -func AppID(c context.Context) string { return internal.AppID(c) } - -// DefaultVersionHostname returns the standard hostname of the default version -// of the current application (e.g. "my-app.appspot.com"). This is suitable for -// use in constructing URLs. -func DefaultVersionHostname(c context.Context) string { - return internal.DefaultVersionHostname(c) -} - -// ModuleName returns the module name of the current instance. -func ModuleName(c context.Context) string { - return internal.ModuleName(c) -} - -// ModuleHostname returns a hostname of a module instance. -// If module is the empty string, it refers to the module of the current instance. -// If version is empty, it refers to the version of the current instance if valid, -// or the default version of the module of the current instance. -// If instance is empty, ModuleHostname returns the load-balancing hostname. -func ModuleHostname(c context.Context, module, version, instance string) (string, error) { - req := &modpb.GetHostnameRequest{} - if module != "" { - req.Module = &module - } - if version != "" { - req.Version = &version - } - if instance != "" { - req.Instance = &instance - } - res := &modpb.GetHostnameResponse{} - if err := internal.Call(c, "modules", "GetHostname", req, res); err != nil { - return "", err - } - return *res.Hostname, nil -} - -// VersionID returns the version ID for the current application. -// It will be of the form "X.Y", where X is specified in app.yaml, -// and Y is a number generated when each version of the app is uploaded. -// It does not include a module name. -func VersionID(c context.Context) string { return internal.VersionID(c) } - -// InstanceID returns a mostly-unique identifier for this instance. -func InstanceID() string { return internal.InstanceID() } - -// Datacenter returns an identifier for the datacenter that the instance is running in. -func Datacenter(c context.Context) string { return internal.Datacenter(c) } - -// ServerSoftware returns the App Engine release version. -// In production, it looks like "Google App Engine/X.Y.Z". -// In the development appserver, it looks like "Development/X.Y". -func ServerSoftware() string { return internal.ServerSoftware() } - -// RequestID returns a string that uniquely identifies the request. -func RequestID(c context.Context) string { return internal.RequestID(c) } - -// AccessToken generates an OAuth2 access token for the specified scopes on -// behalf of service account of this application. This token will expire after -// the returned time. -func AccessToken(c context.Context, scopes ...string) (token string, expiry time.Time, err error) { - req := &pb.GetAccessTokenRequest{Scope: scopes} - res := &pb.GetAccessTokenResponse{} - - err = internal.Call(c, "app_identity_service", "GetAccessToken", req, res) - if err != nil { - return "", time.Time{}, err - } - return res.GetAccessToken(), time.Unix(res.GetExpirationTime(), 0), nil -} - -// Certificate represents a public certificate for the app. -type Certificate struct { - KeyName string - Data []byte // PEM-encoded X.509 certificate -} - -// PublicCertificates retrieves the public certificates for the app. -// They can be used to verify a signature returned by SignBytes. -func PublicCertificates(c context.Context) ([]Certificate, error) { - req := &pb.GetPublicCertificateForAppRequest{} - res := &pb.GetPublicCertificateForAppResponse{} - if err := internal.Call(c, "app_identity_service", "GetPublicCertificatesForApp", req, res); err != nil { - return nil, err - } - var cs []Certificate - for _, pc := range res.PublicCertificateList { - cs = append(cs, Certificate{ - KeyName: pc.GetKeyName(), - Data: []byte(pc.GetX509CertificatePem()), - }) - } - return cs, nil -} - -// ServiceAccount returns a string representing the service account name, in -// the form of an email address (typically app_id@appspot.gserviceaccount.com). -func ServiceAccount(c context.Context) (string, error) { - req := &pb.GetServiceAccountNameRequest{} - res := &pb.GetServiceAccountNameResponse{} - - err := internal.Call(c, "app_identity_service", "GetServiceAccountName", req, res) - if err != nil { - return "", err - } - return res.GetServiceAccountName(), err -} - -// SignBytes signs bytes using a private key unique to your application. -func SignBytes(c context.Context, bytes []byte) (keyName string, signature []byte, err error) { - req := &pb.SignForAppRequest{BytesToSign: bytes} - res := &pb.SignForAppResponse{} - - if err := internal.Call(c, "app_identity_service", "SignForApp", req, res); err != nil { - return "", nil, err - } - return res.GetKeyName(), res.GetSignatureBytes(), nil -} - -func init() { - internal.RegisterErrorCodeMap("app_identity_service", pb.AppIdentityServiceError_ErrorCode_name) - internal.RegisterErrorCodeMap("modules", modpb.ModulesServiceError_ErrorCode_name) -} diff --git a/vendor/google.golang.org/appengine/internal/api_race_test.go b/vendor/google.golang.org/appengine/internal/api_race_test.go deleted file mode 100644 index 6cfe9064..00000000 --- a/vendor/google.golang.org/appengine/internal/api_race_test.go +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2014 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -// +build race - -package internal - -func init() { raceDetector = true } diff --git a/vendor/google.golang.org/appengine/internal/api_test.go b/vendor/google.golang.org/appengine/internal/api_test.go deleted file mode 100644 index 1743254f..00000000 --- a/vendor/google.golang.org/appengine/internal/api_test.go +++ /dev/null @@ -1,465 +0,0 @@ -// Copyright 2014 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -// +build !appengine - -package internal - -import ( - "bufio" - "bytes" - "fmt" - "io" - "io/ioutil" - "net/http" - "net/http/httptest" - "net/url" - "os" - "os/exec" - "strings" - "sync/atomic" - "testing" - "time" - - "github.com/golang/protobuf/proto" - netcontext "golang.org/x/net/context" - - basepb "google.golang.org/appengine/internal/base" - remotepb "google.golang.org/appengine/internal/remote_api" -) - -const testTicketHeader = "X-Magic-Ticket-Header" - -func init() { - ticketHeader = testTicketHeader -} - -type fakeAPIHandler struct { - hang chan int // used for RunSlowly RPC - - LogFlushes int32 // atomic -} - -func (f *fakeAPIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - writeResponse := func(res *remotepb.Response) { - hresBody, err := proto.Marshal(res) - if err != nil { - http.Error(w, fmt.Sprintf("Failed encoding API response: %v", err), 500) - return - } - w.Write(hresBody) - } - - if r.URL.Path != "/rpc_http" { - http.NotFound(w, r) - return - } - hreqBody, err := ioutil.ReadAll(r.Body) - if err != nil { - http.Error(w, fmt.Sprintf("Bad body: %v", err), 500) - return - } - apiReq := &remotepb.Request{} - if err := proto.Unmarshal(hreqBody, apiReq); err != nil { - http.Error(w, fmt.Sprintf("Bad encoded API request: %v", err), 500) - return - } - if *apiReq.RequestId != "s3cr3t" && *apiReq.RequestId != DefaultTicket() { - writeResponse(&remotepb.Response{ - RpcError: &remotepb.RpcError{ - Code: proto.Int32(int32(remotepb.RpcError_SECURITY_VIOLATION)), - Detail: proto.String("bad security ticket"), - }, - }) - return - } - if got, want := r.Header.Get(dapperHeader), "trace-001"; got != want { - writeResponse(&remotepb.Response{ - RpcError: &remotepb.RpcError{ - Code: proto.Int32(int32(remotepb.RpcError_BAD_REQUEST)), - Detail: proto.String(fmt.Sprintf("trace info = %q, want %q", got, want)), - }, - }) - return - } - - service, method := *apiReq.ServiceName, *apiReq.Method - var resOut proto.Message - if service == "actordb" && method == "LookupActor" { - req := &basepb.StringProto{} - res := &basepb.StringProto{} - if err := proto.Unmarshal(apiReq.Request, req); err != nil { - http.Error(w, fmt.Sprintf("Bad encoded request: %v", err), 500) - return - } - if *req.Value == "Doctor Who" { - res.Value = proto.String("David Tennant") - } - resOut = res - } - if service == "errors" { - switch method { - case "Non200": - http.Error(w, "I'm a little teapot.", 418) - return - case "ShortResponse": - w.Header().Set("Content-Length", "100") - w.Write([]byte("way too short")) - return - case "OverQuota": - writeResponse(&remotepb.Response{ - RpcError: &remotepb.RpcError{ - Code: proto.Int32(int32(remotepb.RpcError_OVER_QUOTA)), - Detail: proto.String("you are hogging the resources!"), - }, - }) - return - case "RunSlowly": - // TestAPICallRPCFailure creates f.hang, but does not strobe it - // until Call returns with remotepb.RpcError_CANCELLED. - // This is here to force a happens-before relationship between - // the httptest server handler and shutdown. - <-f.hang - resOut = &basepb.VoidProto{} - } - } - if service == "logservice" && method == "Flush" { - // Pretend log flushing is slow. - time.Sleep(50 * time.Millisecond) - atomic.AddInt32(&f.LogFlushes, 1) - resOut = &basepb.VoidProto{} - } - - encOut, err := proto.Marshal(resOut) - if err != nil { - http.Error(w, fmt.Sprintf("Failed encoding response: %v", err), 500) - return - } - writeResponse(&remotepb.Response{ - Response: encOut, - }) -} - -func setup() (f *fakeAPIHandler, c *context, cleanup func()) { - f = &fakeAPIHandler{} - srv := httptest.NewServer(f) - u, err := url.Parse(srv.URL + apiPath) - if err != nil { - panic(fmt.Sprintf("url.Parse(%q): %v", srv.URL+apiPath, err)) - } - return f, &context{ - req: &http.Request{ - Header: http.Header{ - ticketHeader: []string{"s3cr3t"}, - dapperHeader: []string{"trace-001"}, - }, - }, - apiURL: u, - }, srv.Close -} - -func TestAPICall(t *testing.T) { - _, c, cleanup := setup() - defer cleanup() - - req := &basepb.StringProto{ - Value: proto.String("Doctor Who"), - } - res := &basepb.StringProto{} - err := Call(toContext(c), "actordb", "LookupActor", req, res) - if err != nil { - t.Fatalf("API call failed: %v", err) - } - if got, want := *res.Value, "David Tennant"; got != want { - t.Errorf("Response is %q, want %q", got, want) - } -} - -func TestAPICallTicketUnavailable(t *testing.T) { - resetEnv := SetTestEnv() - defer resetEnv() - _, c, cleanup := setup() - defer cleanup() - - c.req.Header.Set(ticketHeader, "") - req := &basepb.StringProto{ - Value: proto.String("Doctor Who"), - } - res := &basepb.StringProto{} - err := Call(toContext(c), "actordb", "LookupActor", req, res) - if err != nil { - t.Fatalf("API call failed: %v", err) - } - if got, want := *res.Value, "David Tennant"; got != want { - t.Errorf("Response is %q, want %q", got, want) - } -} - -func TestAPICallRPCFailure(t *testing.T) { - f, c, cleanup := setup() - defer cleanup() - - testCases := []struct { - method string - code remotepb.RpcError_ErrorCode - }{ - {"Non200", remotepb.RpcError_UNKNOWN}, - {"ShortResponse", remotepb.RpcError_UNKNOWN}, - {"OverQuota", remotepb.RpcError_OVER_QUOTA}, - {"RunSlowly", remotepb.RpcError_CANCELLED}, - } - f.hang = make(chan int) // only for RunSlowly - for _, tc := range testCases { - ctx, _ := netcontext.WithTimeout(toContext(c), 100*time.Millisecond) - err := Call(ctx, "errors", tc.method, &basepb.VoidProto{}, &basepb.VoidProto{}) - ce, ok := err.(*CallError) - if !ok { - t.Errorf("%s: API call error is %T (%v), want *CallError", tc.method, err, err) - continue - } - if ce.Code != int32(tc.code) { - t.Errorf("%s: ce.Code = %d, want %d", tc.method, ce.Code, tc.code) - } - if tc.method == "RunSlowly" { - f.hang <- 1 // release the HTTP handler - } - } -} - -func TestAPICallDialFailure(t *testing.T) { - // See what happens if the API host is unresponsive. - // This should time out quickly, not hang forever. - _, c, cleanup := setup() - defer cleanup() - // Reset the URL to the production address so that dialing fails. - c.apiURL = apiURL() - - start := time.Now() - err := Call(toContext(c), "foo", "bar", &basepb.VoidProto{}, &basepb.VoidProto{}) - const max = 1 * time.Second - if taken := time.Since(start); taken > max { - t.Errorf("Dial hang took too long: %v > %v", taken, max) - } - if err == nil { - t.Error("Call did not fail") - } -} - -func TestDelayedLogFlushing(t *testing.T) { - f, c, cleanup := setup() - defer cleanup() - - http.HandleFunc("/quick_log", func(w http.ResponseWriter, r *http.Request) { - logC := WithContext(netcontext.Background(), r) - fromContext(logC).apiURL = c.apiURL // Otherwise it will try to use the default URL. - Logf(logC, 1, "It's a lovely day.") - w.WriteHeader(200) - w.Write(make([]byte, 100<<10)) // write 100 KB to force HTTP flush - }) - - r := &http.Request{ - Method: "GET", - URL: &url.URL{ - Scheme: "http", - Path: "/quick_log", - }, - Header: c.req.Header, - Body: ioutil.NopCloser(bytes.NewReader(nil)), - } - w := httptest.NewRecorder() - - // Check that log flushing does not hold up the HTTP response. - start := time.Now() - handleHTTP(w, r) - if d := time.Since(start); d > 10*time.Millisecond { - t.Errorf("handleHTTP took %v, want under 10ms", d) - } - const hdr = "X-AppEngine-Log-Flush-Count" - if h := w.HeaderMap.Get(hdr); h != "1" { - t.Errorf("%s header = %q, want %q", hdr, h, "1") - } - if f := atomic.LoadInt32(&f.LogFlushes); f != 0 { - t.Errorf("After HTTP response: f.LogFlushes = %d, want 0", f) - } - - // Check that the log flush eventually comes in. - time.Sleep(100 * time.Millisecond) - if f := atomic.LoadInt32(&f.LogFlushes); f != 1 { - t.Errorf("After 100ms: f.LogFlushes = %d, want 1", f) - } -} - -func TestRemoteAddr(t *testing.T) { - var addr string - http.HandleFunc("/remote_addr", func(w http.ResponseWriter, r *http.Request) { - addr = r.RemoteAddr - }) - - testCases := []struct { - headers http.Header - addr string - }{ - {http.Header{"X-Appengine-User-Ip": []string{"10.5.2.1"}}, "10.5.2.1:80"}, - {http.Header{"X-Appengine-Remote-Addr": []string{"1.2.3.4"}}, "1.2.3.4:80"}, - {http.Header{"X-Appengine-Remote-Addr": []string{"1.2.3.4:8080"}}, "1.2.3.4:8080"}, - { - http.Header{"X-Appengine-Remote-Addr": []string{"2401:fa00:9:1:7646:a0ff:fe90:ca66"}}, - "[2401:fa00:9:1:7646:a0ff:fe90:ca66]:80", - }, - { - http.Header{"X-Appengine-Remote-Addr": []string{"[::1]:http"}}, - "[::1]:http", - }, - {http.Header{}, "127.0.0.1:80"}, - } - - for _, tc := range testCases { - r := &http.Request{ - Method: "GET", - URL: &url.URL{Scheme: "http", Path: "/remote_addr"}, - Header: tc.headers, - Body: ioutil.NopCloser(bytes.NewReader(nil)), - } - handleHTTP(httptest.NewRecorder(), r) - if addr != tc.addr { - t.Errorf("Header %v, got %q, want %q", tc.headers, addr, tc.addr) - } - } -} - -func TestPanickingHandler(t *testing.T) { - http.HandleFunc("/panic", func(http.ResponseWriter, *http.Request) { - panic("whoops!") - }) - r := &http.Request{ - Method: "GET", - URL: &url.URL{Scheme: "http", Path: "/panic"}, - Body: ioutil.NopCloser(bytes.NewReader(nil)), - } - rec := httptest.NewRecorder() - handleHTTP(rec, r) - if rec.Code != 500 { - t.Errorf("Panicking handler returned HTTP %d, want HTTP %d", rec.Code, 500) - } -} - -var raceDetector = false - -func TestAPICallAllocations(t *testing.T) { - if raceDetector { - t.Skip("not running under race detector") - } - - // Run the test API server in a subprocess so we aren't counting its allocations. - u, cleanup := launchHelperProcess(t) - defer cleanup() - c := &context{ - req: &http.Request{ - Header: http.Header{ - ticketHeader: []string{"s3cr3t"}, - dapperHeader: []string{"trace-001"}, - }, - }, - apiURL: u, - } - - req := &basepb.StringProto{ - Value: proto.String("Doctor Who"), - } - res := &basepb.StringProto{} - var apiErr error - avg := testing.AllocsPerRun(100, func() { - ctx, _ := netcontext.WithTimeout(toContext(c), 100*time.Millisecond) - if err := Call(ctx, "actordb", "LookupActor", req, res); err != nil && apiErr == nil { - apiErr = err // get the first error only - } - }) - if apiErr != nil { - t.Errorf("API call failed: %v", apiErr) - } - - // Lots of room for improvement... - const min, max float64 = 60, 85 - if avg < min || max < avg { - t.Errorf("Allocations per API call = %g, want in [%g,%g]", avg, min, max) - } -} - -func launchHelperProcess(t *testing.T) (apiURL *url.URL, cleanup func()) { - cmd := exec.Command(os.Args[0], "-test.run=TestHelperProcess") - cmd.Env = []string{"GO_WANT_HELPER_PROCESS=1"} - stdin, err := cmd.StdinPipe() - if err != nil { - t.Fatalf("StdinPipe: %v", err) - } - stdout, err := cmd.StdoutPipe() - if err != nil { - t.Fatalf("StdoutPipe: %v", err) - } - if err := cmd.Start(); err != nil { - t.Fatalf("Starting helper process: %v", err) - } - - scan := bufio.NewScanner(stdout) - var u *url.URL - for scan.Scan() { - line := scan.Text() - if hp := strings.TrimPrefix(line, helperProcessMagic); hp != line { - var err error - u, err = url.Parse(hp) - if err != nil { - t.Fatalf("Failed to parse %q: %v", hp, err) - } - break - } - } - if err := scan.Err(); err != nil { - t.Fatalf("Scanning helper process stdout: %v", err) - } - if u == nil { - t.Fatal("Helper process never reported") - } - - return u, func() { - stdin.Close() - if err := cmd.Wait(); err != nil { - t.Errorf("Helper process did not exit cleanly: %v", err) - } - } -} - -const helperProcessMagic = "A lovely helper process is listening at " - -// This isn't a real test. It's used as a helper process. -func TestHelperProcess(*testing.T) { - if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" { - return - } - defer os.Exit(0) - - f := &fakeAPIHandler{} - srv := httptest.NewServer(f) - defer srv.Close() - fmt.Println(helperProcessMagic + srv.URL + apiPath) - - // Wait for stdin to be closed. - io.Copy(ioutil.Discard, os.Stdin) -} - -func TestBackgroundContext(t *testing.T) { - resetEnv := SetTestEnv() - defer resetEnv() - - ctx, key := fromContext(BackgroundContext()), "X-Magic-Ticket-Header" - if g, w := ctx.req.Header.Get(key), "my-app-id/default.20150612t184001.0"; g != w { - t.Errorf("%v = %q, want %q", key, g, w) - } - - // Check that using the background context doesn't panic. - req := &basepb.StringProto{ - Value: proto.String("Doctor Who"), - } - res := &basepb.StringProto{} - Call(BackgroundContext(), "actordb", "LookupActor", req, res) // expected to fail -} diff --git a/vendor/google.golang.org/appengine/internal/app_id_test.go b/vendor/google.golang.org/appengine/internal/app_id_test.go deleted file mode 100644 index e69195cd..00000000 --- a/vendor/google.golang.org/appengine/internal/app_id_test.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2011 Google Inc. All Rights Reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -package internal - -import ( - "testing" -) - -func TestAppIDParsing(t *testing.T) { - testCases := []struct { - in string - partition, domain, displayID string - }{ - {"simple-app-id", "", "", "simple-app-id"}, - {"domain.com:domain-app-id", "", "domain.com", "domain-app-id"}, - {"part~partition-app-id", "part", "", "partition-app-id"}, - {"part~domain.com:display", "part", "domain.com", "display"}, - } - - for _, tc := range testCases { - part, dom, dis := parseFullAppID(tc.in) - if part != tc.partition { - t.Errorf("partition of %q: got %q, want %q", tc.in, part, tc.partition) - } - if dom != tc.domain { - t.Errorf("domain of %q: got %q, want %q", tc.in, dom, tc.domain) - } - if dis != tc.displayID { - t.Errorf("displayID of %q: got %q, want %q", tc.in, dis, tc.displayID) - } - } -} diff --git a/vendor/google.golang.org/appengine/internal/base/api_base.proto b/vendor/google.golang.org/appengine/internal/base/api_base.proto deleted file mode 100644 index 56cd7a3c..00000000 --- a/vendor/google.golang.org/appengine/internal/base/api_base.proto +++ /dev/null @@ -1,33 +0,0 @@ -// Built-in base types for API calls. Primarily useful as return types. - -syntax = "proto2"; -option go_package = "base"; - -package appengine.base; - -message StringProto { - required string value = 1; -} - -message Integer32Proto { - required int32 value = 1; -} - -message Integer64Proto { - required int64 value = 1; -} - -message BoolProto { - required bool value = 1; -} - -message DoubleProto { - required double value = 1; -} - -message BytesProto { - required bytes value = 1 [ctype=CORD]; -} - -message VoidProto { -} diff --git a/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto b/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto deleted file mode 100755 index 497b4d9a..00000000 --- a/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto +++ /dev/null @@ -1,551 +0,0 @@ -syntax = "proto2"; -option go_package = "datastore"; - -package appengine; - -message Action{} - -message PropertyValue { - optional int64 int64Value = 1; - optional bool booleanValue = 2; - optional string stringValue = 3; - optional double doubleValue = 4; - - optional group PointValue = 5 { - required double x = 6; - required double y = 7; - } - - optional group UserValue = 8 { - required string email = 9; - required string auth_domain = 10; - optional string nickname = 11; - optional string federated_identity = 21; - optional string federated_provider = 22; - } - - optional group ReferenceValue = 12 { - required string app = 13; - optional string name_space = 20; - repeated group PathElement = 14 { - required string type = 15; - optional int64 id = 16; - optional string name = 17; - } - } -} - -message Property { - enum Meaning { - NO_MEANING = 0; - BLOB = 14; - TEXT = 15; - BYTESTRING = 16; - - ATOM_CATEGORY = 1; - ATOM_LINK = 2; - ATOM_TITLE = 3; - ATOM_CONTENT = 4; - ATOM_SUMMARY = 5; - ATOM_AUTHOR = 6; - - GD_WHEN = 7; - GD_EMAIL = 8; - GEORSS_POINT = 9; - GD_IM = 10; - - GD_PHONENUMBER = 11; - GD_POSTALADDRESS = 12; - - GD_RATING = 13; - - BLOBKEY = 17; - ENTITY_PROTO = 19; - - INDEX_VALUE = 18; - }; - - optional Meaning meaning = 1 [default = NO_MEANING]; - optional string meaning_uri = 2; - - required string name = 3; - - required PropertyValue value = 5; - - required bool multiple = 4; - - optional bool searchable = 6 [default=false]; - - enum FtsTokenizationOption { - HTML = 1; - ATOM = 2; - } - - optional FtsTokenizationOption fts_tokenization_option = 8; - - optional string locale = 9 [default = "en"]; -} - -message Path { - repeated group Element = 1 { - required string type = 2; - optional int64 id = 3; - optional string name = 4; - } -} - -message Reference { - required string app = 13; - optional string name_space = 20; - required Path path = 14; -} - -message User { - required string email = 1; - required string auth_domain = 2; - optional string nickname = 3; - optional string federated_identity = 6; - optional string federated_provider = 7; -} - -message EntityProto { - required Reference key = 13; - required Path entity_group = 16; - optional User owner = 17; - - enum Kind { - GD_CONTACT = 1; - GD_EVENT = 2; - GD_MESSAGE = 3; - } - optional Kind kind = 4; - optional string kind_uri = 5; - - repeated Property property = 14; - repeated Property raw_property = 15; - - optional int32 rank = 18; -} - -message CompositeProperty { - required int64 index_id = 1; - repeated string value = 2; -} - -message Index { - required string entity_type = 1; - required bool ancestor = 5; - repeated group Property = 2 { - required string name = 3; - enum Direction { - ASCENDING = 1; - DESCENDING = 2; - } - optional Direction direction = 4 [default = ASCENDING]; - } -} - -message CompositeIndex { - required string app_id = 1; - required int64 id = 2; - required Index definition = 3; - - enum State { - WRITE_ONLY = 1; - READ_WRITE = 2; - DELETED = 3; - ERROR = 4; - } - required State state = 4; - - optional bool only_use_if_required = 6 [default = false]; -} - -message IndexPostfix { - message IndexValue { - required string property_name = 1; - required PropertyValue value = 2; - } - - repeated IndexValue index_value = 1; - - optional Reference key = 2; - - optional bool before = 3 [default=true]; -} - -message IndexPosition { - optional string key = 1; - - optional bool before = 2 [default=true]; -} - -message Snapshot { - enum Status { - INACTIVE = 0; - ACTIVE = 1; - } - - required int64 ts = 1; -} - -message InternalHeader { - optional string qos = 1; -} - -message Transaction { - optional InternalHeader header = 4; - required fixed64 handle = 1; - required string app = 2; - optional bool mark_changes = 3 [default = false]; -} - -message Query { - optional InternalHeader header = 39; - - required string app = 1; - optional string name_space = 29; - - optional string kind = 3; - optional Reference ancestor = 17; - - repeated group Filter = 4 { - enum Operator { - LESS_THAN = 1; - LESS_THAN_OR_EQUAL = 2; - GREATER_THAN = 3; - GREATER_THAN_OR_EQUAL = 4; - EQUAL = 5; - IN = 6; - EXISTS = 7; - } - - required Operator op = 6; - repeated Property property = 14; - } - - optional string search_query = 8; - - repeated group Order = 9 { - enum Direction { - ASCENDING = 1; - DESCENDING = 2; - } - - required string property = 10; - optional Direction direction = 11 [default = ASCENDING]; - } - - enum Hint { - ORDER_FIRST = 1; - ANCESTOR_FIRST = 2; - FILTER_FIRST = 3; - } - optional Hint hint = 18; - - optional int32 count = 23; - - optional int32 offset = 12 [default = 0]; - - optional int32 limit = 16; - - optional CompiledCursor compiled_cursor = 30; - optional CompiledCursor end_compiled_cursor = 31; - - repeated CompositeIndex composite_index = 19; - - optional bool require_perfect_plan = 20 [default = false]; - - optional bool keys_only = 21 [default = false]; - - optional Transaction transaction = 22; - - optional bool compile = 25 [default = false]; - - optional int64 failover_ms = 26; - - optional bool strong = 32; - - repeated string property_name = 33; - - repeated string group_by_property_name = 34; - - optional bool distinct = 24; - - optional int64 min_safe_time_seconds = 35; - - repeated string safe_replica_name = 36; - - optional bool persist_offset = 37 [default=false]; -} - -message CompiledQuery { - required group PrimaryScan = 1 { - optional string index_name = 2; - - optional string start_key = 3; - optional bool start_inclusive = 4; - optional string end_key = 5; - optional bool end_inclusive = 6; - - repeated string start_postfix_value = 22; - repeated string end_postfix_value = 23; - - optional int64 end_unapplied_log_timestamp_us = 19; - } - - repeated group MergeJoinScan = 7 { - required string index_name = 8; - - repeated string prefix_value = 9; - - optional bool value_prefix = 20 [default=false]; - } - - optional Index index_def = 21; - - optional int32 offset = 10 [default = 0]; - - optional int32 limit = 11; - - required bool keys_only = 12; - - repeated string property_name = 24; - - optional int32 distinct_infix_size = 25; - - optional group EntityFilter = 13 { - optional bool distinct = 14 [default=false]; - - optional string kind = 17; - optional Reference ancestor = 18; - } -} - -message CompiledCursor { - optional group Position = 2 { - optional string start_key = 27; - - repeated group IndexValue = 29 { - optional string property = 30; - required PropertyValue value = 31; - } - - optional Reference key = 32; - - optional bool start_inclusive = 28 [default=true]; - } -} - -message Cursor { - required fixed64 cursor = 1; - - optional string app = 2; -} - -message Error { - enum ErrorCode { - BAD_REQUEST = 1; - CONCURRENT_TRANSACTION = 2; - INTERNAL_ERROR = 3; - NEED_INDEX = 4; - TIMEOUT = 5; - PERMISSION_DENIED = 6; - BIGTABLE_ERROR = 7; - COMMITTED_BUT_STILL_APPLYING = 8; - CAPABILITY_DISABLED = 9; - TRY_ALTERNATE_BACKEND = 10; - SAFE_TIME_TOO_OLD = 11; - } -} - -message Cost { - optional int32 index_writes = 1; - optional int32 index_write_bytes = 2; - optional int32 entity_writes = 3; - optional int32 entity_write_bytes = 4; - optional group CommitCost = 5 { - optional int32 requested_entity_puts = 6; - optional int32 requested_entity_deletes = 7; - }; - optional int32 approximate_storage_delta = 8; - optional int32 id_sequence_updates = 9; -} - -message GetRequest { - optional InternalHeader header = 6; - - repeated Reference key = 1; - optional Transaction transaction = 2; - - optional int64 failover_ms = 3; - - optional bool strong = 4; - - optional bool allow_deferred = 5 [default=false]; -} - -message GetResponse { - repeated group Entity = 1 { - optional EntityProto entity = 2; - optional Reference key = 4; - - optional int64 version = 3; - } - - repeated Reference deferred = 5; - - optional bool in_order = 6 [default=true]; -} - -message PutRequest { - optional InternalHeader header = 11; - - repeated EntityProto entity = 1; - optional Transaction transaction = 2; - repeated CompositeIndex composite_index = 3; - - optional bool trusted = 4 [default = false]; - - optional bool force = 7 [default = false]; - - optional bool mark_changes = 8 [default = false]; - repeated Snapshot snapshot = 9; - - enum AutoIdPolicy { - CURRENT = 0; - SEQUENTIAL = 1; - } - optional AutoIdPolicy auto_id_policy = 10 [default = CURRENT]; -} - -message PutResponse { - repeated Reference key = 1; - optional Cost cost = 2; - repeated int64 version = 3; -} - -message TouchRequest { - optional InternalHeader header = 10; - - repeated Reference key = 1; - repeated CompositeIndex composite_index = 2; - optional bool force = 3 [default = false]; - repeated Snapshot snapshot = 9; -} - -message TouchResponse { - optional Cost cost = 1; -} - -message DeleteRequest { - optional InternalHeader header = 10; - - repeated Reference key = 6; - optional Transaction transaction = 5; - - optional bool trusted = 4 [default = false]; - - optional bool force = 7 [default = false]; - - optional bool mark_changes = 8 [default = false]; - repeated Snapshot snapshot = 9; -} - -message DeleteResponse { - optional Cost cost = 1; - repeated int64 version = 3; -} - -message NextRequest { - optional InternalHeader header = 5; - - required Cursor cursor = 1; - optional int32 count = 2; - - optional int32 offset = 4 [default = 0]; - - optional bool compile = 3 [default = false]; -} - -message QueryResult { - optional Cursor cursor = 1; - - repeated EntityProto result = 2; - - optional int32 skipped_results = 7; - - required bool more_results = 3; - - optional bool keys_only = 4; - - optional bool index_only = 9; - - optional bool small_ops = 10; - - optional CompiledQuery compiled_query = 5; - - optional CompiledCursor compiled_cursor = 6; - - repeated CompositeIndex index = 8; - - repeated int64 version = 11; -} - -message AllocateIdsRequest { - optional InternalHeader header = 4; - - optional Reference model_key = 1; - - optional int64 size = 2; - - optional int64 max = 3; - - repeated Reference reserve = 5; -} - -message AllocateIdsResponse { - required int64 start = 1; - required int64 end = 2; - optional Cost cost = 3; -} - -message CompositeIndices { - repeated CompositeIndex index = 1; -} - -message AddActionsRequest { - optional InternalHeader header = 3; - - required Transaction transaction = 1; - repeated Action action = 2; -} - -message AddActionsResponse { -} - -message BeginTransactionRequest { - optional InternalHeader header = 3; - - required string app = 1; - optional bool allow_multiple_eg = 2 [default = false]; - optional string database_id = 4; - - enum TransactionMode { - UNKNOWN = 0; - READ_ONLY = 1; - READ_WRITE = 2; - } - optional TransactionMode mode = 5 [default = UNKNOWN]; - - optional Transaction previous_transaction = 7; -} - -message CommitResponse { - optional Cost cost = 1; - - repeated group Version = 3 { - required Reference root_entity_key = 4; - required int64 version = 5; - } -} diff --git a/vendor/google.golang.org/appengine/internal/internal_vm_test.go b/vendor/google.golang.org/appengine/internal/internal_vm_test.go deleted file mode 100644 index f8097616..00000000 --- a/vendor/google.golang.org/appengine/internal/internal_vm_test.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2014 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -// +build !appengine - -package internal - -import ( - "io" - "io/ioutil" - "net/http" - "net/http/httptest" - "testing" -) - -func TestInstallingHealthChecker(t *testing.T) { - try := func(desc string, mux *http.ServeMux, wantCode int, wantBody string) { - installHealthChecker(mux) - srv := httptest.NewServer(mux) - defer srv.Close() - - resp, err := http.Get(srv.URL + "/_ah/health") - if err != nil { - t.Errorf("%s: http.Get: %v", desc, err) - return - } - defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - t.Errorf("%s: reading body: %v", desc, err) - return - } - - if resp.StatusCode != wantCode { - t.Errorf("%s: got HTTP %d, want %d", desc, resp.StatusCode, wantCode) - return - } - if wantBody != "" && string(body) != wantBody { - t.Errorf("%s: got HTTP body %q, want %q", desc, body, wantBody) - return - } - } - - // If there's no handlers, or only a root handler, a health checker should be installed. - try("empty mux", http.NewServeMux(), 200, "ok") - mux := http.NewServeMux() - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, "root handler") - }) - try("mux with root handler", mux, 200, "ok") - - // If there's a custom health check handler, one should not be installed. - mux = http.NewServeMux() - mux.HandleFunc("/_ah/health", func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(418) - io.WriteString(w, "I'm short and stout!") - }) - try("mux with custom health checker", mux, 418, "I'm short and stout!") -} diff --git a/vendor/google.golang.org/appengine/internal/log/log_service.proto b/vendor/google.golang.org/appengine/internal/log/log_service.proto deleted file mode 100644 index 8981dc47..00000000 --- a/vendor/google.golang.org/appengine/internal/log/log_service.proto +++ /dev/null @@ -1,150 +0,0 @@ -syntax = "proto2"; -option go_package = "log"; - -package appengine; - -message LogServiceError { - enum ErrorCode { - OK = 0; - INVALID_REQUEST = 1; - STORAGE_ERROR = 2; - } -} - -message UserAppLogLine { - required int64 timestamp_usec = 1; - required int64 level = 2; - required string message = 3; -} - -message UserAppLogGroup { - repeated UserAppLogLine log_line = 2; -} - -message FlushRequest { - optional bytes logs = 1; -} - -message SetStatusRequest { - required string status = 1; -} - - -message LogOffset { - optional bytes request_id = 1; -} - -message LogLine { - required int64 time = 1; - required int32 level = 2; - required string log_message = 3; -} - -message RequestLog { - required string app_id = 1; - optional string module_id = 37 [default="default"]; - required string version_id = 2; - required bytes request_id = 3; - optional LogOffset offset = 35; - required string ip = 4; - optional string nickname = 5; - required int64 start_time = 6; - required int64 end_time = 7; - required int64 latency = 8; - required int64 mcycles = 9; - required string method = 10; - required string resource = 11; - required string http_version = 12; - required int32 status = 13; - required int64 response_size = 14; - optional string referrer = 15; - optional string user_agent = 16; - required string url_map_entry = 17; - required string combined = 18; - optional int64 api_mcycles = 19; - optional string host = 20; - optional double cost = 21; - - optional string task_queue_name = 22; - optional string task_name = 23; - - optional bool was_loading_request = 24; - optional int64 pending_time = 25; - optional int32 replica_index = 26 [default = -1]; - optional bool finished = 27 [default = true]; - optional bytes clone_key = 28; - - repeated LogLine line = 29; - - optional bool lines_incomplete = 36; - optional bytes app_engine_release = 38; - - optional int32 exit_reason = 30; - optional bool was_throttled_for_time = 31; - optional bool was_throttled_for_requests = 32; - optional int64 throttled_time = 33; - - optional bytes server_name = 34; -} - -message LogModuleVersion { - optional string module_id = 1 [default="default"]; - optional string version_id = 2; -} - -message LogReadRequest { - required string app_id = 1; - repeated string version_id = 2; - repeated LogModuleVersion module_version = 19; - - optional int64 start_time = 3; - optional int64 end_time = 4; - optional LogOffset offset = 5; - repeated bytes request_id = 6; - - optional int32 minimum_log_level = 7; - optional bool include_incomplete = 8; - optional int64 count = 9; - - optional string combined_log_regex = 14; - optional string host_regex = 15; - optional int32 replica_index = 16; - - optional bool include_app_logs = 10; - optional int32 app_logs_per_request = 17; - optional bool include_host = 11; - optional bool include_all = 12; - optional bool cache_iterator = 13; - optional int32 num_shards = 18; -} - -message LogReadResponse { - repeated RequestLog log = 1; - optional LogOffset offset = 2; - optional int64 last_end_time = 3; -} - -message LogUsageRecord { - optional string version_id = 1; - optional int32 start_time = 2; - optional int32 end_time = 3; - optional int64 count = 4; - optional int64 total_size = 5; - optional int32 records = 6; -} - -message LogUsageRequest { - required string app_id = 1; - repeated string version_id = 2; - optional int32 start_time = 3; - optional int32 end_time = 4; - optional uint32 resolution_hours = 5 [default = 1]; - optional bool combine_versions = 6; - optional int32 usage_version = 7; - optional bool versions_only = 8; -} - -message LogUsageResponse { - repeated LogUsageRecord usage = 1; - optional LogUsageRecord summary = 2; -} diff --git a/vendor/google.golang.org/appengine/internal/net_test.go b/vendor/google.golang.org/appengine/internal/net_test.go deleted file mode 100644 index 24da8bb2..00000000 --- a/vendor/google.golang.org/appengine/internal/net_test.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2014 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -// +build !appengine - -package internal - -import ( - "sync" - "testing" - "time" - - netcontext "golang.org/x/net/context" - - basepb "google.golang.org/appengine/internal/base" -) - -func TestDialLimit(t *testing.T) { - // Fill up semaphore with false acquisitions to permit only two TCP connections at a time. - // We don't replace limitSem because that results in a data race when net/http lazily closes connections. - nFake := cap(limitSem) - 2 - for i := 0; i < nFake; i++ { - limitSem <- 1 - } - defer func() { - for i := 0; i < nFake; i++ { - <-limitSem - } - }() - - f, c, cleanup := setup() // setup is in api_test.go - defer cleanup() - f.hang = make(chan int) - - // If we make two RunSlowly RPCs (which will wait for f.hang to be strobed), - // then the simple Non200 RPC should hang. - var wg sync.WaitGroup - wg.Add(2) - for i := 0; i < 2; i++ { - go func() { - defer wg.Done() - Call(toContext(c), "errors", "RunSlowly", &basepb.VoidProto{}, &basepb.VoidProto{}) - }() - } - time.Sleep(50 * time.Millisecond) // let those two RPCs start - - ctx, _ := netcontext.WithTimeout(toContext(c), 50*time.Millisecond) - err := Call(ctx, "errors", "Non200", &basepb.VoidProto{}, &basepb.VoidProto{}) - if err != errTimeout { - t.Errorf("Non200 RPC returned with err %v, want errTimeout", err) - } - - // Drain the two RunSlowly calls. - f.hang <- 1 - f.hang <- 1 - wg.Wait() -} diff --git a/vendor/google.golang.org/appengine/internal/regen.sh b/vendor/google.golang.org/appengine/internal/regen.sh deleted file mode 100755 index 2fdb546a..00000000 --- a/vendor/google.golang.org/appengine/internal/regen.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -e -# -# This script rebuilds the generated code for the protocol buffers. -# To run this you will need protoc and goprotobuf installed; -# see https://github.com/golang/protobuf for instructions. - -PKG=google.golang.org/appengine - -function die() { - echo 1>&2 $* - exit 1 -} - -# Sanity check that the right tools are accessible. -for tool in go protoc protoc-gen-go; do - q=$(which $tool) || die "didn't find $tool" - echo 1>&2 "$tool: $q" -done - -echo -n 1>&2 "finding package dir... " -pkgdir=$(go list -f '{{.Dir}}' $PKG) -echo 1>&2 $pkgdir -base=$(echo $pkgdir | sed "s,/$PKG\$,,") -echo 1>&2 "base: $base" -cd $base - -# Run protoc once per package. -for dir in $(find $PKG/internal -name '*.proto' | xargs dirname | sort | uniq); do - echo 1>&2 "* $dir" - protoc --go_out=. $dir/*.proto -done - -for f in $(find $PKG/internal -name '*.pb.go'); do - # Remove proto.RegisterEnum calls. - # These cause duplicate registration panics when these packages - # are used on classic App Engine. proto.RegisterEnum only affects - # parsing the text format; we don't care about that. - # https://code.google.com/p/googleappengine/issues/detail?id=11670#c17 - sed -i '/proto.RegisterEnum/d' $f -done diff --git a/vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto b/vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto deleted file mode 100644 index f21763a4..00000000 --- a/vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto +++ /dev/null @@ -1,44 +0,0 @@ -syntax = "proto2"; -option go_package = "remote_api"; - -package remote_api; - -message Request { - required string service_name = 2; - required string method = 3; - required bytes request = 4; - optional string request_id = 5; -} - -message ApplicationError { - required int32 code = 1; - required string detail = 2; -} - -message RpcError { - enum ErrorCode { - UNKNOWN = 0; - CALL_NOT_FOUND = 1; - PARSE_ERROR = 2; - SECURITY_VIOLATION = 3; - OVER_QUOTA = 4; - REQUEST_TOO_LARGE = 5; - CAPABILITY_DISABLED = 6; - FEATURE_DISABLED = 7; - BAD_REQUEST = 8; - RESPONSE_TOO_LARGE = 9; - CANCELLED = 10; - REPLAY_ERROR = 11; - DEADLINE_EXCEEDED = 12; - } - required int32 code = 1; - optional string detail = 2; -} - -message Response { - optional bytes response = 1; - optional bytes exception = 2; - optional ApplicationError application_error = 3; - optional bytes java_exception = 4; - optional RpcError rpc_error = 5; -} diff --git a/vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.proto b/vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.proto deleted file mode 100644 index f695edf6..00000000 --- a/vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.proto +++ /dev/null @@ -1,64 +0,0 @@ -syntax = "proto2"; -option go_package = "urlfetch"; - -package appengine; - -message URLFetchServiceError { - enum ErrorCode { - OK = 0; - INVALID_URL = 1; - FETCH_ERROR = 2; - UNSPECIFIED_ERROR = 3; - RESPONSE_TOO_LARGE = 4; - DEADLINE_EXCEEDED = 5; - SSL_CERTIFICATE_ERROR = 6; - DNS_ERROR = 7; - CLOSED = 8; - INTERNAL_TRANSIENT_ERROR = 9; - TOO_MANY_REDIRECTS = 10; - MALFORMED_REPLY = 11; - CONNECTION_ERROR = 12; - } -} - -message URLFetchRequest { - enum RequestMethod { - GET = 1; - POST = 2; - HEAD = 3; - PUT = 4; - DELETE = 5; - PATCH = 6; - } - required RequestMethod Method = 1; - required string Url = 2; - repeated group Header = 3 { - required string Key = 4; - required string Value = 5; - } - optional bytes Payload = 6 [ctype=CORD]; - - optional bool FollowRedirects = 7 [default=true]; - - optional double Deadline = 8; - - optional bool MustValidateServerCertificate = 9 [default=true]; -} - -message URLFetchResponse { - optional bytes Content = 1; - required int32 StatusCode = 2; - repeated group Header = 3 { - required string Key = 4; - required string Value = 5; - } - optional bool ContentWasTruncated = 6 [default=false]; - optional int64 ExternalBytesSent = 7; - optional int64 ExternalBytesReceived = 8; - - optional string FinalUrl = 9; - - optional int64 ApiCpuMilliseconds = 10 [default=0]; - optional int64 ApiBytesSent = 11 [default=0]; - optional int64 ApiBytesReceived = 12 [default=0]; -} diff --git a/vendor/google.golang.org/appengine/namespace.go b/vendor/google.golang.org/appengine/namespace.go deleted file mode 100644 index 21860ca0..00000000 --- a/vendor/google.golang.org/appengine/namespace.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -package appengine - -import ( - "fmt" - "regexp" - - "golang.org/x/net/context" - - "google.golang.org/appengine/internal" -) - -// Namespace returns a replacement context that operates within the given namespace. -func Namespace(c context.Context, namespace string) (context.Context, error) { - if !validNamespace.MatchString(namespace) { - return nil, fmt.Errorf("appengine: namespace %q does not match /%s/", namespace, validNamespace) - } - return internal.NamespacedContext(c, namespace), nil -} - -// validNamespace matches valid namespace names. -var validNamespace = regexp.MustCompile(`^[0-9A-Za-z._-]{0,100}$`) diff --git a/vendor/google.golang.org/appengine/namespace_test.go b/vendor/google.golang.org/appengine/namespace_test.go deleted file mode 100644 index 847f640b..00000000 --- a/vendor/google.golang.org/appengine/namespace_test.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -package appengine - -import ( - "testing" - - "golang.org/x/net/context" -) - -func TestNamespaceValidity(t *testing.T) { - testCases := []struct { - namespace string - ok bool - }{ - // data from Python's namespace_manager_test.py - {"", true}, - {"__a.namespace.123__", true}, - {"-_A....NAMESPACE-_", true}, - {"-", true}, - {".", true}, - {".-", true}, - - {"?", false}, - {"+", false}, - {"!", false}, - {" ", false}, - } - for _, tc := range testCases { - _, err := Namespace(context.Background(), tc.namespace) - if err == nil && !tc.ok { - t.Errorf("Namespace %q should be rejected, but wasn't", tc.namespace) - } else if err != nil && tc.ok { - t.Errorf("Namespace %q should be accepted, but wasn't", tc.namespace) - } - } -} diff --git a/vendor/google.golang.org/appengine/timeout.go b/vendor/google.golang.org/appengine/timeout.go deleted file mode 100644 index 05642a99..00000000 --- a/vendor/google.golang.org/appengine/timeout.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2013 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -package appengine - -import "golang.org/x/net/context" - -// IsTimeoutError reports whether err is a timeout error. -func IsTimeoutError(err error) bool { - if err == context.DeadlineExceeded { - return true - } - if t, ok := err.(interface { - IsTimeout() bool - }); ok { - return t.IsTimeout() - } - return false -}