summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohn Letey <john.letey@colorado.edu>2019-05-12 04:58:45 +0100
committerMatan Kushner <hello@matchai.me>2019-05-11 23:58:45 -0400
commitd3ce00c5163b1c6a2b3bc510f8900d51f5320d54 (patch)
tree711f90c69f03c80a1518a0244e7c747fc2a09c7e /tests
parent8b5055d5106da402f9a132f0ed21571ef98b8ac2 (diff)
Add Go version module (#44)
Diffstat (limited to 'tests')
-rw-r--r--tests/Dockerfile22
-rw-r--r--tests/go.rs134
2 files changed, 153 insertions, 3 deletions
diff --git a/tests/Dockerfile b/tests/Dockerfile
index bd1bcaa4e..80757356c 100644
--- a/tests/Dockerfile
+++ b/tests/Dockerfile
@@ -9,15 +9,31 @@ RUN curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | ba
&& nvm use default
ENV PATH /root/.nvm/versions/node/v$NODE_VERSION/bin:$PATH
# Check that Node.js was correctly installed
-RUN node --version
+RUN node --version
+
+# Install Go
+ENV GO_VERSION 1.10.0
+ENV GOENV_ROOT /root/.goenv
+ENV GO_ROOT /root/go
+# RUN git clone https://github.com/wfarr/goenv.git $GOENV_ROOT
+RUN git clone https://github.com/syndbg/goenv.git $GOENV_ROOT
+ENV PATH $GOENV_ROOT/bin:$GOENV_ROOT/shims:$PATH
+RUN eval "$(goenv init -)"
+RUN mkdir -p $GO_ROOT
+ENV GOPATH $GO_ROOT
+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
# 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
+COPY ./Cargo.lock ./Cargo.lock
+COPY ./Cargo.toml ./Cargo.toml
# Cargo.toml will fail to parse without my_benchmark
RUN mkdir benches
diff --git a/tests/go.rs b/tests/go.rs
new file mode 100644
index 000000000..369530abc
--- /dev/null
+++ b/tests/go.rs
@@ -0,0 +1,134 @@
+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_go_file() -> io::Result<()> {
+ let dir = TempDir::new()?;
+ File::create(dir.path().join("main.go"))?;
+
+ let expected = format!(
+ "via {} ",
+ Segment::new("go")
+ .set_value("🐹 v1.10")
+ .set_style(Color::Cyan.bold())
+ );
+ let actual = common::render_module("go", &dir.path());
+ assert_eq!(expected, actual);
+
+ Ok(())
+}
+
+#[test]
+#[ignore]
+fn folder_with_go_mod() -> io::Result<()> {
+ let dir = TempDir::new()?;
+ File::create(dir.path().join("go.mod"))?;
+
+ let expected = format!(
+ "via {} ",
+ Segment::new("go")
+ .set_value("🐹 v1.10")
+ .set_style(Color::Cyan.bold())
+ );
+ let actual = common::render_module("go", &dir.path());
+ assert_eq!(expected, actual);
+
+ Ok(())
+}
+
+#[test]
+#[ignore]
+fn folder_with_go_sum() -> io::Result<()> {
+ let dir = TempDir::new()?;
+ File::create(dir.path().join("go.sum"))?;
+
+ let expected = format!(
+ "via {} ",
+ Segment::new("go")
+ .set_value("🐹 v1.10")
+ .set_style(Color::Cyan.bold())
+ );
+ let actual = common::render_module("go", &dir.path());
+ assert_eq!(expected, actual);
+
+ Ok(())
+}
+
+#[test]
+#[ignore]
+fn folder_with_godeps() -> io::Result<()> {
+ let dir = TempDir::new()?;
+ let godeps = dir.path().join("Godeps");
+ fs::create_dir_all(&godeps)?;
+
+ let expected = format!(
+ "via {} ",
+ Segment::new("go")
+ .set_value("🐹 v1.10")
+ .set_style(Color::Cyan.bold())
+ );
+ let actual = common::render_module("go", &dir.path());
+ assert_eq!(expected, actual);
+
+ Ok(())
+}
+
+#[test]
+#[ignore]
+fn folder_with_glide_yaml() -> io::Result<()> {
+ let dir = TempDir::new()?;
+ File::create(dir.path().join("glide.yaml"))?;
+
+ let expected = format!(
+ "via {} ",
+ Segment::new("go")
+ .set_value("🐹 v1.10")
+ .set_style(Color::Cyan.bold())
+ );
+ let actual = common::render_module("go", &dir.path());
+ assert_eq!(expected, actual);
+
+ Ok(())
+}
+
+#[test]
+#[ignore]
+fn folder_with_gopkg_yml() -> io::Result<()> {
+ let dir = TempDir::new()?;
+ File::create(dir.path().join("Gopkg.yml"))?;
+
+ let expected = format!(
+ "via {} ",
+ Segment::new("go")
+ .set_value("🐹 v1.10")
+ .set_style(Color::Cyan.bold())
+ );
+ let actual = common::render_module("go", &dir.path());
+ assert_eq!(expected, actual);
+
+ Ok(())
+}
+
+#[test]
+#[ignore]
+fn folder_with_gopkg_lock() -> io::Result<()> {
+ let dir = TempDir::new()?;
+ File::create(dir.path().join("Gopkg.lock"))?;
+
+ let expected = format!(
+ "via {} ",
+ Segment::new("go")
+ .set_value("🐹 v1.10")
+ .set_style(Color::Cyan.bold())
+ );
+ let actual = common::render_module("go", &dir.path());
+ assert_eq!(expected, actual);
+
+ Ok(())
+}