<commit_before>(ns dmgr.test.core
  ^{:author "<NAME>"
    :doc "Acceptance test revolving around proving a user can trigger a heroku app install from a github webhook
         using a third heroku app running  in the clould"}
  (:use  [dmgr.core])
  (:require [clj-webdriver.taxi :as scraper :refer [set-driver! to click exists? input-text submit quit]]
            [clojure.core]
            [clojure.java.io :as io]
            [clojure.string :as str]
            [conch.core]
            [expectations :refer [expect]]
            [lstoll.utils :refer [env]]
            [ring.mock.request :refer [request]]
            [tentacles.repos :refer [create-repo]]
            [tentacles.core :refer [api-call]]))

;;=========================================================================
;; TESTS SETUP
;;=========================================================================
(def test-opts {:github-repo-uri "github.com/mateoconfeugo/lhg.git"
                :heroku-repo-uri "<EMAIL>"
                :ssh-private-key "ssh-rsa A<KEY>PE1dktCxJudjst <EMAIL>"
                :access-key "test123"})



;;=========================================================================
;; UNIT TEST:  Get the correct path
;;=========================================================================
(def test-app-name "lhg")
(def expected-path  (str (System/getProperty "user.dir") "/lhg"))
(expect true (= expected-path (expand-path test-app-name)))
(def test-params (get-deployment-parameters test-app-name test-opts))
(def test-params (get-deployment-parameters test-app-name ))
(env "lhg_GITHUB_REPO")
(def test-git-deploy-cmds (git-deploy-cmds test-params))
(def test-stageing-area (prepare-staging-area (assoc test-params :app-path (expand-path test-app-name))))

;;=========================================================================
;; UNIT TEST:  Make sure the external process runs the proper shell commands
;;=========================================================================
(def git-fetch-test-cmd nil)
(def git-clone-test-cmd nil)
(:push-to-heroku test-git-deploy-cmds)
;;(deploy test-params)

;;========================================================================
;; ACCEPTANCE TEST: Ring Compojure clojure web app installed from github
;; when the web hook is triggered
;;========================================================================
(def test-webhook-uri "/deploy?app=lhg&key=test123")

(get-github-repo-uri "lhg" )
(get-heroku-repo-uri "lhg" )
(get-ssh-private-key "lhg")


;;(expect true (= (:status (app (request :post test-webhook-uri))) 200))

;;(keys (System/getenv ))<commit_msg>removed the heroku command line use and used git directly<commit_after>(ns dmgr.test.core
  ^{:author "<NAME>"
    :doc "Acceptance test revolving around proving a user can trigger a heroku app install from a github webhook
         using a third heroku app running  in the clould"}
  (:use  [dmgr.core])
  (:require [clj-webdriver.taxi :as scraper :refer [set-driver! to click exists? input-text submit quit]]
            [clojure.core]
            [clojure.java.io :as io]
            [clojure.string :as str]
            [conch.core]
            [expectations :refer [expect]]
            [lstoll.utils :refer [env]]
            [ring.mock.request :refer [request]]
            [tentacles.repos :refer [create-repo]]
            [tentacles.core :refer [api-call]]))

;;=========================================================================
;; TESTS SETUP
;;=========================================================================
(def test-opts {:github-repo-uri "github.com/mateoconfeugo/lhg.git"
                :heroku-repo-uri "<EMAIL>"
                :ssh-private-key "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDxhl4HNWTmtANOfHDjFJvZsCv2zQ53dNXpQvR5hbyIdWA6X7bhTYOhrOlAuOBp55wR4vwbRg6zQ9AhMeCAuuh4ZjO5K68gyxRtNgCEYu/TIiKq5ob2BGT1KlczqD4LpvQVnvHyH17U+aCFhO8Xl35jZ3GMr2YZc9mxh8iNqjUUUZsj0IotfQA3bzTPC3ecM+m4H4sQ0k+pUvhdB3SAvE/bM6nbRgwzPHhp5YI/oMEpIhls8TAyo3iVR6YkbHEcMvbrHUOArVoSa1uHVkoWdn0ZH/5IG7Y6msY9/QMgJmwiBvH5qKWLomtZ8vCdtn13NlSli7Ek6+PE1dktCxJudjst <EMAIL>"
                :access-key "test123"})



;;=========================================================================
;; UNIT TEST:  Get the correct path
;;=========================================================================
(def test-app-name "lhg")
(def expected-path  (str (System/getProperty "user.dir") "/lhg"))
(expect true (= expected-path (expand-path test-app-name)))
(def test-params (get-deployment-parameters test-app-name test-opts))
(def test-params (get-deployment-parameters test-app-name ))
(env "lhg_GITHUB_REPO")
(def test-git-deploy-cmds (git-deploy-cmds test-params))
(def test-stageing-area (prepare-staging-area (assoc test-params :app-path (expand-path test-app-name))))

;;=========================================================================
;; UNIT TEST:  Make sure the external process runs the proper shell commands
;;=========================================================================
(deploy test-params)

;;========================================================================
;; ACCEPTANCE TEST: Ring Compojure clojure web app installed from github
;; when the web hook is triggered
;;========================================================================
(def test-webhook-uri "/deploy?app=lhg&key=test123")

(get-github-repo-uri "lhg" )
(get-heroku-repo-uri "lhg" )
(get-ssh-private-key "lhg")


;;(expect true (= (:status (app (request :post test-webhook-uri))) 200))

;;(keys (System/getenv ))
{'fraction_non_alphanumeric': 0.3195170300955127, 'fraction_numerical': 0.013696161470535232, 'mean_word_length': 4.745341614906832, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3793209', 'n_tokens_mistral': 1819, 'n_tokens_neox': 1668, 'n_words': 365}