Skip to content

Commit 4595084

Browse files
committed
Fix tests to avoid internet connection
1 parent 79b8d64 commit 4595084

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

test/eca/features/login_test.clj

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
(ns eca.features.login-test
2-
(:require [clojure.test :refer [deftest is testing]]
3-
[eca.features.login :as login]
4-
[matcher-combinators.test :refer [match?]]))
2+
(:require
3+
[clojure.test :refer [deftest is testing]]
4+
[eca.features.login :as login]
5+
[hato.client :as http]
6+
[matcher-combinators.test :refer [match?]]))
57

68
(deftest test-login-step
79
(let [msg-log (atom [])
@@ -42,16 +44,18 @@
4244
@db*)))))
4345

4446
(testing "valid input is provided"
45-
46-
(login/login-step {:provider nil
47-
:step :login/start
48-
:chat-id 0
49-
:input "github-copilot"
50-
:db* db*
51-
:send-msg! send-msg!})
47+
(with-redefs [http/post (constantly {:body {:user_code "1234"
48+
:decide_code "5678"
49+
:verification_uri "https://mock.github.com/login/device"}})]
50+
(login/login-step {:provider nil
51+
:step :login/start
52+
:chat-id 0
53+
:input "github-copilot"
54+
:db* db*
55+
:send-msg! send-msg!}))
5256

5357
(testing "should proceed to the next step"
54-
(is (re-find #"(?m)Open your browser at `https://github.com/login/device` and authenticate using the code: `.+`\nThen type anything in the chat and send it to continue the authentication."
58+
(is (re-find #"(?m)Open your browser at `https://mock.github.com/login/device` and authenticate using the code: `.+`\nThen type anything in the chat and send it to continue the authentication."
5559
(last @msg-log)))
5660

5761
(testing "state is update to reflect in-progress login"

0 commit comments

Comments
 (0)