From b2ddc9ffa9fdc880ca301817d59277343005fd5d Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 16 Sep 2016 12:56:13 +0200 Subject: bugfix: load order issue in server, include test Includes our first functional test. This one only makes sure loading the bin/nickserver actually works fine. Enough to catch this bug. --- .gitlab-ci.yml | 1 + bin/nickserver | 2 +- lib/nickserver/server.rb | 6 +++--- test/functional/bin_test.rb | 24 ++++++++++++++++++++++++ test/remote/Readme.md | 15 +++++++++++++++ 5 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 test/functional/bin_test.rb create mode 100644 test/remote/Readme.md diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 14e56a7..024fb9f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,6 +21,7 @@ before_script: - curl -s couchdb:5984 - gem install bundler --no-ri --no-rdoc - bundle install -j $(nproc) --path vendor + - bundle exec ruby /builds/leap/nickserver/bin/nickserver version test: script: diff --git a/bin/nickserver b/bin/nickserver index c56cc76..b77369c 100755 --- a/bin/nickserver +++ b/bin/nickserver @@ -1,4 +1,4 @@ -#!/usr/bin/ruby +#!/usr/bin/env ruby # # Nickserver key discovery daemon diff --git a/lib/nickserver/server.rb b/lib/nickserver/server.rb index 11e7012..2139029 100644 --- a/lib/nickserver/server.rb +++ b/lib/nickserver/server.rb @@ -1,9 +1,9 @@ -require 'nickserver/config' -require 'nickserver/reel_server' - require 'kernel_ext' require 'json' +require 'nickserver/config' +require 'nickserver/reel_server' + # # This is the main HTTP server that clients connect to in order to fetch keys # diff --git a/test/functional/bin_test.rb b/test/functional/bin_test.rb new file mode 100644 index 0000000..bc15e38 --- /dev/null +++ b/test/functional/bin_test.rb @@ -0,0 +1,24 @@ +require 'minitest/autorun' +require 'minitest/pride' +require 'minitest/hell' + +class BinTest < Minitest::Test + + def test_bin_loading + assert_command_runs("version") + assert_equal 0, $?.exitstatus + end + + protected + + def assert_command_runs(command) + out = `#{path_to_executable} #{command} 2>&1` + assert ($?.exitstatus == 0), + "failed to run 'nickserver #{command}':\n #{out}" + end + + def path_to_executable + File.expand_path(File.dirname(__FILE__) + '/../../bin/nickserver') + end + +end diff --git a/test/remote/Readme.md b/test/remote/Readme.md new file mode 100644 index 0000000..957ea12 --- /dev/null +++ b/test/remote/Readme.md @@ -0,0 +1,15 @@ +Integration tests for clients of remote services +================================================ + +The tests in this directory are integration test with remote services. However +we aims at testing the client side of the equation as that is what we control +here. + +So unexpected server behavious should *crash* the test if we are not dealing +with it properly yet and have no unit test for it. + +Server responses that we do not expect but handle in the code and test in unit +tests make the test *skip*. + +The Behaviour we would normally expect should make the test *pass* + -- cgit v1.2.3