| 734 | } |
| 735 | |
| 736 | func TestJQWithDotQueryPrettyPrintsInput(t *testing.T) { |
| 737 | t.Parallel() |
| 738 | input := `{"timestamp": 1649264191, "iss_position": {"longitude": "52.8439", "latitude": "10.8107"}, "message": "success"}` |
| 739 | // Fields should be sorted by key, with whitespace removed |
| 740 | want := `{"iss_position":{"latitude":"10.8107","longitude":"52.8439"},"message":"success","timestamp":1649264191}` + "\n" |
| 741 | got, err := script.Echo(input).JQ(".").String() |
| 742 | if err != nil { |
| 743 | t.Fatal(err) |
| 744 | } |
| 745 | if want != got { |
| 746 | t.Error(cmp.Diff(want, got)) |
| 747 | } |
| 748 | } |
| 749 | |
| 750 | func TestJQWithFieldQueryProducesSelectedField(t *testing.T) { |
| 751 | t.Parallel() |