MCPcopy
hub / github.com/bitfield/script / TestJQWithArrayQueryProducesRequiredArray

Function TestJQWithArrayQueryProducesRequiredArray

script_test.go:763–774  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

761}
762
763func TestJQWithArrayQueryProducesRequiredArray(t *testing.T) {
764 t.Parallel()
765 input := `{"timestamp": 1649264191, "iss_position": {"longitude": "52.8439", "latitude": "10.8107"}, "message": "success"}`
766 want := `["10.8107","52.8439"]` + "\n"
767 got, err := script.Echo(input).JQ("[.iss_position.latitude, .iss_position.longitude]").String()
768 if err != nil {
769 t.Fatal(err)
770 }
771 if want != got {
772 t.Error(cmp.Diff(want, got))
773 }
774}
775
776func TestJQWithArrayInputAndElementQueryProducesSelectedElement(t *testing.T) {
777 t.Parallel()

Callers

nothing calls this directly

Calls 4

EchoFunction · 0.92
StringMethod · 0.80
JQMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…