From 7663a004ede360251bae02c7078e379fbff9f812 Mon Sep 17 00:00:00 2001 From: Colin Jones Date: Thu, 14 Mar 2013 12:23:19 -0500 Subject: [PATCH] Tidy up a few tests Mostly gets project maps in a format suitable for eval-in-project (including the repositories), but also number-ifies port for aether (the way the real URL.getPort method behaves). --- leiningen-core/test/leiningen/core/test/classpath.clj | 2 +- leiningen-core/test/leiningen/core/test/eval.clj | 8 +++++--- leiningen-core/test/leiningen/core/test/project.clj | 9 +++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/leiningen-core/test/leiningen/core/test/classpath.clj b/leiningen-core/test/leiningen/core/test/classpath.clj index 84eb5de2..c42252e2 100644 --- a/leiningen-core/test/leiningen/core/test/classpath.clj +++ b/leiningen-core/test/leiningen/core/test/classpath.clj @@ -21,7 +21,7 @@ :exclusions [commons-codec]]] :checkout-deps-shares [:source-paths :resource-paths :compile-path #(str (:root %) "/foo")] - :repositories (:repositories project/defaults) + :repositories project/default-repositories :root "/tmp/lein-sample-project" :target-path "/tmp/lein-sample-project/target" :source-paths ["/tmp/lein-sample-project/src"] diff --git a/leiningen-core/test/leiningen/core/test/eval.clj b/leiningen-core/test/leiningen/core/test/eval.clj index 203601e4..813c0606 100644 --- a/leiningen-core/test/leiningen/core/test/eval.clj +++ b/leiningen-core/test/leiningen/core/test/eval.clj @@ -3,11 +3,13 @@ [leiningen.core.eval]) (:require [clojure.java.io :as io] [clojure.set :as set] - [leiningen.core.classpath :as classpath]) + [leiningen.core.classpath :as classpath] + [leiningen.core.project :as project]) (:import (java.io File))) (def project {:dependencies '[[org.clojure/clojure "1.3.0"]] :root "/tmp/lein-sample-project" + :repositories project/default-repositories :target-path "/tmp/lein-sample-project/target" :source-paths ["/tmp/lein-sample-project/src"] :resource-paths ["/tmp/lein-sample-project/resources"] @@ -36,8 +38,8 @@ (deftest test-get-jvm-args-with-proxy-settings ;; Mock get-proxy-settings to return test values (with-redefs [classpath/get-proxy-settings - (fn ([] {:host "foo.com" :port "8080"}) - ([https] {:host "secure-foo.com", :port "443"}))] + (fn ([] {:host "foo.com" :port 8080}) + ([https] {:host "secure-foo.com", :port 443}))] (let [args (set (shell-command project 'repl))] (is (and (contains? args "-Dhttp.proxyHost=foo.com") (contains? args "-Dhttp.proxyPort=8080") diff --git a/leiningen-core/test/leiningen/core/test/project.clj b/leiningen-core/test/leiningen/core/test/project.clj index 87049ac4..6b30cfa6 100755 --- a/leiningen-core/test/leiningen/core/test/project.clj +++ b/leiningen-core/test/leiningen/core/test/project.clj @@ -5,6 +5,7 @@ (:require [leiningen.core.user :as user] [leiningen.core.classpath :as classpath] [leiningen.core.test.helper :refer [abort-msg]] + [leiningen.core.utils :as utils] [clojure.java.io :as io])) (use-fixtures :once @@ -342,10 +343,10 @@ (is (= 7 (:seven (init-project (read (.getFile (io/resource "p2.clj")))))))) (deftest test-activate-middleware - (is (= "" - (with-out-str - (binding [*err* *out*] - (init-project (read (.getFile (io/resource "p3.clj"))))))))) + (let [errors (atom [])] + (with-redefs [utils/error (fn [& args] (swap! errors conj args))] + (init-project (read (.getFile (io/resource "p3.clj"))))) + (is (= [] @errors)))) (deftest test-plugin-vars (are [project hooks middleware] (= (list hooks middleware)