Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker for integration tests (#37)
- Loading branch information
Matan Kushner
committed
Apr 28, 2019
1 parent
5980a0a
commit 0872d52
Showing
6 changed files
with
123 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
if ! (docker --version); then | ||
printf 'Docker is required to run the starship integration tests.\n' | ||
printf 'Please download and install Docker in order to run these tests locally.\n' | ||
exit 1 | ||
fi | ||
|
||
printf 'Building test docker image:\n' | ||
docker build -f tests/Dockerfile --tag starship-test . | ||
|
||
printf 'Running test suite:\n' | ||
docker run --rm -t -v $(pwd):/starship starship-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
FROM rust:latest | ||
|
||
# Install Node.js | ||
ENV NODE_VERSION 12.0.0 | ||
RUN curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash \ | ||
&& . $HOME/.nvm/nvm.sh \ | ||
&& nvm install $NODE_VERSION \ | ||
&& nvm alias default $NODE_VERSION \ | ||
&& nvm use default | ||
ENV PATH /root/.nvm/versions/node/v$NODE_VERSION/bin:$PATH | ||
# Check that Node.js was correctly installed | ||
RUN node --version | ||
|
||
# Create blank project | ||
RUN USER=root cargo new --bin starship | ||
WORKDIR /starship | ||
|
||
# We want dependencies cached, so copy those first | ||
COPY ./Cargo.lock ./Cargo.lock | ||
COPY ./Cargo.toml ./Cargo.toml | ||
|
||
# Cargo.toml will fail to parse without my_benchmark | ||
RUN mkdir benches | ||
RUN touch benches/my_benchmark.rs | ||
|
||
# This is a dummy build to get dependencies cached | ||
RUN cargo build --release | ||
|
||
# Delete the dummy build | ||
RUN rm -rf /starship | ||
|
||
# Create the directory for the real source files | ||
RUN mkdir starship | ||
WORKDIR /starship | ||
|
||
CMD [ "cargo", "test", "--", "--ignored"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use ansi_term::Color; | ||
use starship::segment::Segment; | ||
use std::fs::{self, File}; | ||
use std::io; | ||
use tempfile::TempDir; | ||
|
||
mod common; | ||
|
||
#[test] | ||
#[ignore] | ||
fn folder_with_package_json() -> io::Result<()> { | ||
let dir = TempDir::new()?; | ||
File::create(dir.path().join("package.json"))?; | ||
|
||
let expected = Segment::new("node") | ||
.set_value("⬢ v12.0.0") | ||
.set_style(Color::Green.bold()) | ||
.output(); | ||
let actual = common::render_segment("nodejs", &dir.path()); | ||
assert_eq!(expected, actual); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn folder_with_js_file() -> io::Result<()> { | ||
let dir = TempDir::new()?; | ||
File::create(dir.path().join("index.js"))?; | ||
|
||
let expected = Segment::new("node") | ||
.set_value("⬢ v12.0.0") | ||
.set_style(Color::Green.bold()) | ||
.output(); | ||
let actual = common::render_segment("nodejs", &dir.path()); | ||
assert_eq!(expected, actual); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn folder_with_node_modules() -> io::Result<()> { | ||
let dir = TempDir::new()?; | ||
let node_modules = dir.path().join("node_modules"); | ||
fs::create_dir_all(&node_modules)?; | ||
|
||
let expected = Segment::new("node") | ||
.set_value("⬢ v12.0.0") | ||
.set_style(Color::Green.bold()) | ||
.output(); | ||
let actual = common::render_segment("nodejs", &dir.path()); | ||
assert_eq!(expected, actual); | ||
|
||
Ok(()) | ||
} |