mirror of
				https://github.com/taigrr/yq
				synced 2025-01-18 04:53:17 -08:00 
			
		
		
		
	More scenarios
This commit is contained in:
		
							parent
							
								
									6cc6fdf322
								
							
						
					
					
						commit
						9e9e15df73
					
				| @ -106,7 +106,7 @@ b: *cat | |||||||
| ``` | ``` | ||||||
| then | then | ||||||
| ```bash | ```bash | ||||||
| yq eval '.b.[]' sample.yml | yq eval '.b[]' sample.yml | ||||||
| ``` | ``` | ||||||
| will output | will output | ||||||
| ```yaml | ```yaml | ||||||
| @ -290,7 +290,7 @@ foobar: | |||||||
| ``` | ``` | ||||||
| then | then | ||||||
| ```bash | ```bash | ||||||
| yq eval '.foobar.[]' sample.yml | yq eval '.foobar[]' sample.yml | ||||||
| ``` | ``` | ||||||
| will output | will output | ||||||
| ```yaml | ```yaml | ||||||
| @ -356,7 +356,7 @@ foobar: | |||||||
| ``` | ``` | ||||||
| then | then | ||||||
| ```bash | ```bash | ||||||
| yq eval '.foobarList.[]' sample.yml | yq eval '.foobarList[]' sample.yml | ||||||
| ``` | ``` | ||||||
| will output | will output | ||||||
| ```yaml | ```yaml | ||||||
|  | |||||||
| @ -137,7 +137,15 @@ var traversePathOperatorScenarios = []expressionScenario{ | |||||||
| 	{ | 	{ | ||||||
| 		description: "Traversing aliases with splat", | 		description: "Traversing aliases with splat", | ||||||
| 		document:    `{a: &cat {c: frog}, b: *cat}`, | 		document:    `{a: &cat {c: frog}, b: *cat}`, | ||||||
| 		expression:  `.b.[]`, | 		expression:  `.b[]`, | ||||||
|  | 		expected: []string{ | ||||||
|  | 			"D0, P[b c], (!!str)::frog\n", | ||||||
|  | 		}, | ||||||
|  | 	}, | ||||||
|  | 	{ | ||||||
|  | 		skipDoc:    true, | ||||||
|  | 		document:   `{a: &cat {c: frog}, b: *cat}`, | ||||||
|  | 		expression: `.b.[]`, | ||||||
| 		expected: []string{ | 		expected: []string{ | ||||||
| 			"D0, P[b c], (!!str)::frog\n", | 			"D0, P[b c], (!!str)::frog\n", | ||||||
| 		}, | 		}, | ||||||
| @ -209,7 +217,17 @@ var traversePathOperatorScenarios = []expressionScenario{ | |||||||
| 	{ | 	{ | ||||||
| 		description: "Splatting merge anchors", | 		description: "Splatting merge anchors", | ||||||
| 		document:    mergeDocSample, | 		document:    mergeDocSample, | ||||||
| 		expression:  `.foobar.[]`, | 		expression:  `.foobar[]`, | ||||||
|  | 		expected: []string{ | ||||||
|  | 			"D0, P[foobar c], (!!str)::foo_c\n", | ||||||
|  | 			"D0, P[foobar a], (!!str)::foo_a\n", | ||||||
|  | 			"D0, P[foobar thing], (!!str)::foobar_thing\n", | ||||||
|  | 		}, | ||||||
|  | 	}, | ||||||
|  | 	{ | ||||||
|  | 		skipDoc:    true, | ||||||
|  | 		document:   mergeDocSample, | ||||||
|  | 		expression: `.foobar.[]`, | ||||||
| 		expected: []string{ | 		expected: []string{ | ||||||
| 			"D0, P[foobar c], (!!str)::foo_c\n", | 			"D0, P[foobar c], (!!str)::foo_c\n", | ||||||
| 			"D0, P[foobar a], (!!str)::foo_a\n", | 			"D0, P[foobar a], (!!str)::foo_a\n", | ||||||
| @ -260,7 +278,18 @@ var traversePathOperatorScenarios = []expressionScenario{ | |||||||
| 	{ | 	{ | ||||||
| 		description: "Splatting merge anchor lists", | 		description: "Splatting merge anchor lists", | ||||||
| 		document:    mergeDocSample, | 		document:    mergeDocSample, | ||||||
| 		expression:  `.foobarList.[]`, | 		expression:  `.foobarList[]`, | ||||||
|  | 		expected: []string{ | ||||||
|  | 			"D0, P[foobarList b], (!!str)::bar_b\n", | ||||||
|  | 			"D0, P[foobarList a], (!!str)::foo_a\n", | ||||||
|  | 			"D0, P[foobarList thing], (!!str)::bar_thing\n", | ||||||
|  | 			"D0, P[foobarList c], (!!str)::foobarList_c\n", | ||||||
|  | 		}, | ||||||
|  | 	}, | ||||||
|  | 	{ | ||||||
|  | 		skipDoc:    true, | ||||||
|  | 		document:   mergeDocSample, | ||||||
|  | 		expression: `.foobarList.[]`, | ||||||
| 		expected: []string{ | 		expected: []string{ | ||||||
| 			"D0, P[foobarList b], (!!str)::bar_b\n", | 			"D0, P[foobarList b], (!!str)::bar_b\n", | ||||||
| 			"D0, P[foobarList a], (!!str)::foo_a\n", | 			"D0, P[foobarList a], (!!str)::foo_a\n", | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user