|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +use std::env; |
| 19 | +use std::fs; |
| 20 | +use std::path::Path; |
| 21 | +use std::process::Command; |
| 22 | + |
| 23 | +use anyhow::Result; |
| 24 | +use assert_cmd::prelude::*; |
| 25 | + |
| 26 | +#[tokio::test] |
| 27 | +async fn test_basic_cat() -> Result<()> { |
| 28 | + let dir = env::temp_dir(); |
| 29 | + fs::create_dir_all(dir.clone())?; |
| 30 | + let dst_path_1 = Path::new(&dir).join("dst_1.txt"); |
| 31 | + let dst_path_2 = Path::new(&dir).join("dst_2.txt"); |
| 32 | + let dst_path_3 = Path::new(&dir).join("dst_3.txt"); |
| 33 | + |
| 34 | + let expect = "hello"; |
| 35 | + fs::write(dst_path_1, expect)?; |
| 36 | + fs::write(dst_path_2, expect)?; |
| 37 | + fs::write(dst_path_3, expect)?; |
| 38 | + |
| 39 | + let mut cmd = Command::cargo_bin("oli")?; |
| 40 | + |
| 41 | + let current_dir = dir.to_str().unwrap().to_string() + "/"; |
| 42 | + |
| 43 | + cmd.arg("ls").arg(current_dir); |
| 44 | + let res = cmd.assert().success(); |
| 45 | + let output = res.get_output().stdout.clone(); |
| 46 | + |
| 47 | + let output_stdout = String::from_utf8(output)?; |
| 48 | + |
| 49 | + assert!(output_stdout.contains("dst_1.txt")); |
| 50 | + assert!(output_stdout.contains("dst_2.txt")); |
| 51 | + assert!(output_stdout.contains("dst_3.txt")); |
| 52 | + |
| 53 | + Ok(()) |
| 54 | +} |
0 commit comments