mirror of
https://github.com/mikefarah/yq.git
synced 2025-02-26 01:25:45 +00:00
moar tests
This commit is contained in:
parent
86b9fe3ef9
commit
18bb4eee96
@ -104,6 +104,16 @@ func TestReadCmd(t *testing.T) {
|
|||||||
assertResult(t, "2\n", result.Output)
|
assertResult(t, "2\n", result.Output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestReadBadDocumentIndexCmd(t *testing.T) {
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := runCmd(cmd, "read -df examples/sample.yaml b.c")
|
||||||
|
if result.Error == nil {
|
||||||
|
t.Error("Expected command to fail due to invalid path")
|
||||||
|
}
|
||||||
|
expectedOutput := `Document index f is not a integer or *: strconv.ParseInt: parsing "f": invalid syntax`
|
||||||
|
assertResult(t, expectedOutput, result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
func TestReadOrderCmd(t *testing.T) {
|
func TestReadOrderCmd(t *testing.T) {
|
||||||
cmd := getRootCommand()
|
cmd := getRootCommand()
|
||||||
result := runCmd(cmd, "read examples/order.yaml")
|
result := runCmd(cmd, "read examples/order.yaml")
|
||||||
|
5
yq.go
5
yq.go
@ -236,16 +236,15 @@ func readProperty(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
log.Debugf("processing %v / %v", currentIndex, docIndexInt)
|
log.Debugf("processing %v - requested index %v", currentIndex, docIndexInt)
|
||||||
if updateAll || currentIndex == docIndexInt {
|
if updateAll || currentIndex == docIndexInt {
|
||||||
log.Debugf("reading %v in %v", path, currentIndex)
|
log.Debugf("reading %v in index %v", path, currentIndex)
|
||||||
mappedDoc, errorParsing := readPath(dataBucket, path)
|
mappedDoc, errorParsing := readPath(dataBucket, path)
|
||||||
log.Debugf("%v", mappedDoc)
|
log.Debugf("%v", mappedDoc)
|
||||||
if errorParsing != nil {
|
if errorParsing != nil {
|
||||||
return errors.Wrapf(errorParsing, "Error reading path in document index %v", currentIndex)
|
return errors.Wrapf(errorParsing, "Error reading path in document index %v", currentIndex)
|
||||||
}
|
}
|
||||||
mappedDocs = append(mappedDocs, mappedDoc)
|
mappedDocs = append(mappedDocs, mappedDoc)
|
||||||
log.Debugf("%v", mappedDocs)
|
|
||||||
}
|
}
|
||||||
currentIndex = currentIndex + 1
|
currentIndex = currentIndex + 1
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user