2019-05-14 03:53:26 +00:00
|
|
|
use ansi_term::Color;
|
|
|
|
use starship::segment::Segment;
|
|
|
|
use std::fs::File;
|
|
|
|
use std::io;
|
|
|
|
use tempfile::TempDir;
|
|
|
|
|
|
|
|
mod common;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[ignore]
|
|
|
|
fn folder_with_python_version() -> io::Result<()> {
|
|
|
|
let dir = TempDir::new()?;
|
|
|
|
File::create(dir.path().join(".python-version"))?;
|
|
|
|
|
|
|
|
let expected = format!(
|
|
|
|
"via {} ",
|
|
|
|
Segment::new("python")
|
2019-05-16 15:40:30 +00:00
|
|
|
.set_value("🐍 v3.6.8")
|
2019-05-14 03:53:26 +00:00
|
|
|
.set_style(Color::Yellow.bold())
|
|
|
|
);
|
|
|
|
let actual = common::render_module("python", &dir.path());
|
|
|
|
assert_eq!(expected, actual);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[ignore]
|
|
|
|
fn folder_with_requirements_txt() -> io::Result<()> {
|
|
|
|
let dir = TempDir::new()?;
|
|
|
|
File::create(dir.path().join("requirements.txt"))?;
|
|
|
|
|
|
|
|
let expected = format!(
|
|
|
|
"via {} ",
|
|
|
|
Segment::new("python")
|
2019-05-16 15:40:30 +00:00
|
|
|
.set_value("🐍 v3.6.8")
|
2019-05-14 03:53:26 +00:00
|
|
|
.set_style(Color::Yellow.bold())
|
|
|
|
);
|
|
|
|
let actual = common::render_module("python", &dir.path());
|
|
|
|
assert_eq!(expected, actual);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[ignore]
|
|
|
|
fn folder_with_pyproject_toml() -> io::Result<()> {
|
|
|
|
let dir = TempDir::new()?;
|
|
|
|
File::create(dir.path().join("pyproject.toml"))?;
|
|
|
|
|
|
|
|
let expected = format!(
|
|
|
|
"via {} ",
|
|
|
|
Segment::new("python")
|
2019-05-16 15:40:30 +00:00
|
|
|
.set_value("🐍 v3.6.8")
|
2019-05-14 03:53:26 +00:00
|
|
|
.set_style(Color::Yellow.bold())
|
|
|
|
);
|
|
|
|
let actual = common::render_module("python", &dir.path());
|
|
|
|
assert_eq!(expected, actual);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[ignore]
|
|
|
|
fn folder_with_py_file() -> io::Result<()> {
|
|
|
|
let dir = TempDir::new()?;
|
|
|
|
File::create(dir.path().join("main.py"))?;
|
|
|
|
|
|
|
|
let expected = format!(
|
|
|
|
"via {} ",
|
|
|
|
Segment::new("python")
|
2019-05-16 15:40:30 +00:00
|
|
|
.set_value("🐍 v3.6.8")
|
2019-05-14 03:53:26 +00:00
|
|
|
.set_style(Color::Yellow.bold())
|
|
|
|
);
|
|
|
|
let actual = common::render_module("python", &dir.path());
|
|
|
|
assert_eq!(expected, actual);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|