File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,3 +41,44 @@ pub fn rpc_get_version() -> RpcResult<RpcVersionInfo> {
4141 cargo_version : arc_version:: SHORT_VERSION . to_string ( ) ,
4242 } )
4343}
44+
45+ #[ cfg( test) ]
46+ mod tests {
47+ use super :: * ;
48+
49+ #[ test]
50+ fn rpc_get_version_returns_ok ( ) {
51+ assert ! ( rpc_get_version( ) . is_ok( ) ) ;
52+ }
53+
54+ #[ test]
55+ fn rpc_get_version_fields_non_empty ( ) {
56+ let info = rpc_get_version ( ) . unwrap ( ) ;
57+ assert ! ( !info. git_version. is_empty( ) ) ;
58+ assert ! ( !info. git_commit. is_empty( ) ) ;
59+ assert ! ( !info. git_short_hash. is_empty( ) ) ;
60+ assert ! ( !info. cargo_version. is_empty( ) ) ;
61+ }
62+
63+ #[ test]
64+ fn rpc_get_version_short_hash_is_prefix_of_commit ( ) {
65+ let info = rpc_get_version ( ) . unwrap ( ) ;
66+ assert ! (
67+ info. git_commit. starts_with( & info. git_short_hash) ,
68+ "git_short_hash '{}' should be a prefix of git_commit '{}'" ,
69+ info. git_short_hash,
70+ info. git_commit
71+ ) ;
72+ }
73+
74+ #[ test]
75+ fn rpc_get_version_cargo_version_contains_short_hash ( ) {
76+ let info = rpc_get_version ( ) . unwrap ( ) ;
77+ assert ! (
78+ info. cargo_version. contains( & info. git_short_hash) ,
79+ "cargo_version '{}' should contain short hash '{}'" ,
80+ info. cargo_version,
81+ info. git_short_hash
82+ ) ;
83+ }
84+ }
You can’t perform that action at this time.
0 commit comments