11pub mod configuration;
22
3- // mod client;
3+ mod client;
4+ // mod types;
45
56use std:: process:: Command ;
67
78use configuration:: MatterMost ;
89
910pub fn mattermost ( configuration : & MatterMost , state : bool ) {
1011 if configuration. enable {
11- // let code = std::include_str!("../../backend/python/mattermost.py");
12- let _cmd = Command :: new ( "./ve/bin/python" )
12+ let code = std:: include_str!( "../../../backend/python/mattermost.py" ) ;
13+ let output = Command :: new ( "python3" )
14+ // let output = Command::new("./ve/bin/python3")
1315 . args ( [
14- "./backend/python/mattermost.py " ,
16+ // "python/mattermost.py",
17+ "-c" ,
18+ code,
1519 configuration. url . as_str ( ) ,
1620 configuration. loginid . as_str ( ) ,
1721 configuration. apitoken . as_str ( ) ,
@@ -21,14 +25,20 @@ pub fn mattermost(configuration: &MatterMost, state: bool) {
2125 ] )
2226 . output ( )
2327 . expect ( "Error: Failed to set MatterMost message" ) ;
28+
29+ println ! ( "output start" ) ;
30+ use std:: io:: { self , Write } ;
31+ io:: stdout ( ) . write_all ( & output. stdout ) . unwrap ( ) ;
32+ io:: stderr ( ) . write_all ( & output. stderr ) . unwrap ( ) ;
33+ println ! ( "output end" ) ;
2434 }
2535}
2636
2737#[ cfg( test) ]
2838mod tests {
2939 use wiremock:: {
3040 http:: Method ,
31- matchers:: { any , method} ,
41+ matchers:: { body_json , header , method, path } ,
3242 { Mock , MockServer , ResponseTemplate } ,
3343 } ;
3444
@@ -40,7 +50,7 @@ mod tests {
4050 async fn mattermost_disabled ( ) {
4151 let mock_server = MockServer :: start ( ) . await ;
4252
43- Mock :: given ( method ( Method :: PUT ) )
53+ Mock :: given ( method ( Method :: GET ) )
4454 . respond_with ( ResponseTemplate :: new ( 200 ) )
4555 . expect ( 0 )
4656 . mount ( & mock_server)
@@ -53,25 +63,39 @@ mod tests {
5363 mattermost ( & mm_config, true ) ;
5464 }
5565
56- #[ ignore = "TODO" ]
57- #[ tokio:: test]
58- async fn send_mattermost_message ( ) {
59- let mock_server = MockServer :: start ( ) . await ;
66+ // #[tokio::test]
67+ // async fn send_mattermost_message() {
68+ // let mock_server = MockServer::start().await;
6069
61- Mock :: given ( any ( ) )
62- . respond_with ( ResponseTemplate :: new ( 200 ) )
63- . expect ( 1 )
64- . mount ( & mock_server)
65- . await ;
70+ // let user_responce = super::types::user::UserResponce {
71+ // id: "bla".to_string(),
72+ // ..Default::default()
73+ // };
74+ // Mock::given(method(Method::GET))
75+ // .and(path("api/v4/users/me"))
76+ // .and(header("content-type", "application/json"))
77+ // .and(body_json(&user_responce))
78+ // .respond_with(ResponseTemplate::new(200))
79+ // .expect(1)
80+ // .mount(&mock_server)
81+ // .await;
6682
67- let mm_config = MatterMost {
68- enable : true ,
69- url : mock_server. uri ( ) ,
70- loginid : String :: new ( ) ,
71- apitoken : String :: new ( ) ,
72- scheme : String :: from ( "http" ) ,
73- port : mock_server. address ( ) . port ( ) ,
74- } ;
75- mattermost ( & mm_config, true ) ;
76- }
83+ // // Mock::given(method(Method::GET))
84+ // // .and(path("api/v4/teams/name/section77"))
85+ // // .and(bearer_token(""))
86+ // // .respond_with(ResponseTemplate::new(200))
87+ // // .expect(1)
88+ // // .mount(&mock_server)
89+ // // .await;
90+
91+ // let mm_config = MatterMost {
92+ // enable: true,
93+ // url: mock_server.address().ip().to_string(),
94+ // loginid: String::from("clubstatus"),
95+ // apitoken: String::from("apitoken"),
96+ // scheme: String::from("http"),
97+ // port: mock_server.address().port(),
98+ // };
99+ // mattermost(&mm_config, true);
100+ // }
77101}
0 commit comments