mirror of
				https://github.com/taigrr/yq
				synced 2025-01-18 04:53:17 -08:00 
			
		
		
		
	added lib_test.go
This commit is contained in:
		
							parent
							
								
									9ae03e0a1c
								
							
						
					
					
						commit
						e6336bcb85
					
				
							
								
								
									
										39
									
								
								pkg/yqlib/lib_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								pkg/yqlib/lib_test.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,39 @@ | ||||
| package yqlib | ||||
| 
 | ||||
| import ( | ||||
| 	"testing" | ||||
| 
 | ||||
| 	"github.com/mikefarah/yq/v4/test" | ||||
| ) | ||||
| 
 | ||||
| var evaluateNodesScenario = []expressionScenario{ | ||||
| 	{ | ||||
| 		document:   `a: hello`, | ||||
| 		expression: `.a`, | ||||
| 		expected: []string{ | ||||
| 			"D0, P[a], (!!str)::hello\n", | ||||
| 		}, | ||||
| 	}, | ||||
| 	{ | ||||
| 		document:   `a: hello`, | ||||
| 		expression: `.`, | ||||
| 		expected: []string{ | ||||
| 			"D0, P[], (doc)::a: hello\n", | ||||
| 		}, | ||||
| 	}, | ||||
| 	{ | ||||
| 		document:   `- a: "yes"`, | ||||
| 		expression: `.[] | has("a")`, | ||||
| 		expected: []string{ | ||||
| 			"D0, P[0], (!!bool)::true\n", | ||||
| 		}, | ||||
| 	}, | ||||
| } | ||||
| 
 | ||||
| func TestEvaluateNodesScenarios(t *testing.T) { | ||||
| 	for _, tt := range evaluateNodesScenario { | ||||
| 		node := test.ParseData(tt.document) | ||||
| 		list, _ := EvaluateNodes(tt.expression, &node) | ||||
| 		test.AssertResultComplex(t, tt.expected, resultsToString(list)) | ||||
| 	} | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user