|
| 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 | +//! Tests for the CLI (e.g. run from files) to make sure config works as expected |
| 19 | +
|
| 20 | +use std::fs::DirEntry; |
| 21 | + |
| 22 | +use crate::config::TestConfigBuilder; |
| 23 | +use assert_cmd::Command; |
| 24 | + |
| 25 | +#[test] |
| 26 | +fn test_custom_config() { |
| 27 | + let tempdir = tempfile::tempdir().unwrap(); |
| 28 | + let db_path = tempdir.path().join("db"); |
| 29 | + std::fs::create_dir_all(&db_path).unwrap(); |
| 30 | + let mut config_builder = TestConfigBuilder::default(); |
| 31 | + config_builder.with_db_path(db_path.to_str().unwrap()); |
| 32 | + let config = config_builder.build("my_config.toml"); |
| 33 | + |
| 34 | + Command::cargo_bin("dft") |
| 35 | + .unwrap() |
| 36 | + .arg("--config") |
| 37 | + .arg(config.path) |
| 38 | + .arg("generate-tpch") |
| 39 | + .assert() |
| 40 | + .success(); |
| 41 | + |
| 42 | + let needed_dirs = [ |
| 43 | + "customers", |
| 44 | + "orders", |
| 45 | + "line_items", |
| 46 | + "nations", |
| 47 | + "parts", |
| 48 | + "part_supps", |
| 49 | + "regions", |
| 50 | + "suppliers", |
| 51 | + ]; |
| 52 | + let tables_path = db_path.join("tables").join("tpch"); |
| 53 | + std::fs::read_dir(tables_path).unwrap().for_each(|e| { |
| 54 | + let entry = e.unwrap(); |
| 55 | + assert!(needed_dirs.contains(&entry.file_name().to_str().unwrap())); |
| 56 | + let data = entry.path().join("data.parquet"); |
| 57 | + assert!(data.exists()); |
| 58 | + let metadata = data.metadata().unwrap(); |
| 59 | + assert!(metadata.len() > 1000); |
| 60 | + }) |
| 61 | +} |
0 commit comments