[SCM] ci-tooling packaging branch, master, updated. e699e7a1f94729cf2bebf7521851895bb79844e3
Harald Sitter
apachelogger-guest at moszumanska.debian.org
Wed Feb 25 13:31:34 UTC 2015
Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=e699e7a
The following commit has been merged in the master branch:
commit e699e7a1f94729cf2bebf7521851895bb79844e3
Author: Harald Sitter <sitter at kde.org>
Date: Wed Feb 25 14:31:30 2015 +0100
use an instance variable for conf_path to make it easier to test
currently this is a bit meh as ideally that would be a tmpdir, but
since we never test authenticate there is nothing to be written anyway
---
lib/lp.rb | 13 +++++--------
test/test_lp.rb | 36 +++++++++++++++++++++---------------
2 files changed, 26 insertions(+), 23 deletions(-)
diff --git a/lib/lp.rb b/lib/lp.rb
index f8ab79d..03020b7 100644
--- a/lib/lp.rb
+++ b/lib/lp.rb
@@ -45,6 +45,7 @@ require 'oauth/signature/plaintext'
module Launchpad
@mutex = Mutex.new
@token = nil
+ @conf_path = ENV['HOME']
# @!visibility private
# @note NOT thread safe
@@ -59,10 +60,8 @@ module Launchpad
token_hash = {}
# FIXME: this should be moved to a method one presumes.
- conf = "#{ENV['HOME']}/.config/lp-tokens.json"
- unless File.exist?(conf)
- conf = "#{ENV['HOME']}/tooling/confined/lp-tokens.json"
- end
+ conf = "#{@conf_path}/tooling/confined/lp-tokens.json"
+ conf = "#{@conf_path}/.config/lp-tokens.json" unless File.exist?(conf)
if File.exist?(conf)
token_hash = JSON.parse(File.read(conf), symbolize_names: true)
else
@@ -91,10 +90,8 @@ module Launchpad
# body while at usage it only works with flags in the header...
token_hash = {}
- conf = "#{ENV['HOME']}/.config/lp-tokens.json"
- unless File.exist?(conf)
- conf = "#{ENV['HOME']}/tooling/confined/lp-tokens.json"
- end
+ conf = "#{@conf_path}/tooling/confined/lp-tokens.json"
+ conf = "#{@conf_path}/.config/lp-tokens.json" unless File.exist?(conf)
if File.exist?(conf)
token_hash = JSON.parse(File.read(conf), symbolize_names: true)
else
diff --git a/test/test_lp.rb b/test/test_lp.rb
index 0cbc984..8441ab1 100644
--- a/test/test_lp.rb
+++ b/test/test_lp.rb
@@ -47,29 +47,35 @@ private
end
class LaunchpadTest < Test::Unit::TestCase
+ def setup
+ Launchpad.instance_variable_set(:@conf_path, '/tmp')
+ end
+
def test_token
assert_equal(Launchpad.token, nil)
end
- # FIXME: need auth test
+ # FIXME: need auth test
end
class LaunchpadRubberTest < Test::Unit::TestCase
- def setup
- # TODO: make mock optional
- require "webmock/test_unit"
- require "rack"
- WebMock.disable_net_connect!(allow_localhost: true)
- stub_request(:any, /api.launchpad.net/).to_rack(FakeLaunchpad)
+ def setup
+ Launchpad.instance_variable_set(:@conf_path, '/tmp')
- ppa_url = "https://api.launchpad.net/devel/~kubuntu-ci/+archive/ubuntu/unstable"
- @ppa = Launchpad::Rubber::from_url(ppa_url)
- assert(@ppa)
- # Has a bunch of properties]
- assert_equal(@ppa.status, "Active")
- assert_equal(@ppa.name, "unstable")
- assert_equal(@ppa.self_link, ppa_url)
- end
+ # TODO: make mock optional
+ require 'webmock/test_unit'
+ require 'rack'
+ WebMock.disable_net_connect!(allow_localhost: true)
+ stub_request(:any, /api.launchpad.net/).to_rack(FakeLaunchpad)
+
+ ppa_url = 'https://api.launchpad.net/devel/~kubuntu-ci/+archive/ubuntu/unstable'
+ @ppa = Launchpad::Rubber.from_url(ppa_url)
+ assert(@ppa)
+ # Has a bunch of properties]
+ assert_equal(@ppa.status, 'Active')
+ assert_equal(@ppa.name, 'unstable')
+ assert_equal(@ppa.self_link, ppa_url)
+ end
# TODO: test from_json
# TODO: maybe test get and post directly?
--
ci-tooling packaging
More information about the pkg-kde-commits
mailing list