@@ -145,4 +145,43 @@ mod tests {
145
145
146
146
commit ( repo_path, "commit msg" ) ;
147
147
}
148
+
149
+ #[ test]
150
+ fn test_stage_add_smoke ( ) {
151
+ let file_path = Path :: new ( "foo" ) ;
152
+ let ( _td, repo) = repo_init_empty ( ) ;
153
+ let root = repo. path ( ) . parent ( ) . unwrap ( ) ;
154
+ let repo_path = root. as_os_str ( ) . to_str ( ) . unwrap ( ) ;
155
+
156
+ assert_eq ! ( stage_add( repo_path, file_path) , false ) ;
157
+ }
158
+
159
+ #[ test]
160
+ fn test_staging_one_file ( ) {
161
+ let file_path = Path :: new ( "file1.txt" ) ;
162
+ let ( _td, repo) = repo_init ( ) ;
163
+ let root = repo. path ( ) . parent ( ) . unwrap ( ) ;
164
+ let repo_path = root. as_os_str ( ) . to_str ( ) . unwrap ( ) ;
165
+
166
+ let status_count = |s : StatusType | -> usize {
167
+ get_status ( repo_path, s) . len ( )
168
+ } ;
169
+
170
+ File :: create ( & root. join ( file_path) )
171
+ . unwrap ( )
172
+ . write_all ( b"test file1 content" )
173
+ . unwrap ( ) ;
174
+
175
+ File :: create ( & root. join ( Path :: new ( "file2.txt" ) ) )
176
+ . unwrap ( )
177
+ . write_all ( b"test file2 content" )
178
+ . unwrap ( ) ;
179
+
180
+ assert_eq ! ( status_count( StatusType :: WorkingDir ) , 2 ) ;
181
+
182
+ assert_eq ! ( stage_add( repo_path, file_path) , true ) ;
183
+
184
+ assert_eq ! ( status_count( StatusType :: WorkingDir ) , 1 ) ;
185
+ assert_eq ! ( status_count( StatusType :: Stage ) , 1 ) ;
186
+ }
148
187
}
0 commit comments