@@ -15,6 +15,7 @@ use log::*;
15
15
pub async fn create (
16
16
db : & DatabaseConnection ,
17
17
overarching_goal_model : Model ,
18
+ user_id : Id ,
18
19
) -> Result < Model , Error > {
19
20
debug ! (
20
21
"New Overarching Goal Model to be inserted: {:?}" ,
@@ -25,7 +26,7 @@ pub async fn create(
25
26
26
27
let overarching_goal_active_model: ActiveModel = ActiveModel {
27
28
coaching_session_id : Set ( overarching_goal_model. coaching_session_id ) ,
28
- user_id : Set ( overarching_goal_model . user_id ) ,
29
+ user_id : Set ( user_id) ,
29
30
title : Set ( overarching_goal_model. title ) ,
30
31
body : Set ( overarching_goal_model. body ) ,
31
32
created_at : Set ( now. into ( ) ) ,
@@ -135,20 +136,19 @@ pub async fn find_by(
135
136
mod tests {
136
137
use super :: * ;
137
138
use entity:: { overarching_goals:: Model , Id } ;
138
- use sea_orm:: { DatabaseBackend , MockDatabase , Transoverarching_goal } ;
139
+ use sea_orm:: { DatabaseBackend , MockDatabase , Transaction } ;
139
140
140
141
#[ tokio:: test]
141
142
async fn create_returns_a_new_overarching_goal_model ( ) -> Result < ( ) , Error > {
142
143
let now = chrono:: Utc :: now ( ) ;
143
144
144
145
let overarching_goal_model = Model {
145
146
id : Id :: new_v4 ( ) ,
146
- coaching_session_id : Id :: new_v4 ( ) ,
147
- body : Some ( "This is a overarching_goal" . to_owned ( ) ) ,
148
- due_by : Some ( now. into ( ) ) ,
149
147
user_id : Id :: new_v4 ( ) ,
150
- status_changed_at : None ,
151
- status : Default :: default ( ) ,
148
+ coaching_session_id : Some ( Id :: new_v4 ( ) ) ,
149
+ title : Some ( "title" . to_owned ( ) ) ,
150
+ body : Some ( "This is a overarching_goal" . to_owned ( ) ) ,
151
+ completed_at : Some ( now. into ( ) ) ,
152
152
created_at : now. into ( ) ,
153
153
updated_at : now. into ( ) ,
154
154
} ;
@@ -157,7 +157,8 @@ mod tests {
157
157
. append_query_results ( vec ! [ vec![ overarching_goal_model. clone( ) ] ] )
158
158
. into_connection ( ) ;
159
159
160
- let overarching_goal = create ( & db, overarching_goal_model. clone ( ) . into ( ) ) . await ?;
160
+ let overarching_goal =
161
+ create ( & db, overarching_goal_model. clone ( ) . into ( ) , Id :: new_v4 ( ) ) . await ?;
161
162
162
163
assert_eq ! ( overarching_goal. id, overarching_goal_model. id) ;
163
164
@@ -170,12 +171,11 @@ mod tests {
170
171
171
172
let overarching_goal_model = Model {
172
173
id : Id :: new_v4 ( ) ,
173
- coaching_session_id : Id :: new_v4 ( ) ,
174
- due_by : Some ( now . into ( ) ) ,
174
+ coaching_session_id : Some ( Id :: new_v4 ( ) ) ,
175
+ title : Some ( "title" . to_owned ( ) ) ,
175
176
body : Some ( "This is a overarching_goal" . to_owned ( ) ) ,
176
177
user_id : Id :: new_v4 ( ) ,
177
- status_changed_at : None ,
178
- status : Default :: default ( ) ,
178
+ completed_at : Some ( now. into ( ) ) ,
179
179
created_at : now. into ( ) ,
180
180
updated_at : now. into ( ) ,
181
181
} ;
@@ -215,9 +215,9 @@ mod tests {
215
215
216
216
assert_eq ! (
217
217
db. into_transaction_log( ) ,
218
- [ Transoverarching_goal :: from_sql_and_values(
218
+ [ Transaction :: from_sql_and_values(
219
219
DatabaseBackend :: Postgres ,
220
- r#"SELECT "overarching_goals"."id", "overarching_goals"."coaching_session_id", "overarching_goals"."user_id", "overarching_goals"."body", "overarching_goals"."title ", "overarching_goals"."created_at", "overarching_goals"."updated_at" FROM "refactor_platform"."overarching_goals" WHERE "overarching_goals"."coaching_session_id" = $1"# ,
220
+ r#"SELECT "overarching_goals"."id", "overarching_goals"."coaching_session_id", "overarching_goals"."user_id", "overarching_goals"."title", "overarching_goals"." body", "overarching_goals"."completed_at ", "overarching_goals"."created_at", "overarching_goals"."updated_at" FROM "refactor_platform"."overarching_goals" WHERE "overarching_goals"."coaching_session_id" = $1"# ,
221
221
[ coaching_session_id. into( ) ]
222
222
) ]
223
223
) ;
0 commit comments