Created
May 14, 2018 02:44
-
-
Save ghaskins/11857fef7dfc8e56dc90d422d11ceb9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns protoc-gen-clojure.core-test | |
(:require [clojure.test :refer :all] | |
[clojure.java.io :as io] | |
[clojure.pprint :refer :all] | |
[clojure.tools.namespace :as namespace] | |
[me.raynes.fs :as fs] | |
[protoc-gen-clojure.main :as main] | |
[protoc-gen-clojure.core :refer :all]) | |
(:import [java.io ByteArrayOutputStream])) | |
(deftest io-test | |
(testing "Drive a sample request through plugin IO" | |
(let [in (io/input-stream (io/resource "testdata/sample.request")) | |
out (ByteArrayOutputStream.)] | |
(main/execute in out)))) | |
(do | |
(let [{:keys [file]} (-> (io/resource "testdata/sample.request") | |
io/input-stream | |
main/decode-request | |
generate) | |
dir (io/file "target/test")] | |
;; Ensure we start fresh | |
(fs/delete-dir dir) | |
;; Write the file(s) to our temp-dir | |
(doseq [{:keys [name content]} file] | |
(let [h (io/file dir name) | |
parent (.getParent h)] | |
(fs/mkdirs parent) | |
(spit h content))) | |
(require '[com.example.tutorial.sample :as sample] :reload-all))) | |
(deftest compile-test | |
(testing "Generate and then compile our sample" | |
(pprint (sample/map->Person {:name "Test User" :id 42 :email "tester@acme.com"})))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment