Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure temporal.promise resolved/rejected are compatible with all/race #62

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/temporal/promise.clj
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ promises returned from [[temporal.activity/invoke]] from within workflow context
(defn resolved
"Returns a new, fully resolved promise"
[value]
(Workflow/newPromise value))
(pt/->PromiseAdapter (Workflow/newPromise value)))

(defn rejected
"Returns a new, rejected promise"
[^Exception e]
(Workflow/newFailedPromise e))
(pt/->PromiseAdapter (Workflow/newFailedPromise e)))
24 changes: 24 additions & 0 deletions test/temporal/test/resolved_promises.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
;; Copyright © Manetu, Inc. All rights reserved

(ns temporal.test.resolved-promises
(:require [clojure.test :refer :all]
[taoensso.timbre :as log]
[temporal.client.core :as c]
[temporal.workflow :refer [defworkflow]]
[temporal.promise :as pt]
[temporal.test.utils :as t]))

(use-fixtures :once t/wrap-service)

(defworkflow all-workflow
[args]
(log/info "workflow:" args)
@(pt/all [(pt/resolved true)])
@(pt/race [(pt/resolved true)])
:ok)

(deftest the-test
(testing "Verifies that pt/resolved and pt/rejected are compatible with all/race"
(let [workflow (t/create-workflow all-workflow)]
(c/start workflow {})
(is (-> workflow c/get-result deref (= :ok))))))