From: Étienne BERSAC Date: Wed, 20 Sep 2017 07:34:48 +0000 (+0200) Subject: Add regression test from bin to JSON X-Git-Tag: v10.0~34^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=286d1301900ec15661c068c5bf71f44e13cefcb5;p=pgbadger Add regression test from bin to JSON --- diff --git a/.circleci/config.yml b/.circleci/config.yml index eefc52f..f964e67 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,15 +2,21 @@ version: 2 jobs: test: - docker: [{image: "perl:5.26"}] + # Use same version as debian stretch to use packaged dependencies. + docker: [{image: "perl:5.24-threaded"}] working_directory: /tmp/pgbadger steps: - run: name: Install debian packages - command: apt update -y && apt install -y bats git openssh-client + command: > + apt update -y && + apt install -y --no-install-recommends bats git jq libjson-xs-perl openssh-client - checkout - run: name: Executing tests + environment: + # Inject APT packaged dependencies. + PERL5LIB: /usr/lib/x86_64-linux-gnu/perl5/5.24:/usr/share/perl5 command: prove --verbose doc: diff --git a/t/basics.t b/t/basics.t index 1906db7..adc95f4 100755 --- a/t/basics.t +++ b/t/basics.t @@ -15,3 +15,11 @@ # Assert out.html is not created in PWD. ! test -f out.html } + +@test "From binary to JSON" { + ./pgbadger --outdir $BATS_TMPDIR -o test-out.json \ + --format binary t/fixtures/light.postgres.bin + test -f $BATS_TMPDIR/test-out.json + SELECT=$(jq .database_info.postgres.SELECT < $BATS_TMPDIR/test-out.json) + test $SELECT -gt 0 +} diff --git a/t/fixtures/light.postgres.bin b/t/fixtures/light.postgres.bin new file mode 100644 index 0000000..17f19ee Binary files /dev/null and b/t/fixtures/light.postgres.bin differ