this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cmd/cue: better test for import --recursive

This change just changes the `import --recursive` test to make it
more comprehensive and to illustrate current behaviour before
changing it to fix https://github.com/cue-lang/cue/issues/1443.

The test is made more specific to the functionality being tested - other
tests, (for example `import_context.txt`) already check the JSONL functionality.

The planned fix will only allow YAML if it contains a newline,
to avoid false positives due to the overly-permissive YAML
syntax, so we include tests to illustrate current behaviour
in these cases.

Change-Id: I2f9fb9127885693fcae41574c33607102a3cdee6
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/536901
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>

+58 -55
+58 -55
cmd/cue/cmd/testdata/script/import_hoiststr.txt
··· 1 - cue import -o - -f --list -l '"\(strings.ToLower(kind))": "\(name)":' --recursive ./import 2 - cmp stdout expect-stdout 3 - 4 - cue import -o - -f --list -l 'strings.ToLower(kind)' -l name --recursive ./import 1 + cue import -o - --recursive ./import/data.json 5 2 cmp stdout expect-stdout 6 3 -- expect-stdout -- 7 - import json656e63 "encoding/json" 4 + import ( 5 + json656e63 "encoding/json" 6 + yaml656e63 "encoding/yaml" 7 + ) 8 8 9 - service: { 10 - booster: [{ 11 - kind: "Service" 12 - name: "booster" 13 - }] 14 - "supplement\nfoo": [{ 15 - kind: "Service" 16 - name: """ 17 - supplement 18 - foo 19 - """ 20 - json: json656e63.Marshal(_cue_json) 21 - let _cue_json = [1, 2] 22 - }] 9 + foo: { 10 + name: "something" 11 + json1: json656e63.Marshal(_cue_json1) 12 + let _cue_json1 = [1, 2] 13 + json2: json656e63.Marshal(_cue_json2) 14 + let _cue_json2 = { 15 + key: "value" 16 + } 17 + yaml1: yaml656e63.Marshal(_cue_yaml1) 18 + let _cue_yaml1 = { 19 + a: "b" 20 + c: "d" 21 + } 22 + yaml2: yaml656e63.Marshal(_cue_yaml2) 23 + let _cue_yaml2 = [ 24 + "one", 25 + "two", 26 + ] 27 + nocodec1: "\"str\"" 28 + nocodec2: "1234" 29 + nocodec3: "null" 30 + nocodec4: "true" 31 + nocodec5: yaml656e63.Marshal(_cue_nocodec5) 32 + let _cue_nocodec5 = ["a-z"] 33 + nocodec6: yaml656e63.Marshal(_cue_nocodec6) 34 + let _cue_nocodec6 = { 35 + a: 123 36 + } 37 + nocodec7: yaml656e63.Marshal(_cue_nocodec7) 38 + let _cue_nocodec7 = ["a-z"] 39 + nocodec8: yaml656e63.Marshal(_cue_nocodec8) 40 + let _cue_nocodec8 = ["a"] 41 + nocodec9: yaml656e63.Marshal(_cue_nocodec9) 42 + let _cue_nocodec9 = { 43 + a: 1, b: 2 44 + } 23 45 } 24 - deployment: booster: [{ 25 - kind: "Deployment" 26 - name: "booster" 27 - replicas: 1 28 - }] 29 - -- import/services.cue -- 30 - service: [{ 31 - kind: "Service" 32 - name: "booster" 33 - }, { 34 - kind: "Service" 35 - name: """ 36 - supplement 37 - foo 38 - """ 39 - json: "[1, 2]" 40 - }] 41 - deployment: [{ 42 - kind: "Deployment" 43 - name: "booster" 44 - replicas: 1 45 - }] 46 - -- import/services.jsonl -- 47 - { 48 - "kind": "Service", 49 - "name": "booster" 50 - } 51 - { 52 - "kind": "Deployment", 53 - "name": "booster", 54 - "replicas": 1 55 - } 46 + -- import/data.json -- 56 47 { 57 - "kind": "Service", 58 - "name": "supplement\nfoo", 59 - "json": "[1, 2]" 48 + "foo": { 49 + "name": "something", 50 + "json1": "[1, 2]", 51 + "json2": "{\"key\": \"value\"}", 52 + "yaml1": "a: b\nc: d", 53 + "yaml2": "- one\n- two", 54 + "nocodec1": "\"str\"", 55 + "nocodec2": "1234", 56 + "nocodec3": "null", 57 + "nocodec4": "true", 58 + "nocodec5": "[a-z]+", 59 + "nocodec6": "a: 123", 60 + "nocodec7": "[a-z]+", 61 + "nocodec8": "[a]", 62 + "nocodec9": "{a: 1, b: 2}" 63 + } 60 64 } 61 - -- cue.mod --