]> granicus.if.org Git - pgbadger/commitdiff
Add regression test from bin to JSON
authorÉtienne BERSAC <etienne.bersac@dalibo.com>
Wed, 20 Sep 2017 07:34:48 +0000 (09:34 +0200)
committerÉtienne BERSAC <etienne.bersac@dalibo.com>
Wed, 20 Sep 2017 07:34:48 +0000 (09:34 +0200)
.circleci/config.yml
t/basics.t
t/fixtures/light.postgres.bin [new file with mode: 0644]

index eefc52f3579c9b9bdb90873b4c50dc69fa37c1e0..f964e679afb8523e9bb42d76172147d1e2ffcbb8 100644 (file)
@@ -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:
index 1906db7de6dcc1c67e34a87014fb22686fd919d3..adc95f4f229d335d72bae085a2e5f5a5a8a71c48 100755 (executable)
     # 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 (file)
index 0000000..17f19ee
Binary files /dev/null and b/t/fixtures/light.postgres.bin differ