mirror of
				https://github.com/taigrr/yq
				synced 2025-01-18 04:53:17 -08:00 
			
		
		
		
	Explode anchors now applies to map keys too
This commit is contained in:
		
							parent
							
								
									7dabc57b65
								
							
						
					
					
						commit
						eedbb0a99f
					
				| @ -617,6 +617,23 @@ pointer: *value-pointer` | ||||
| 	test.AssertResult(t, expectedOutput, result.Output) | ||||
| } | ||||
| 
 | ||||
| func TestReadMergeAnchorsExplodeKeyCmd(t *testing.T) { | ||||
| 	content := `name: &nameField Mike | ||||
| *nameField: Great Guy` | ||||
| 	filename := test.WriteTempYamlFile(content) | ||||
| 	defer test.RemoveTempYamlFile(filename) | ||||
| 
 | ||||
| 	cmd := getRootCommand() | ||||
| 	result := test.RunCmd(cmd, fmt.Sprintf("read -X %s", filename)) | ||||
| 	if result.Error != nil { | ||||
| 		t.Error(result.Error) | ||||
| 	} | ||||
| 	expectedOutput := `name: Mike | ||||
| Mike: Great Guy | ||||
| ` | ||||
| 	test.AssertResult(t, expectedOutput, result.Output) | ||||
| } | ||||
| 
 | ||||
| func TestReadMergeAnchorsExplodeSimpleArrayCmd(t *testing.T) { | ||||
| 	content := `- things` | ||||
| 	filename := test.WriteTempYamlFile(content) | ||||
|  | ||||
| @ -202,6 +202,10 @@ func explodeNode(node *yaml.Node) error { | ||||
| 				if errorInContent != nil { | ||||
| 					return errorInContent | ||||
| 				} | ||||
| 				errorInContent = explodeNode(keyNode) | ||||
| 				if errorInContent != nil { | ||||
| 					return errorInContent | ||||
| 				} | ||||
| 			} else { | ||||
| 				if valueNode.Kind == yaml.SequenceNode { | ||||
| 					log.Debugf("an alias merge list!") | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user