Skip to content

Commit f838f65

Browse files
committed
Sample App Built
1 parent b0194ca commit f838f65

File tree

8 files changed

+101
-2
lines changed

8 files changed

+101
-2
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Patrick
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

100644100755
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
sample_clojure_postgres
2-
=======================
1+
Clojure Sample with Postgres
2+
=====================
3+
4+
Simple Clojure app using clojure.test framework and PostgreSQL.

sample/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/target
2+
/classes
3+
/checkouts
4+
pom.xml
5+
pom.xml.asc
6+
*.jar
7+
*.class
8+
/.lein-*
9+
/.nrepl-port

sample/db/repl-connection.clj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(require '[clojure.java.jdbc :as jdbc])
2+
3+
(def pgdb
4+
{ :subprotocol "postgresql"
5+
:subname "//localhost:5432/test"
6+
:user "postgres"
7+
:password "" })
8+
9+
(def create-users-table-sql
10+
"CREATE TABLE users (
11+
id bigserial primary key,
12+
username varchar(255),
13+
email varchar(255) NOT NULL
14+
);")

sample/project.clj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(defproject sample "0.1.0-SNAPSHOT"
2+
:description "Clojure Sample App with PostgreSQL"
3+
:url "http://github.com/Shippable/sample_clojure_postgres"
4+
:license {:name "Eclipse Public License"
5+
:url "http://www.eclipse.org/legal/epl-v10.html"}
6+
:dependencies [[org.clojure/clojure "1.5.1"]
7+
[org.clojure/java.jdbc "0.3.2"]
8+
[postgresql "9.1-901.jdbc4"]
9+
[org.clojure/tools.logging "0.2.3"]]
10+
:main ^:skip-aot sample.core
11+
:target-path "target/%s"
12+
:profiles {:uberjar {:aot :all}})

sample/src/sample/core.clj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(ns sample.core
2+
(:gen-class))
3+
4+
(use 'clojure.tools.logging)
5+
(load-file "db/repl-connection.clj")
6+
7+
(defn -main
8+
[username]
9+
(jdbc/execute! pgdb [create-users-table-sql])
10+
(jdbc/insert! pgdb :users {:username "lindsaybluth" :email "[email protected]"})
11+
(jdbc/insert! pgdb :users {:username "tobiasfunke" :email "[email protected]"})
12+
(apply str (jdbc/query pgdb ["select * from users where username=?" username])))

sample/test/sample/core_test.clj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(ns sample.core-test
2+
(:require [clojure.test :refer :all]
3+
[sample.core :refer :all]))
4+
5+
(use 'clojure.tools.logging)
6+
7+
(deftest a-test
8+
(testing "Simple Postges query"
9+
(is (.contains (-main "lindsaybluth") "[email protected]"))))

shippable.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Language setting
2+
language: clojure
3+
4+
lein:
5+
- lein2
6+
7+
# Addons used by app
8+
addons:
9+
postgresql: "9.3"
10+
11+
# Create directories for test and coverage reports; Create 'test' Postgres database
12+
before_script:
13+
- mkdir -p shippable/testresults
14+
- mkdir -p shippable/codecoverage
15+
- psql -c 'CREATE DATABASE test;' -U postgres
16+
17+
# Running the test with Leiningen
18+
script:
19+
- cd sample
20+
- lein test

0 commit comments

Comments
 (0)