Switch to dep for dependency management
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-client/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-client/commit/868863aa Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-client/tree/868863aa Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-client/diff/868863aa Branch: refs/heads/master Commit: 868863aa166e9ac90391fcd405f891c7c645b658 Parents: d8ef284 Author: Geoff Macartney <geoff.macart...@gmail.com> Authored: Sat Nov 17 22:49:20 2018 +0000 Committer: Geoff Macartney <geoff.macart...@gmail.com> Committed: Sun Nov 18 23:42:44 2018 +0000 ---------------------------------------------------------------------- cli/Gopkg.lock | 37 + cli/Gopkg.toml | 28 + cli/README.md | 4 +- cli/glide.lock | 15 - cli/glide.yaml | 9 - cli/pom.xml | 3 +- cli/release/build.sh | 1 - .../NodePrime/jsonpath/cli/jsonpath/main.go | 94 -- .../github.com/NodePrime/jsonpath/eval_test.go | 101 -- .../jsonpath/expression_states_test.go | 40 - .../NodePrime/jsonpath/expression_test.go | 226 --- .../NodePrime/jsonpath/json_states_test.go | 172 -- .../github.com/NodePrime/jsonpath/lexer_test.go | 309 ---- .../NodePrime/jsonpath/path_states_test.go | 30 - .../github.com/NodePrime/jsonpath/path_test.go | 40 - .../github.com/NodePrime/jsonpath/stack_test.go | 56 - cli/vendor/github.com/urfave/cli/app_test.go | 1047 ------------ .../urfave/cli/autocomplete/bash_autocomplete | 14 - .../urfave/cli/autocomplete/zsh_autocomplete | 5 - .../github.com/urfave/cli/command_test.go | 97 -- .../github.com/urfave/cli/context_test.go | 113 -- cli/vendor/github.com/urfave/cli/flag_test.go | 859 ---------- cli/vendor/github.com/urfave/cli/help_test.go | 94 -- .../github.com/urfave/cli/helpers_test.go | 19 - cli/vendor/golang.org/x/crypto/.gitattributes | 10 - cli/vendor/golang.org/x/crypto/.gitignore | 2 - cli/vendor/golang.org/x/crypto/CONTRIBUTING.md | 31 - cli/vendor/golang.org/x/crypto/README | 3 - cli/vendor/golang.org/x/crypto/bcrypt/base64.go | 35 - cli/vendor/golang.org/x/crypto/bcrypt/bcrypt.go | 294 ---- .../golang.org/x/crypto/bcrypt/bcrypt_test.go | 226 --- .../golang.org/x/crypto/blowfish/block.go | 159 -- .../x/crypto/blowfish/blowfish_test.go | 274 ---- .../golang.org/x/crypto/blowfish/cipher.go | 91 -- .../golang.org/x/crypto/blowfish/const.go | 199 --- cli/vendor/golang.org/x/crypto/bn256/bn256.go | 404 ----- .../golang.org/x/crypto/bn256/bn256_test.go | 304 ---- .../golang.org/x/crypto/bn256/constants.go | 44 - cli/vendor/golang.org/x/crypto/bn256/curve.go | 278 ---- .../golang.org/x/crypto/bn256/example_test.go | 43 - cli/vendor/golang.org/x/crypto/bn256/gfp12.go | 200 --- cli/vendor/golang.org/x/crypto/bn256/gfp2.go | 219 --- cli/vendor/golang.org/x/crypto/bn256/gfp6.go | 296 ---- cli/vendor/golang.org/x/crypto/bn256/optate.go | 395 ----- cli/vendor/golang.org/x/crypto/bn256/twist.go | 249 --- cli/vendor/golang.org/x/crypto/cast5/cast5.go | 526 ------ .../golang.org/x/crypto/cast5/cast5_test.go | 106 -- cli/vendor/golang.org/x/crypto/codereview.cfg | 1 - .../x/crypto/curve25519/const_amd64.s | 20 - .../x/crypto/curve25519/cswap_amd64.s | 88 - .../x/crypto/curve25519/curve25519.go | 841 ---------- .../x/crypto/curve25519/curve25519_test.go | 29 - .../golang.org/x/crypto/curve25519/doc.go | 23 - .../x/crypto/curve25519/freeze_amd64.s | 94 -- .../x/crypto/curve25519/ladderstep_amd64.s | 1398 ---------------- .../x/crypto/curve25519/mont25519_amd64.go | 240 --- .../golang.org/x/crypto/curve25519/mul_amd64.s | 191 --- .../x/crypto/curve25519/square_amd64.s | 153 -- .../golang.org/x/crypto/hkdf/example_test.go | 61 - cli/vendor/golang.org/x/crypto/hkdf/hkdf.go | 75 - .../golang.org/x/crypto/hkdf/hkdf_test.go | 370 ----- cli/vendor/golang.org/x/crypto/md4/md4.go | 118 -- cli/vendor/golang.org/x/crypto/md4/md4_test.go | 71 - cli/vendor/golang.org/x/crypto/md4/md4block.go | 89 - cli/vendor/golang.org/x/crypto/nacl/box/box.go | 85 - .../golang.org/x/crypto/nacl/box/box_test.go | 78 - .../x/crypto/nacl/secretbox/secretbox.go | 149 -- .../x/crypto/nacl/secretbox/secretbox_test.go | 91 -- cli/vendor/golang.org/x/crypto/ocsp/ocsp.go | 673 -------- .../golang.org/x/crypto/ocsp/ocsp_test.go | 584 ------- .../golang.org/x/crypto/openpgp/armor/armor.go | 219 --- .../x/crypto/openpgp/armor/armor_test.go | 95 -- .../golang.org/x/crypto/openpgp/armor/encode.go | 160 -- .../x/crypto/openpgp/canonical_text.go | 59 - .../x/crypto/openpgp/canonical_text_test.go | 52 - .../x/crypto/openpgp/clearsign/clearsign.go | 372 ----- .../crypto/openpgp/clearsign/clearsign_test.go | 197 --- .../x/crypto/openpgp/elgamal/elgamal.go | 122 -- .../x/crypto/openpgp/elgamal/elgamal_test.go | 49 - .../x/crypto/openpgp/errors/errors.go | 72 - cli/vendor/golang.org/x/crypto/openpgp/keys.go | 633 -------- .../golang.org/x/crypto/openpgp/keys_test.go | 370 ----- .../x/crypto/openpgp/packet/compressed.go | 123 -- .../x/crypto/openpgp/packet/compressed_test.go | 41 - .../x/crypto/openpgp/packet/config.go | 91 -- .../x/crypto/openpgp/packet/encrypted_key.go | 199 --- .../crypto/openpgp/packet/encrypted_key_test.go | 146 -- .../x/crypto/openpgp/packet/literal.go | 89 - .../golang.org/x/crypto/openpgp/packet/ocfb.go | 143 -- .../x/crypto/openpgp/packet/ocfb_test.go | 46 - .../crypto/openpgp/packet/one_pass_signature.go | 73 - .../x/crypto/openpgp/packet/opaque.go | 162 -- .../x/crypto/openpgp/packet/opaque_test.go | 67 - .../x/crypto/openpgp/packet/packet.go | 539 ------ .../x/crypto/openpgp/packet/packet_test.go | 255 --- .../x/crypto/openpgp/packet/private_key.go | 326 ---- .../x/crypto/openpgp/packet/private_key_test.go | 69 - .../x/crypto/openpgp/packet/public_key.go | 724 --------- .../x/crypto/openpgp/packet/public_key_test.go | 202 --- .../x/crypto/openpgp/packet/public_key_v3.go | 280 ---- .../crypto/openpgp/packet/public_key_v3_test.go | 82 - .../x/crypto/openpgp/packet/reader.go | 76 - .../x/crypto/openpgp/packet/signature.go | 699 -------- .../x/crypto/openpgp/packet/signature_test.go | 42 - .../x/crypto/openpgp/packet/signature_v3.go | 146 -- .../crypto/openpgp/packet/signature_v3_test.go | 92 -- .../openpgp/packet/symmetric_key_encrypted.go | 155 -- .../packet/symmetric_key_encrypted_test.go | 103 -- .../openpgp/packet/symmetrically_encrypted.go | 290 ---- .../packet/symmetrically_encrypted_test.go | 123 -- .../x/crypto/openpgp/packet/userattribute.go | 91 -- .../crypto/openpgp/packet/userattribute_test.go | 109 -- .../x/crypto/openpgp/packet/userid.go | 160 -- .../x/crypto/openpgp/packet/userid_test.go | 87 - cli/vendor/golang.org/x/crypto/openpgp/read.go | 439 ----- .../golang.org/x/crypto/openpgp/read_test.go | 512 ------ .../golang.org/x/crypto/openpgp/s2k/s2k.go | 273 ---- .../golang.org/x/crypto/openpgp/s2k/s2k_test.go | 137 -- cli/vendor/golang.org/x/crypto/openpgp/write.go | 378 ----- .../golang.org/x/crypto/openpgp/write_test.go | 259 --- .../x/crypto/otr/libotr_test_helper.c | 197 --- cli/vendor/golang.org/x/crypto/otr/otr.go | 1408 ---------------- cli/vendor/golang.org/x/crypto/otr/otr_test.go | 470 ------ cli/vendor/golang.org/x/crypto/otr/smp.go | 572 ------- cli/vendor/golang.org/x/crypto/pbkdf2/pbkdf2.go | 77 - .../golang.org/x/crypto/pbkdf2/pbkdf2_test.go | 157 -- .../golang.org/x/crypto/pkcs12/bmp-string.go | 50 - .../x/crypto/pkcs12/bmp-string_test.go | 63 - cli/vendor/golang.org/x/crypto/pkcs12/crypto.go | 131 -- .../golang.org/x/crypto/pkcs12/crypto_test.go | 125 -- cli/vendor/golang.org/x/crypto/pkcs12/errors.go | 23 - .../x/crypto/pkcs12/internal/rc2/bench_test.go | 27 - .../x/crypto/pkcs12/internal/rc2/rc2.go | 274 ---- .../x/crypto/pkcs12/internal/rc2/rc2_test.go | 93 -- cli/vendor/golang.org/x/crypto/pkcs12/mac.go | 45 - .../golang.org/x/crypto/pkcs12/mac_test.go | 42 - cli/vendor/golang.org/x/crypto/pkcs12/pbkdf.go | 170 -- .../golang.org/x/crypto/pkcs12/pbkdf_test.go | 34 - cli/vendor/golang.org/x/crypto/pkcs12/pkcs12.go | 342 ---- .../golang.org/x/crypto/pkcs12/pkcs12_test.go | 138 -- .../golang.org/x/crypto/pkcs12/safebags.go | 57 - .../golang.org/x/crypto/poly1305/const_amd64.s | 45 - .../golang.org/x/crypto/poly1305/poly1305.go | 32 - .../x/crypto/poly1305/poly1305_amd64.s | 497 ------ .../golang.org/x/crypto/poly1305/poly1305_arm.s | 379 ----- .../x/crypto/poly1305/poly1305_test.go | 86 - .../golang.org/x/crypto/poly1305/sum_amd64.go | 24 - .../golang.org/x/crypto/poly1305/sum_arm.go | 24 - .../golang.org/x/crypto/poly1305/sum_ref.go | 1531 ------------------ .../golang.org/x/crypto/ripemd160/ripemd160.go | 120 -- .../x/crypto/ripemd160/ripemd160_test.go | 64 - .../x/crypto/ripemd160/ripemd160block.go | 161 -- .../x/crypto/salsa20/salsa/hsalsa20.go | 144 -- .../x/crypto/salsa20/salsa/salsa2020_amd64.s | 902 ----------- .../x/crypto/salsa20/salsa/salsa208.go | 199 --- .../x/crypto/salsa20/salsa/salsa20_amd64.go | 23 - .../x/crypto/salsa20/salsa/salsa20_ref.go | 234 --- .../x/crypto/salsa20/salsa/salsa_test.go | 35 - .../golang.org/x/crypto/salsa20/salsa20.go | 54 - .../golang.org/x/crypto/salsa20/salsa20_test.go | 139 -- cli/vendor/golang.org/x/crypto/scrypt/scrypt.go | 243 --- .../golang.org/x/crypto/scrypt/scrypt_test.go | 160 -- cli/vendor/golang.org/x/crypto/sha3/doc.go | 66 - cli/vendor/golang.org/x/crypto/sha3/hashes.go | 65 - cli/vendor/golang.org/x/crypto/sha3/keccakf.go | 410 ----- cli/vendor/golang.org/x/crypto/sha3/register.go | 18 - cli/vendor/golang.org/x/crypto/sha3/sha3.go | 193 --- .../golang.org/x/crypto/sha3/sha3_test.go | 306 ---- cli/vendor/golang.org/x/crypto/sha3/shake.go | 60 - .../sha3/testdata/keccakKats.json.deflate | Bin 521342 -> 0 bytes cli/vendor/golang.org/x/crypto/sha3/xor.go | 16 - .../golang.org/x/crypto/sha3/xor_generic.go | 28 - .../golang.org/x/crypto/sha3/xor_unaligned.go | 58 - .../golang.org/x/crypto/ssh/agent/client.go | 615 ------- .../x/crypto/ssh/agent/client_test.go | 287 ---- .../golang.org/x/crypto/ssh/agent/forward.go | 103 -- .../golang.org/x/crypto/ssh/agent/keyring.go | 184 --- .../x/crypto/ssh/agent/keyring_test.go | 78 - .../golang.org/x/crypto/ssh/agent/server.go | 209 --- .../x/crypto/ssh/agent/server_test.go | 77 - .../x/crypto/ssh/agent/testdata_test.go | 64 - .../golang.org/x/crypto/ssh/benchmark_test.go | 122 -- cli/vendor/golang.org/x/crypto/ssh/buffer.go | 98 -- .../golang.org/x/crypto/ssh/buffer_test.go | 87 - cli/vendor/golang.org/x/crypto/ssh/certs.go | 501 ------ .../golang.org/x/crypto/ssh/certs_test.go | 216 --- cli/vendor/golang.org/x/crypto/ssh/channel.go | 631 -------- cli/vendor/golang.org/x/crypto/ssh/cipher.go | 552 ------- .../golang.org/x/crypto/ssh/cipher_test.go | 127 -- cli/vendor/golang.org/x/crypto/ssh/client.go | 213 --- .../golang.org/x/crypto/ssh/client_auth.go | 441 ----- .../golang.org/x/crypto/ssh/client_auth_test.go | 393 ----- .../golang.org/x/crypto/ssh/client_test.go | 39 - cli/vendor/golang.org/x/crypto/ssh/common.go | 354 ---- .../golang.org/x/crypto/ssh/connection.go | 144 -- cli/vendor/golang.org/x/crypto/ssh/doc.go | 18 - .../golang.org/x/crypto/ssh/example_test.go | 211 --- cli/vendor/golang.org/x/crypto/ssh/handshake.go | 412 ----- .../golang.org/x/crypto/ssh/handshake_test.go | 415 ----- cli/vendor/golang.org/x/crypto/ssh/kex.go | 526 ------ cli/vendor/golang.org/x/crypto/ssh/kex_test.go | 50 - cli/vendor/golang.org/x/crypto/ssh/keys.go | 720 -------- cli/vendor/golang.org/x/crypto/ssh/keys_test.go | 437 ----- cli/vendor/golang.org/x/crypto/ssh/mac.go | 57 - .../golang.org/x/crypto/ssh/mempipe_test.go | 110 -- cli/vendor/golang.org/x/crypto/ssh/messages.go | 725 --------- .../golang.org/x/crypto/ssh/messages_test.go | 254 --- cli/vendor/golang.org/x/crypto/ssh/mux.go | 356 ---- cli/vendor/golang.org/x/crypto/ssh/mux_test.go | 525 ------ cli/vendor/golang.org/x/crypto/ssh/server.go | 495 ------ cli/vendor/golang.org/x/crypto/ssh/session.go | 605 ------- .../golang.org/x/crypto/ssh/session_test.go | 774 --------- cli/vendor/golang.org/x/crypto/ssh/tcpip.go | 407 ----- .../golang.org/x/crypto/ssh/tcpip_test.go | 20 - .../x/crypto/ssh/terminal/terminal_test.go | 269 --- .../x/crypto/ssh/test/agent_unix_test.go | 59 - .../golang.org/x/crypto/ssh/test/cert_test.go | 47 - cli/vendor/golang.org/x/crypto/ssh/test/doc.go | 7 - .../x/crypto/ssh/test/forward_unix_test.go | 160 -- .../x/crypto/ssh/test/session_test.go | 340 ---- .../golang.org/x/crypto/ssh/test/tcpip_test.go | 46 - .../x/crypto/ssh/test/test_unix_test.go | 261 --- .../x/crypto/ssh/test/testdata_test.go | 64 - .../golang.org/x/crypto/ssh/testdata/doc.go | 8 - .../golang.org/x/crypto/ssh/testdata/keys.go | 43 - .../golang.org/x/crypto/ssh/testdata_test.go | 63 - cli/vendor/golang.org/x/crypto/ssh/transport.go | 332 ---- .../golang.org/x/crypto/ssh/transport_test.go | 109 -- cli/vendor/golang.org/x/crypto/tea/cipher.go | 109 -- cli/vendor/golang.org/x/crypto/tea/tea_test.go | 93 -- .../golang.org/x/crypto/twofish/twofish.go | 342 ---- .../golang.org/x/crypto/twofish/twofish_test.go | 129 -- cli/vendor/golang.org/x/crypto/xtea/block.go | 66 - cli/vendor/golang.org/x/crypto/xtea/cipher.go | 82 - .../golang.org/x/crypto/xtea/xtea_test.go | 229 --- cli/vendor/golang.org/x/crypto/xts/xts.go | 138 -- cli/vendor/golang.org/x/crypto/xts/xts_test.go | 85 - 237 files changed, 68 insertions(+), 50027 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/868863aa/cli/Gopkg.lock ---------------------------------------------------------------------- diff --git a/cli/Gopkg.lock b/cli/Gopkg.lock new file mode 100644 index 0000000..b0a14cf --- /dev/null +++ b/cli/Gopkg.lock @@ -0,0 +1,37 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + branch = "master" + digest = "1:bfdc609d11759ec1e9258f8f865eb8751bb2f338914f6d7feb5270b044d479ce" + name = "github.com/NodePrime/jsonpath" + packages = ["."] + pruneopts = "UT" + revision = "84403ded544328c99be3472727667179eef23a91" + source = "g...@github.com:johnmccabe/jsonpath.git" + +[[projects]] + digest = "1:0377edffb6fff9b100103369cba0d250ff6dfe1d9d77fb994f1541082d1ce1ab" + name = "github.com/urfave/cli" + packages = ["."] + pruneopts = "UT" + revision = "5db74198dee1cfe60cf06a611d03a420361baad6" + version = "v1.12.0" + +[[projects]] + digest = "1:25c94dba495a2eccc455516bb78d4b64cc69650b7fe9a358adc289c5a5fde1f5" + name = "golang.org/x/crypto" + packages = ["ssh/terminal"] + pruneopts = "UT" + revision = "1f22c0103821b9390939b6776727195525381532" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + input-imports = [ + "github.com/NodePrime/jsonpath", + "github.com/urfave/cli", + "golang.org/x/crypto/ssh/terminal", + ] + solver-name = "gps-cdcl" + solver-version = 1 http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/868863aa/cli/Gopkg.toml ---------------------------------------------------------------------- diff --git a/cli/Gopkg.toml b/cli/Gopkg.toml new file mode 100644 index 0000000..9a1dab3 --- /dev/null +++ b/cli/Gopkg.toml @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# +[[constraint]] + name = "github.com/NodePrime/jsonpath" + source = "g...@github.com:johnmccabe/jsonpath.git" + +[[constraint]] + name = "github.com/urfave/cli" + version = "1.12.0" + +[prune] + go-tests = true + unused-packages = true http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/868863aa/cli/README.md ---------------------------------------------------------------------- diff --git a/cli/README.md b/cli/README.md index e6fee04..762b612 100644 --- a/cli/README.md +++ b/cli/README.md @@ -27,8 +27,8 @@ as it relies on this in the naming of packages. If you're familiar with Go and just want to develop the `br` tool itself you may simply work in your usual `GOPATH`, using `go get github.com/apache/brooklyn-client/cli/br` and adding your own fork as a remote. -If you know `glide` then you probably know what to do and can ignore these instructions; -`br` is built just like any other Go project. + +`br` is built just like any other Go project. Dependencies are managed through [dep](https://github.com/golang/dep). If you're new to Go and you want to work on the CLI alongside non-Go components in Apache Brooklyn, then the common Go setup -- where code lives under the `GOPATH` -- may be tedious to work with. http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/868863aa/cli/glide.lock ---------------------------------------------------------------------- diff --git a/cli/glide.lock b/cli/glide.lock deleted file mode 100644 index 2abb271..0000000 --- a/cli/glide.lock +++ /dev/null @@ -1,15 +0,0 @@ -hash: 7c8519b92c19888ea206fc6997cc110841df216d67eb54dda8db4abc3d24cc0c -updated: 2018-03-23T12:39:58.092531Z -imports: -- name: github.com/NodePrime/jsonpath - version: 84403ded544328c99be3472727667179eef23a91 - repo: g...@github.com:johnmccabe/jsonpath.git - subpackages: - - cli/jsonpath -- name: github.com/urfave/cli - version: 5db74198dee1cfe60cf06a611d03a420361baad6 -- name: golang.org/x/crypto - version: 1f22c0103821b9390939b6776727195525381532 - subpackages: - - ssh/terminal -testImports: [] http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/868863aa/cli/glide.yaml ---------------------------------------------------------------------- diff --git a/cli/glide.yaml b/cli/glide.yaml deleted file mode 100644 index fedd0e7..0000000 --- a/cli/glide.yaml +++ /dev/null @@ -1,9 +0,0 @@ -package: github.com/apache/brooklyn-client/cli -import: -- package: github.com/urfave/cli -# using g...@github.com:johnmccabe/jsonpath.git temporarily as original repo deleted March 2018 -- package: github.com/NodePrime/jsonpath/cli/jsonpath - repo: g...@github.com:johnmccabe/jsonpath.git -- package: golang.org/x/crypto - subpackages: - - ssh/terminal http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/868863aa/cli/pom.xml ---------------------------------------------------------------------- diff --git a/cli/pom.xml b/cli/pom.xml index c96e311..d58e96e 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -100,8 +100,7 @@ <configuration> <excludes combine.children="append"> <exclude>vendor/**</exclude> - <exclude>glide.*</exclude> - <exclude>.glide/**</exclude> + <exclude>Gopkg.*</exclude> </excludes> </configuration> </plugin> http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/868863aa/cli/release/build.sh ---------------------------------------------------------------------- diff --git a/cli/release/build.sh b/cli/release/build.sh index beb1c2f..af1481f 100755 --- a/cli/release/build.sh +++ b/cli/release/build.sh @@ -26,7 +26,6 @@ BRNAME="br" PROJECT="github.com/apache/brooklyn-client/cli" CLI_PACKAGE="${PROJECT}/${BRNAME}" GOBIN=go -GLIDE=glide START_TIME=$(date +%s) http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/868863aa/cli/vendor/github.com/NodePrime/jsonpath/cli/jsonpath/main.go ---------------------------------------------------------------------- diff --git a/cli/vendor/github.com/NodePrime/jsonpath/cli/jsonpath/main.go b/cli/vendor/github.com/NodePrime/jsonpath/cli/jsonpath/main.go deleted file mode 100644 index 7ef9c00..0000000 --- a/cli/vendor/github.com/NodePrime/jsonpath/cli/jsonpath/main.go +++ /dev/null @@ -1,94 +0,0 @@ -package main - -import ( - "bufio" - "fmt" - "os" - "strings" - - "github.com/NodePrime/jsonpath" - flag "github.com/ogier/pflag" -) - -func main() { - var pathStrings pathSlice - filePtr := flag.StringP("file", "f", "", "Path to json file") - jsonPtr := flag.StringP("json", "j", "", "JSON text") - flag.VarP(&pathStrings, "path", "p", "One or more paths to target in JSON") - showKeysPtr := flag.BoolP("keys", "k", false, "Print keys & indexes that lead to value") - flag.Usage = func() { - fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0]) - flag.PrintDefaults() - fmt.Fprintln(os.Stderr, "Pipe JSON to StdIn by not specifying --file or --json ") - } - flag.Parse() - - if len(pathStrings) == 0 { - fmt.Println("Must specify one or more paths with the --path flag") - os.Exit(1) - } - - paths, err := jsonpath.ParsePaths(pathStrings...) - if err != nil { - fmt.Println(fmt.Errorf("Failed to parse paths: %q", err.Error())) - os.Exit(1) - } - - if filePtr != nil && *filePtr != "" { - f, err := os.Open(*filePtr) - if err != nil { - fmt.Println(fmt.Errorf("Failed to open file: %q", err.Error())) - os.Exit(1) - } - - eval, err := jsonpath.EvalPathsInReader(f, paths) - checkAndHandleError(err) - run(eval, *showKeysPtr) - checkAndHandleError(eval.Error) - f.Close() - - } else if jsonPtr != nil && *jsonPtr != "" { - eval, err := jsonpath.EvalPathsInBytes([]byte(*jsonPtr), paths) - checkAndHandleError(err) - run(eval, *showKeysPtr) - checkAndHandleError(eval.Error) - } else { - reader := bufio.NewReader(os.Stdin) - eval, err := jsonpath.EvalPathsInReader(reader, paths) - checkAndHandleError(err) - run(eval, *showKeysPtr) - checkAndHandleError(eval.Error) - } -} - -func run(eval *jsonpath.Eval, showKeys bool) { - for { - result, running := eval.Next() - if result != nil { - fmt.Print(result.Pretty(showKeys)) - } - if !running { - break - } - } -} - -func checkAndHandleError(err error) { - if err != nil { - fmt.Println(err) - os.Exit(1) - } -} - -type pathSlice []string - -func (i *pathSlice) Set(value string) error { - for _, dt := range strings.Split(value, ",") { - *i = append(*i, dt) - } - return nil -} - -func (i *pathSlice) String() string { - return fmt.Sprint(*i) -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/868863aa/cli/vendor/github.com/NodePrime/jsonpath/eval_test.go ---------------------------------------------------------------------- diff --git a/cli/vendor/github.com/NodePrime/jsonpath/eval_test.go b/cli/vendor/github.com/NodePrime/jsonpath/eval_test.go deleted file mode 100644 index bc391af..0000000 --- a/cli/vendor/github.com/NodePrime/jsonpath/eval_test.go +++ /dev/null @@ -1,101 +0,0 @@ -package jsonpath - -import ( - "strings" - "testing" - - "github.com/stretchr/testify/assert" -) - -type test struct { - name string - json string - path string - expected []Result -} - -var tests = []test{ - test{`key selection`, `{"aKey":32}`, `$.aKey+`, []Result{newResult(`32`, JsonNumber, `aKey`)}}, - test{`nested key selection`, `{"aKey":{"bKey":32}}`, `$.aKey+`, []Result{newResult(`{"bKey":32}`, JsonObject, `aKey`)}}, - test{`empty array`, `{"aKey":[]}`, `$.aKey+`, []Result{newResult(`[]`, JsonArray, `aKey`)}}, - test{`multiple same-level keys, weird spacing`, `{ "aKey" : true , "bKey": [ 1 , 2 ], "cKey" : true } `, `$.bKey+`, []Result{newResult(`[1,2]`, JsonArray, `bKey`)}}, - - test{`array index selection`, `{"aKey":[123,456]}`, `$.aKey[1]+`, []Result{newResult(`456`, JsonNumber, `aKey`, 1)}}, - test{`array wild index selection`, `{"aKey":[123,456]}`, `$.aKey[*]+`, []Result{newResult(`123`, JsonNumber, `aKey`, 0), newResult(`456`, JsonNumber, `aKey`, 1)}}, - test{`array range index selection`, `{"aKey":[11,22,33,44]}`, `$.aKey[1:3]+`, []Result{newResult(`22`, JsonNumber, `aKey`, 1), newResult(`33`, JsonNumber, `aKey`, 2)}}, - test{`array range (no index) selection`, `{"aKey":[11,22,33,44]}`, `$.aKey[1:1]+`, []Result{}}, - test{`array range (no upper bound) selection`, `{"aKey":[11,22,33]}`, `$.aKey[1:]+`, []Result{newResult(`22`, JsonNumber, `aKey`, 1), newResult(`33`, JsonNumber, `aKey`, 2)}}, - - test{`empty array - try selection`, `{"aKey":[]}`, `$.aKey[1]+`, []Result{}}, - test{`null selection`, `{"aKey":[null]}`, `$.aKey[0]+`, []Result{newResult(`null`, JsonNull, `aKey`, 0)}}, - test{`empty object`, `{"aKey":{}}`, `$.aKey+`, []Result{newResult(`{}`, JsonObject, `aKey`)}}, - test{`object w/ height=2`, `{"aKey":{"bKey":32}}`, `$.aKey.bKey+`, []Result{newResult(`32`, JsonNumber, `aKey`, `bKey`)}}, - test{`array of multiple types`, `{"aKey":[1,{"s":true},"asdf"]}`, `$.aKey[1]+`, []Result{newResult(`{"s":true}`, JsonObject, `aKey`, 1)}}, - test{`nested array selection`, `{"aKey":{"bKey":[123,456]}}`, `$.aKey.bKey+`, []Result{newResult(`[123,456]`, JsonArray, `aKey`, `bKey`)}}, - test{`nested array`, `[[[[[]], [true, false, []]]]]`, `$[0][0][1][2]+`, []Result{newResult(`[]`, JsonArray, 0, 0, 1, 2)}}, - test{`index of array selection`, `{"aKey":{"bKey":[123, 456, 789]}}`, `$.aKey.bKey[1]+`, []Result{newResult(`456`, JsonNumber, `aKey`, `bKey`, 1)}}, - test{`index of array selection (more than one)`, `{"aKey":{"bKey":[123,456]}}`, `$.aKey.bKey[1]+`, []Result{newResult(`456`, JsonNumber, `aKey`, `bKey`, 1)}}, - test{`multi-level object/array`, `{"1Key":{"aKey": null, "bKey":{"trash":[1,2]}, "cKey":[123,456] }, "2Key":false}`, `$.1Key.bKey.trash[0]+`, []Result{newResult(`1`, JsonNumber, `1Key`, `bKey`, `trash`, 0)}}, - test{`multi-level array`, `{"aKey":[true,false,null,{"michael":[5,6,7]}, ["s", "3"] ]}`, `$.*[*].michael[1]+`, []Result{newResult(`6`, JsonNumber, `aKey`, 3, `michael`, 1)}}, - test{`multi-level array 2`, `{"aKey":[true,false,null,{"michael":[5,6,7]}, ["s", "3"] ]}`, `$.*[*][1]+`, []Result{newResult(`"3"`, JsonString, `aKey`, 4, 1)}}, - - test{`evaluation literal equality`, `{"items":[ {"name":"alpha", "value":11}]}`, `$.items[*]?("bravo" == "bravo").value+`, []Result{newResult(`11`, JsonNumber, `items`, 0, `value`)}}, - test{`evaluation based on string equal to path value`, `{"items":[ {"name":"alpha", "value":11}, {"name":"bravo", "value":22}, {"name":"charlie", "value":33} ]}`, `$.items[*]?(@.name == "bravo").value+`, []Result{newResult(`22`, JsonNumber, `items`, 1, `value`)}}, -} - -func TestPathQuery(t *testing.T) { - as := assert.New(t) - - for _, t := range tests { - paths, err := ParsePaths(t.path) - if as.NoError(err) { - eval, err := EvalPathsInBytes([]byte(t.json), paths) - if as.NoError(err, "Testing: %s", t.name) { - res := toResultArray(eval) - if as.NoError(eval.Error) { - as.EqualValues(t.expected, res, "Testing of %q", t.name) - } - } - - eval_reader, err := EvalPathsInReader(strings.NewReader(t.json), paths) - if as.NoError(err, "Testing: %s", t.name) { - res := toResultArray(eval_reader) - if as.NoError(eval.Error) { - as.EqualValues(t.expected, res, "Testing of %q", t.name) - } - } - } - } -} - -func newResult(value string, typ int, keys ...interface{}) Result { - keysChanged := make([]interface{}, len(keys)) - for i, k := range keys { - switch v := k.(type) { - case string: - keysChanged[i] = []byte(v) - default: - keysChanged[i] = v - } - } - - return Result{ - Value: []byte(value), - Keys: keysChanged, - Type: typ, - } -} - -func toResultArray(e *Eval) []Result { - vals := make([]Result, 0) - for { - if r, ok := e.Next(); ok { - if r != nil { - vals = append(vals, *r) - } - } else { - break - } - } - return vals -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/868863aa/cli/vendor/github.com/NodePrime/jsonpath/expression_states_test.go ---------------------------------------------------------------------- diff --git a/cli/vendor/github.com/NodePrime/jsonpath/expression_states_test.go b/cli/vendor/github.com/NodePrime/jsonpath/expression_states_test.go deleted file mode 100644 index 2861c30..0000000 --- a/cli/vendor/github.com/NodePrime/jsonpath/expression_states_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package jsonpath - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/assert" -) - -var expressionTests = []lexTest{ - {"empty", "", []int{exprEOF}}, - {"spaces", " \t\r\n", []int{exprEOF}}, - {"numbers", " 1.3e10 ", []int{exprNumber, exprEOF}}, - // {"numbers with signs", "+1 -2.23", []int{exprNumber, exprOpPlus, exprNumber, exprEOF}}, - {"paths", " @.aKey[2].bKey ", []int{exprPath, exprEOF}}, - {"addition with mixed sign", "4+-19", []int{exprNumber, exprOpPlus, exprOpMinusUn, exprNumber, exprEOF}}, - {"addition", "4+19", []int{exprNumber, exprOpPlus, exprNumber, exprEOF}}, - {"subtraction", "4-19", []int{exprNumber, exprOpMinus, exprNumber, exprEOF}}, - - {"parens", "( () + () )", []int{exprParenLeft, exprParenLeft, exprParenRight, exprOpPlus, exprParenLeft, exprParenRight, exprParenRight, exprEOF}}, - {"equals", "true ==", []int{exprBool, exprOpEq, exprEOF}}, - {"numerical comparisons", "3.4 <", []int{exprNumber, exprOpLt, exprEOF}}, -} - -func TestExpressionTokens(t *testing.T) { - as := assert.New(t) - for _, test := range expressionTests { - lexer := NewSliceLexer([]byte(test.input), EXPRESSION) - items := readerToArray(lexer) - types := itemsToTypes(items) - - for _, i := range items { - if i.typ == exprError { - fmt.Println(string(i.val)) - } - } - - as.EqualValues(types, test.tokenTypes, "Testing of %s: \nactual\n\t%+v\nexpected\n\t%v", test.name, typesDescription(types, exprTokenNames), typesDescription(test.tokenTypes, exprTokenNames)) - } -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/868863aa/cli/vendor/github.com/NodePrime/jsonpath/expression_test.go ---------------------------------------------------------------------- diff --git a/cli/vendor/github.com/NodePrime/jsonpath/expression_test.go b/cli/vendor/github.com/NodePrime/jsonpath/expression_test.go deleted file mode 100644 index fca4903..0000000 --- a/cli/vendor/github.com/NodePrime/jsonpath/expression_test.go +++ /dev/null @@ -1,226 +0,0 @@ -package jsonpath - -import ( - "strings" - "testing" - - "github.com/stretchr/testify/assert" -) - -var exprTests = []struct { - input string - fields map[string]Item - expectedValue interface{} -}{ - // && - {"true && true", nil, true}, - {"false && true", nil, false}, - {"false && false", nil, false}, - - // || - {"true || true", nil, true}, - {"true || false", nil, true}, - {"false || false", nil, false}, - - // LT - {"10 < 20", nil, true}, - {"10 < 10", nil, false}, - {"100 < 20", nil, false}, - {"@a < 50", map[string]Item{"@a": genValue(`49`, jsonNumber)}, true}, - {"@a < 50", map[string]Item{"@a": genValue(`50`, jsonNumber)}, false}, - {"@a < 50", map[string]Item{"@a": genValue(`51`, jsonNumber)}, false}, - - // LE - {"10 <= 20", nil, true}, - {"10 <= 10", nil, true}, - {"100 <= 20", nil, false}, - {"@a <= 54", map[string]Item{"@a": genValue(`53`, jsonNumber)}, true}, - {"@a <= 54", map[string]Item{"@a": genValue(`54`, jsonNumber)}, true}, - {"@a <= 54", map[string]Item{"@a": genValue(`55`, jsonNumber)}, false}, - - // GT - {"30 > 20", nil, true}, - {"20 > 20", nil, false}, - {"10 > 20", nil, false}, - {"@a > 50", map[string]Item{"@a": genValue(`49`, jsonNumber)}, false}, - {"@a > 50", map[string]Item{"@a": genValue(`50`, jsonNumber)}, false}, - {"@a > 50", map[string]Item{"@a": genValue(`51`, jsonNumber)}, true}, - - // GE - {"30 >= 20", nil, true}, - {"20 >= 20", nil, true}, - {"10 >= 20", nil, false}, - {"@a >= 50", map[string]Item{"@a": genValue(`49`, jsonNumber)}, false}, - {"@a >= 50", map[string]Item{"@a": genValue(`50`, jsonNumber)}, true}, - {"@a >= 50", map[string]Item{"@a": genValue(`51`, jsonNumber)}, true}, - - // EQ - {"20 == 20", nil, true}, - {"20 == 21", nil, false}, - {"true == true", nil, true}, - {"true == false", nil, false}, - {"@a == @b", map[string]Item{"@a": genValue(`"one"`, jsonString), "@b": genValue(`"one"`, jsonString)}, true}, - {"@a == @b", map[string]Item{"@a": genValue(`"one"`, jsonString), "@b": genValue(`"two"`, jsonString)}, false}, - {`"fire" == "fire"`, nil, true}, - {`"fire" == "water"`, nil, false}, - {`@a == "toronto"`, map[string]Item{"@a": genValue(`"toronto"`, jsonString)}, true}, - {`@a == "toronto"`, map[string]Item{"@a": genValue(`"los angeles"`, jsonString)}, false}, - {`@a == 3.4`, map[string]Item{"@a": genValue(`3.4`, jsonNumber)}, true}, - {`@a == 3.4`, map[string]Item{"@a": genValue(`3.41`, jsonNumber)}, false}, - {`@a == null`, map[string]Item{"@a": genValue(`null`, jsonNull)}, true}, - - // NEQ - {"20 != 20", nil, false}, - {"20 != 21", nil, true}, - {"true != true", nil, false}, - {"true != false", nil, true}, - {"@a != @b", map[string]Item{"@a": genValue(`"one"`, jsonString), "@b": genValue(`"one"`, jsonString)}, false}, - {"@a != @b", map[string]Item{"@a": genValue(`"one"`, jsonString), "@b": genValue(`"two"`, jsonString)}, true}, - {`"fire" != "fire"`, nil, false}, - {`"fire" != "water"`, nil, true}, - {`@a != "toronto"`, map[string]Item{"@a": genValue(`"toronto"`, jsonString)}, false}, - {`@a != "toronto"`, map[string]Item{"@a": genValue(`"los angeles"`, jsonString)}, true}, - {`@a != 3.4`, map[string]Item{"@a": genValue(`3.4`, jsonNumber)}, false}, - {`@a != 3.4`, map[string]Item{"@a": genValue(`3.41`, jsonNumber)}, true}, - {`@a != null`, map[string]Item{"@a": genValue(`null`, jsonNull)}, false}, - - // Plus - {"20 + 7", nil, 27}, - {"20 + 6.999999", nil, 26.999999}, - - // Minus - {"20 - 7", nil, 13}, - {"20 - 7.11111", nil, 12.88889}, - - // Minus Unary - {"-27", nil, -27}, - {"30 - -3", nil, 33}, - {"30 + -3", nil, 27}, - - {"2 +++++ 3", nil, 5}, - {"2+--3", nil, 5}, - // Star - {"20 * 7", nil, 140}, - {"20 * 6.999999", nil, 139.99998}, - {"20 * -7", nil, -140}, - {"-20 * -7", nil, 140}, - - // Slash - {"20 / 5", nil, 4}, - {"20 / 6.999999 - 2.85714326531 <= 0.00000001", nil, true}, - - // Hat - {"7 ^ 4", nil, 2401}, - {"2 ^ -2", nil, 0.25}, - {"((7 ^ -4) - 0.00041649312) <= 0.0001", nil, true}, - - // Mod - {"7.5 % 4", nil, 3.5}, - {"2 % -2", nil, 0}, - {"11 % 22", nil, 11}, - - // Negate - {"!true", nil, false}, - {"!false", nil, true}, - - // Mix - {"20 >= 20 || 2 == 2", nil, true}, - {"20 > @.test && @.test < 13 && @.test > 1.99994", map[string]Item{"@.test": genValue(`10.23423`, jsonNumber)}, true}, - {"20 > @.test && @.test < 13 && @.test > 1.99994", map[string]Item{"@.test": genValue(`15.3423`, jsonNumber)}, false}, -} - -func genValue(val string, typ int) Item { - return Item{ - val: []byte(val), - typ: typ, - } -} - -func TestExpressions(t *testing.T) { - as := assert.New(t) - emptyFields := map[string]Item{} - - for _, test := range exprTests { - if test.fields == nil { - test.fields = emptyFields - } - - lexer := NewSliceLexer([]byte(test.input), EXPRESSION) - items := readerToArray(lexer) - // trim EOF - items = items[0 : len(items)-1] - items_post, err := infixToPostFix(items) - if as.NoError(err, "Could not transform to postfix\nTest: %q", test.input) { - val, err := evaluatePostFix(items_post, test.fields) - if as.NoError(err, "Could not evaluate postfix\nTest Input: %q\nTest Values:%q\nError:%q", test.input, test.fields, err) { - as.EqualValues(test.expectedValue, val, "\nTest: %q\nActual: %v \nExpected %v\n", test.input, val, test.expectedValue) - } - } - } -} - -var exprErrorTests = []struct { - input string - fields map[string]Item - expectedErrorSubstring string -}{ - {"@a == @b", map[string]Item{"@a": genValue(`"one"`, jsonString), "@b": genValue("3.4", jsonNumber)}, "cannot be compared"}, - {")(", nil, "Mismatched parentheses"}, - {")123", nil, "Mismatched parentheses"}, - {"20 == null", nil, "cannot be compared"}, - {`"toronto" == null`, nil, "cannot be compared"}, - {`false == 20`, nil, "cannot be compared"}, - {`"nick" == 20`, nil, "cannot be compared"}, - {"20 != null", nil, "cannot be compared"}, - {`"toronto" != null`, nil, "cannot be compared"}, - {`false != 20`, nil, "cannot be compared"}, - {`"nick" != 20`, nil, "cannot be compared"}, - {``, nil, "Bad Expression"}, - {`==`, nil, "Bad Expression"}, - {`!=`, nil, "Not enough operands"}, - - {`!23`, nil, "cannot be compared"}, - {`"nick" || true`, nil, "cannot be compared"}, - {`"nick" >= 3.2`, nil, "cannot be compared"}, - {`"nick" >3.2`, nil, "cannot be compared"}, - {`"nick" <= 3.2`, nil, "cannot be compared"}, - {`"nick" < 3.2`, nil, "cannot be compared"}, - {`"nick" + 3.2`, nil, "cannot be compared"}, - {`"nick" - 3.2`, nil, "cannot be compared"}, - {`"nick" / 3.2`, nil, "cannot be compared"}, - {`"nick" * 3.2`, nil, "cannot be compared"}, - {`"nick" % 3.2`, nil, "cannot be compared"}, - {`"nick"+`, nil, "cannot be compared"}, - {`"nick"-`, nil, "cannot be compared"}, - {`"nick"^3.2`, nil, "cannot be compared"}, - - {`@a == null`, map[string]Item{"@a": genValue(`3.41`, jsonNumber)}, "cannot be compared"}, -} - -func TestBadExpressions(t *testing.T) { - as := assert.New(t) - emptyFields := map[string]Item{} - - for _, test := range exprErrorTests { - if test.fields == nil { - test.fields = emptyFields - } - - lexer := NewSliceLexer([]byte(test.input), EXPRESSION) - items := readerToArray(lexer) - // trim EOF - items = items[0 : len(items)-1] - items_post, err := infixToPostFix(items) - if err != nil { - as.True(strings.Contains(err.Error(), test.expectedErrorSubstring), "Test Input: %q\nError %q does not contain %q", test.input, err.Error(), test.expectedErrorSubstring) - continue - } - if as.NoError(err, "Could not transform to postfix\nTest: %q", test.input) { - _, err := evaluatePostFix(items_post, test.fields) - if as.Error(err, "Could not evaluate postfix\nTest Input: %q\nTest Values:%q\nError:%s", test.input, test.fields, err) { - as.True(strings.Contains(err.Error(), test.expectedErrorSubstring), "Test Input: %q\nError %s does not contain %q", test.input, err.Error(), test.expectedErrorSubstring) - } - - } - } -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/868863aa/cli/vendor/github.com/NodePrime/jsonpath/json_states_test.go ---------------------------------------------------------------------- diff --git a/cli/vendor/github.com/NodePrime/jsonpath/json_states_test.go b/cli/vendor/github.com/NodePrime/jsonpath/json_states_test.go deleted file mode 100644 index 4ba22c1..0000000 --- a/cli/vendor/github.com/NodePrime/jsonpath/json_states_test.go +++ /dev/null @@ -1,172 +0,0 @@ -package jsonpath - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -var jsonTests = []lexTest{ - {"empty object", `{}`, []int{jsonBraceLeft, jsonBraceRight, jsonEOF}}, - {"empty array", `[]`, []int{jsonBracketLeft, jsonBracketRight, jsonEOF}}, - {"key string", `{"key" :"value"}`, []int{jsonBraceLeft, jsonKey, jsonColon, jsonString, jsonBraceRight, jsonEOF}}, - {"multiple pairs", `{"key" :"value","key2" :"value"}`, []int{jsonBraceLeft, jsonKey, jsonColon, jsonString, jsonComma, jsonKey, jsonColon, jsonString, jsonBraceRight, jsonEOF}}, - {"key number", `{"key" : 12.34e+56}`, []int{jsonBraceLeft, jsonKey, jsonColon, jsonNumber, jsonBraceRight, jsonEOF}}, - {"key true", `{"key" :true}`, []int{jsonBraceLeft, jsonKey, jsonColon, jsonBool, jsonBraceRight, jsonEOF}}, - {"key false", `{"key" :false}`, []int{jsonBraceLeft, jsonKey, jsonColon, jsonBool, jsonBraceRight, jsonEOF}}, - {"key null", `{"key" :null}`, []int{jsonBraceLeft, jsonKey, jsonColon, jsonNull, jsonBraceRight, jsonEOF}}, - {"key arrayOf number", `{"key" :[23]}`, []int{jsonBraceLeft, jsonKey, jsonColon, jsonBracketLeft, jsonNumber, jsonBracketRight, jsonBraceRight, jsonEOF}}, - {"key array", `{"key" :[23,"45",67]}`, []int{jsonBraceLeft, jsonKey, jsonColon, jsonBracketLeft, jsonNumber, jsonComma, jsonString, jsonComma, jsonNumber, jsonBracketRight, jsonBraceRight, jsonEOF}}, - {"key array", `{"key" :["45",{}]}`, []int{jsonBraceLeft, jsonKey, jsonColon, jsonBracketLeft, jsonString, jsonComma, jsonBraceLeft, jsonBraceRight, jsonBracketRight, jsonBraceRight, jsonEOF}}, - {"key nestedObject", `{"key" :{"innerkey":"value"}}`, []int{jsonBraceLeft, jsonKey, jsonColon, jsonBraceLeft, jsonKey, jsonColon, jsonString, jsonBraceRight, jsonBraceRight, jsonEOF}}, - {"key nestedArray", `[1,["a","b"]]`, []int{jsonBracketLeft, jsonNumber, jsonComma, jsonBracketLeft, jsonString, jsonComma, jsonString, jsonBracketRight, jsonBracketRight, jsonEOF}}, -} - -func TestValidJson(t *testing.T) { - as := assert.New(t) - - for _, test := range jsonTests { - lexer := NewSliceLexer([]byte(test.input), JSON) - types := itemsToTypes(readerToArray(lexer)) - - as.EqualValues(types, test.tokenTypes, "Testing of %q: \nactual\n\t%+v\nexpected\n\t%v", test.name, typesDescription(types, jsonTokenNames), typesDescription(test.tokenTypes, jsonTokenNames)) - } -} - -var errorJsonTests = []lexTest{ - {"Missing end brace", `{`, []int{jsonBraceLeft, jsonError}}, - {"Missing start brace", `}`, []int{jsonError}}, - {"Missing key start quote", `{key":true}`, []int{jsonBraceLeft, jsonError}}, - {"Missing key end quote", `{"key:true}`, []int{jsonBraceLeft, jsonError}}, - {"Missing colon", `{"key"true}`, []int{jsonBraceLeft, jsonKey, jsonError}}, - {"Missing value", `{"key":}`, []int{jsonBraceLeft, jsonKey, jsonColon, jsonError}}, - {"Missing string start quote", `{"key":test"}`, []int{jsonBraceLeft, jsonKey, jsonColon, jsonError}}, - {"Missing embedded array bracket", `{"key":[}`, []int{jsonBraceLeft, jsonKey, jsonColon, jsonBracketLeft, jsonError}}, - {"Missing values in array", `{"key":[,]`, []int{jsonBraceLeft, jsonKey, jsonColon, jsonBracketLeft, jsonError}}, - {"Missing value after comma", `{"key":[343,]}`, []int{jsonBraceLeft, jsonKey, jsonColon, jsonBracketLeft, jsonNumber, jsonComma, jsonError}}, - {"Missing comma in array", `{"key":[234 424]}`, []int{jsonBraceLeft, jsonKey, jsonColon, jsonBracketLeft, jsonNumber, jsonError}}, -} - -func TestMalformedJson(t *testing.T) { - as := assert.New(t) - - for _, test := range errorJsonTests { - lexer := NewSliceLexer([]byte(test.input), JSON) - types := itemsToTypes(readerToArray(lexer)) - - as.EqualValues(types, test.tokenTypes, "Testing of %q: \nactual\n\t%+v\nexpected\n\t%v", test.name, typesDescription(types, jsonTokenNames), typesDescription(test.tokenTypes, jsonTokenNames)) - } -} - -func itemsToTypes(items []Item) []int { - types := make([]int, len(items)) - for i, item := range items { - types[i] = item.typ - } - return types -} - -// func TestEarlyTerminationForJSON(t *testing.T) { -// as := assert.New(t) -// wg := sync.WaitGroup{} - -// lexer := NewSliceLexer(`{"key":"value", "key2":{"ikey":3}, "key3":[1,2,3,4]}`) -// wg.Add(1) -// go func() { -// lexer.Run(JSON) -// wg.Done() -// }() - -// // Pop a few items -// <-lexer.items -// <-lexer.items -// // Kill command -// close(lexer.kill) - -// wg.Wait() -// remainingItems := readerToArray(lexer.items) -// // TODO: Occasionally fails - rethink this -// _ = as -// _ = remainingItems -// // as.True(len(remainingItems) <= bufferSize, "Count of remaining items should be less than buffer size: %d", len(remainingItems)) -// } - -var examples = []string{ - `{"items":[ - { - "name": "example document for wicked fast parsing of huge json docs", - "integer": 123, - "totally sweet scientific notation": -123.123e-2, - "unicode? you betcha!": "úâ¢Â£Â¢â§\u2665", - "zero character": "0", - "null is boring": null - }, - { - "name": "another object", - "cooler than first object?": true, - "nested object": { - "nested object?": true, - "is nested array the same combination i have on my luggage?": true, - "nested array": [1,2,3,4,5] - }, - "false": false - } -]}`, - `{ - "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Product set", - "type": "array", - "items": { - "title": "Product", - "type": "object", - "properties": { - "id": { - "description": "The unique identifier for a product", - "type": "number" - }, - "name": { - "type": "string" - }, - "price": { - "type": "number", - "minimum": 0, - "exclusiveMinimum": true - }, - "tags": { - "type": "array", - "items": { - "type": "string" - }, - "minItems": 1, - "uniqueItems": true - }, - "dimensions": { - "type": "object", - "properties": { - "length": {"type": "number"}, - "width": {"type": "number"}, - "height": {"type": "number"} - }, - "required": ["length", "width", "height"] - }, - "warehouseLocation": { - "description": "Coordinates of the warehouse with the product", - "$ref": "http://json-schema.org/geo" - } - }, - "required": ["id", "name", "price"] - } - }`, -} - -func TestMixedCaseJson(t *testing.T) { - as := assert.New(t) - for _, json := range examples { - lexer := NewSliceLexer([]byte(json), JSON) - items := readerToArray(lexer) - - for _, i := range items { - as.False(i.typ == jsonError, "Found error while parsing: %q", i.val) - } - } -}