mirror of
				https://github.com/taigrr/yq
				synced 2025-01-18 04:53:17 -08:00 
			
		
		
		
	Added path stack to string test
This commit is contained in:
		
							parent
							
								
									0621307391
								
							
						
					
					
						commit
						feba7b04fa
					
				| @ -2,26 +2,37 @@ package yqlib | |||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"testing" | 	"testing" | ||||||
|  | 
 | ||||||
|  | 	"github.com/mikefarah/yq/v3/test" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func TestLib(t *testing.T) { | func TestLib(t *testing.T) { | ||||||
| 
 | 
 | ||||||
| 	// PathStackToString | 	subject := NewYqLib() | ||||||
| 	// MergePathStackToString (with true) |  | ||||||
| 
 | 
 | ||||||
| 	// var log = logging.MustGetLogger("yq") | 	t.Run("PathStackToString_Empty", func(t *testing.T) { | ||||||
| 	// subject := NewYqLib(log) | 		emptyArray := make([]interface{}, 0) | ||||||
|  | 		got := subject.PathStackToString(emptyArray) | ||||||
|  | 		test.AssertResult(t, ``, got) | ||||||
|  | 	}) | ||||||
| 
 | 
 | ||||||
| 	// 	t.Run("TestReadPath", func(t *testing.T) { | 	t.Run("PathStackToString", func(t *testing.T) { | ||||||
| 	// 		var data = test.ParseData(` | 		array := make([]interface{}, 3) | ||||||
| 	// --- | 		array[0] = "a" | ||||||
| 	// b: | 		array[1] = 0 | ||||||
| 	//   2: c | 		array[2] = "b" | ||||||
| 	// `) | 		got := subject.PathStackToString(array) | ||||||
|  | 		test.AssertResult(t, `a.[0].b`, got) | ||||||
|  | 	}) | ||||||
| 
 | 
 | ||||||
| 	// 		got, _ := subject.ReadPath(data, "b.2") | 	t.Run("MergePathStackToString", func(t *testing.T) { | ||||||
| 	// 		test.AssertResult(t, `c`, got) | 		array := make([]interface{}, 3) | ||||||
| 	// 	}) | 		array[0] = "a" | ||||||
|  | 		array[1] = 0 | ||||||
|  | 		array[2] = "b" | ||||||
|  | 		got := subject.MergePathStackToString(array, true) | ||||||
|  | 		test.AssertResult(t, `a.[+].b`, got) | ||||||
|  | 	}) | ||||||
| 
 | 
 | ||||||
| 	// 	t.Run("TestReadPath_WithError", func(t *testing.T) { | 	// 	t.Run("TestReadPath_WithError", func(t *testing.T) { | ||||||
| 	// 		var data = test.ParseData(` | 	// 		var data = test.ParseData(` | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user