File tree 2 files changed +32
-1
lines changed
2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ def next_free_workflow_id
72
72
id = nil
73
73
loop do
74
74
id = SecureRandom . uuid
75
- available = !redis . exists? ( "gush.workflow .#{ id } " )
75
+ available = !redis . exists? ( "gush.workflows .#{ id } " )
76
76
77
77
break if available
78
78
end
Original file line number Diff line number Diff line change 97
97
end
98
98
end
99
99
100
+ describe "#next_free_job_id" do
101
+ it "returns an id" do
102
+ expect ( client . next_free_job_id ( '123' , Prepare . to_s ) ) . to match ( /^\h {8}-\h {4}-(\h {4})-\h {4}-\h {12}$/ )
103
+ end
104
+
105
+ it "returns an id that doesn't match an existing job id" do
106
+ workflow = TestWorkflow . create
107
+ job = workflow . jobs . first
108
+
109
+ second_try_id = '1234'
110
+ allow ( SecureRandom ) . to receive ( :uuid ) . and_return ( job . id , second_try_id )
111
+
112
+ expect ( client . next_free_job_id ( workflow . id , job . class . to_s ) ) . to eq ( second_try_id )
113
+ end
114
+ end
115
+
116
+ describe "#next_free_workflow_id" do
117
+ it "returns an id" do
118
+ expect ( client . next_free_workflow_id ) . to match ( /^\h {8}-\h {4}-(\h {4})-\h {4}-\h {12}$/ )
119
+ end
120
+
121
+ it "returns an id that doesn't match an existing workflow id" do
122
+ workflow = TestWorkflow . create
123
+
124
+ second_try_id = '1234'
125
+ allow ( SecureRandom ) . to receive ( :uuid ) . and_return ( workflow . id , second_try_id )
126
+
127
+ expect ( client . next_free_workflow_id ) . to eq ( second_try_id )
128
+ end
129
+ end
130
+
100
131
describe "#persist_workflow" do
101
132
it "persists JSON dump of the Workflow and its jobs" do
102
133
job = double ( "job" , to_json : 'json' )
You can’t perform that action at this time.
0 commit comments