From 522b643b5c4e420d5cc029506f712a7a7df97536 Mon Sep 17 00:00:00 2001 From: Jonathan Watson Date: Mon, 17 Feb 2025 17:21:09 +0000 Subject: [PATCH] test(jq): add version and jq test --- e2e/binary/jq/BUILD.bazel | 32 ++++++++++++++++++++++++++------ e2e/binary/jq/fixture.json | 4 ++++ e2e/binary/jq/jq.py | 15 +++++++++++++++ 3 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 e2e/binary/jq/fixture.json create mode 100644 e2e/binary/jq/jq.py diff --git a/e2e/binary/jq/BUILD.bazel b/e2e/binary/jq/BUILD.bazel index ba9714d3..01a4b72d 100644 --- a/e2e/binary/jq/BUILD.bazel +++ b/e2e/binary/jq/BUILD.bazel @@ -1,11 +1,31 @@ -load("@bazel_skylib//rules:build_test.bzl", "build_test") +load("@bazel_skylib//rules:native_binary.bzl", "native_test") +load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") -# TODO: write an _actual_ test for `jq` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["jq.py"], + data = [ + ":fixture.json", + "@ape//ape:jq", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "jq", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:jq"], + src = "@ape//ape:jq", + args = ["--version"], +) + +test_suite( + name = "jq", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/jq/fixture.json b/e2e/binary/jq/fixture.json new file mode 100644 index 00000000..0458103a --- /dev/null +++ b/e2e/binary/jq/fixture.json @@ -0,0 +1,4 @@ +{ + "one": 1, + "two": 2 +} diff --git a/e2e/binary/jq/jq.py b/e2e/binary/jq/jq.py new file mode 100644 index 00000000..04488a45 --- /dev/null +++ b/e2e/binary/jq/jq.py @@ -0,0 +1,15 @@ +from __future__ import annotations + +from subprocess import run + +from binary.tool import Tool +from binary import Relative + + +def test_jq(tool: Tool, relative: Relative) -> None: + binary = tool("jq") + fixture = relative("fixture.json") + + cmd = (binary, ".one", fixture) + result = run(cmd, check=True, timeout=30, capture_output=True, text=True) + assert "1\n" == result.stdout -- GitLab