diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Dockerfile | 19 | ||||
-rw-r--r-- | tests/python.rs | 79 |
2 files changed, 93 insertions, 5 deletions
diff --git a/tests/Dockerfile b/tests/Dockerfile index 80757356c..8218fd312 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.34.0 +FROM rust:latest # Install Node.js ENV NODE_VERSION 12.0.0 @@ -25,7 +25,18 @@ ENV PATH $GO_ROOT/bin:$PATH RUN goenv install $GO_VERSION RUN goenv global $GO_VERSION # Check that Go was correctly installed + RUN go version +# Install Python +ENV PYTHON_VERSION 3.7.2 +ENV PYENV_ROOT /root/.pyenv +ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH +RUN curl https://pyenv.run | bash \ + && pyenv update \ + && pyenv install $PYTHON_VERSION \ + && pyenv global $PYTHON_VERSION +# Check that Python was correctly installed +RUN python --version # Create blank project RUN USER=root cargo new --bin starship @@ -40,8 +51,7 @@ RUN mkdir benches RUN touch benches/my_benchmark.rs # This is a dummy build to get dependencies cached -RUN rustup install stable -RUN rustup run stable cargo build --release +RUN cargo build --release # Delete the dummy build RUN rm -rf /starship @@ -50,5 +60,4 @@ RUN rm -rf /starship RUN mkdir starship WORKDIR /starship -# Run with rustup to use stable instead of the Rust default -CMD [ "rustup", "run", "stable", "cargo", "test", "--", "--ignored"] +CMD ["cargo", "test", "--", "--ignored"] diff --git a/tests/python.rs b/tests/python.rs new file mode 100644 index 000000000..f497e5716 --- /dev/null +++ b/tests/python.rs @@ -0,0 +1,79 @@ +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") + .set_value("🐍 v3.7.2") + .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") + .set_value("🐍 v3.7.2") + .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") + .set_value("🐍 v3.7.2") + .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") + .set_value("🐍 v3.7.2") + .set_style(Color::Yellow.bold()) + ); + let actual = common::render_module("python", &dir.path()); + assert_eq!(expected, actual); + + Ok(()) +} |