Skip to content

Instantly share code, notes, and snippets.

@erez-rabih
Last active April 21, 2019 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erez-rabih/0d6ac65055c4b218677fabccb7672572 to your computer and use it in GitHub Desktop.
Save erez-rabih/0d6ac65055c4b218677fabccb7672572 to your computer and use it in GitHub Desktop.
user auth test with redis mock
(deftest get-user-by-token-test
(let [user-fix (db/insert users {:id 1 :name "username"})]
(testing "authorized token"
(redis/set "authorized-token" 1)
(testing "should return its respective user from the database"
(is (= user-fix (get-user-by-token "authorized-token")))))
(testing "unauthorized token"
(testing "should return unauthorized"
(is (= :unauthorized (get-user-by-token "unauthorized-token")))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment