mirror of
				https://github.com/taigrr/yq
				synced 2025-01-18 04:53:17 -08:00 
			
		
		
		
	add test for key order
This commit is contained in:
		
							parent
							
								
									bb9cb0c60e
								
							
						
					
					
						commit
						996ee0b433
					
				| @ -1441,3 +1441,23 @@ func TestReadFindValueDeepObjectCmd(t *testing.T) { | |||||||
| ` | ` | ||||||
| 	test.AssertResult(t, expectedOutput, result.Output) | 	test.AssertResult(t, expectedOutput, result.Output) | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | func TestReadKeepsKeyOrderInJson(t *testing.T) { | ||||||
|  | 	const content = `{ | ||||||
|  | 	"z": "One", | ||||||
|  | 	"a": 1, | ||||||
|  | 	"w": ["a", "r"], | ||||||
|  | 	"u": {"d": "o", "0": 11.5}, | ||||||
|  | }` | ||||||
|  | 	filename := test.WriteTempYamlFile(content) | ||||||
|  | 	defer test.RemoveTempYamlFile(filename) | ||||||
|  | 	cmd := getRootCommand() | ||||||
|  | 	result := test.RunCmd(cmd, fmt.Sprintf("r -j %s", filename)) | ||||||
|  | 	if result.Error != nil { | ||||||
|  | 		t.Error(result.Error) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	expectedOutput := `{"z":"One","a":1,"w":["a","r"],"u":{"d":"o","0":11.5}} | ||||||
|  | ` | ||||||
|  | 	test.AssertResult(t, expectedOutput, result.Output) | ||||||
|  | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user