Skip to content

Instantly share code, notes, and snippets.

@al3xandr3
Created April 24, 2009 07:27
Show Gist options
  • Save al3xandr3/101005 to your computer and use it in GitHub Desktop.
Save al3xandr3/101005 to your computer and use it in GitHub Desktop.
(ns coverager_test
(:use clojure.contrib.test-is)
(:use coverager)
(:use clojure.contrib.zip-filter.xml)
(:require [clojure.zip :as zip]
[clojure.xml :as xml]))
(deftest browse-page
(with-selenium abrowser
(.open abrowser "http://www.google.com/a/")
(is (.startsWith (.getTitle abrowser) "Google Apps"))))
(def abit "<?xml version='1.0' encoding='UTF-8'?>
<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>
<url>
<loc>http://www.google.com/</loc>
<lastmod>2009-04-03</lastmod>
<priority>0.5000</priority>
</url>
<url>
<loc>http://www.google.com/a</loc>
<lastmod>2009-04-03</lastmod>
<priority>0.5000</priority>
</url>
</urlset>
")
(deftest xml-process
(let [res (xml-to-zip (org.xml.sax.InputSource. (java.io.StringReader. abit)))]
(let [lis (xml-> res :url :loc text)]
(is (= (first lis) "http://www.google.com/"))
(is (= (last lis) "http://www.google.com/a")))))
(deftest on-picking-sample
(let [the-sample (pick-a-sample 10 '(0 1 2 3 4 5 6 7 8 9))]
;not completely garanteed will take only 1,
;it should, on most cases but more important is
;to picking up randomly a small subset from list
;so less than 3 items is reasonable test
(is (< (count the-sample) 3))))
(defn run-them []
(run-tests 'coverager_test))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment