summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCédric Da Fonseca <Kwelity@users.noreply.github.com>2019-11-02 12:08:54 +0100
committerMatan Kushner <hello@matchai.me>2019-11-02 20:08:54 +0900
commitfa1267f12f60510d6214476e3d059edcb861f0c8 (patch)
tree1903487dcf0b89f475071a661c88fbc7f66c96aa /tests
parent26fa4ec1eaa611bcceab6239b005f29f06548778 (diff)
feat: Add configuration to set how much AWS profile info is shown (#556)
Diffstat (limited to 'tests')
-rw-r--r--tests/testsuite/aws.rs136
1 files changed, 129 insertions, 7 deletions
diff --git a/tests/testsuite/aws.rs b/tests/testsuite/aws.rs
index 12da23925..766d16d14 100644
--- a/tests/testsuite/aws.rs
+++ b/tests/testsuite/aws.rs
@@ -4,12 +4,11 @@ use std::io::{self, Write};
use ansi_term::Color;
use tempfile;
-use crate::common;
+use crate::common::{self, TestCommand};
#[test]
fn no_region_set() -> io::Result<()> {
let output = common::render_module("aws")
- .env_clear()
.env("PATH", env!("PATH"))
.output()?;
let expected = "";
@@ -21,7 +20,6 @@ fn no_region_set() -> io::Result<()> {
#[test]
fn region_set() -> io::Result<()> {
let output = common::render_module("aws")
- .env_clear()
.env("AWS_REGION", "ap-northeast-2")
.output()?;
let expected = format!("on {} ", Color::Yellow.bold().paint("☁️ ap-northeast-2"));
@@ -33,7 +31,6 @@ fn region_set() -> io::Result<()> {
#[test]
fn default_region_set() -> io::Result<()> {
let output = common::render_module("aws")
- .env_clear()
.env("AWS_REGION", "ap-northeast-2")
.env("AWS_DEFAULT_REGION", "ap-northeast-1")
.output()?;
@@ -46,7 +43,6 @@ fn default_region_set() -> io::Result<()> {
#[test]
fn profile_set() -> io::Result<()> {
let output = common::render_module("aws")
- .env_clear()
.env("AWS_PROFILE", "astronauts")
.output()?;
let expected = format!("on {} ", Color::Yellow.bold().paint("☁️ astronauts"));
@@ -56,6 +52,21 @@ fn profile_set() -> io::Result<()> {
}
#[test]
+fn profile_and_region_set() -> io::Result<()> {
+ let output = common::render_module("aws")
+ .env("AWS_PROFILE", "astronauts")
+ .env("AWS_REGION", "ap-northeast-2")
+ .output()?;
+ let expected = format!(
+ "on {} ",
+ Color::Yellow.bold().paint("☁️ astronauts(ap-northeast-2)")
+ );
+ let actual = String::from_utf8(output.stdout).unwrap();
+ assert_eq!(expected, actual);
+ Ok(())
+}
+
+#[test]
fn default_profile_set() -> io::Result<()> {
let dir = tempfile::tempdir()?;
let config_path = dir.path().join("config");
@@ -72,7 +83,6 @@ region = us-east-2
)?;
let output = common::render_module("aws")
- .env_clear()
.env("AWS_CONFIG_FILE", config_path.to_string_lossy().as_ref())
.output()?;
let expected = format!("on {} ", Color::Yellow.bold().paint("☁️ us-east-1"));
@@ -98,9 +108,11 @@ region = us-east-2
)?;
let output = common::render_module("aws")
- .env_clear()
.env("AWS_CONFIG_FILE", config_path.to_string_lossy().as_ref())
.env("AWS_PROFILE", "astronauts")
+ .use_config(toml::toml! {
+ [aws]
+ })
.output()?;
let expected = format!(
"on {} ",
@@ -110,3 +122,113 @@ region = us-east-2
assert_eq!(expected, actual);
Ok(())
}
+
+#[test]
+fn profile_and_region_set_with_display_all() -> io::Result<()> {
+ let output = common::render_module("aws")
+ .env("AWS_PROFILE", "astronauts")
+ .env("AWS_REGION", "ap-northeast-1")
+ .use_config(toml::toml! {
+ [aws]
+ displayed_items = "all"
+ })
+ .output()?;
+ let expected = format!(
+ "on {} ",
+ Color::Yellow.bold().paint("☁️ astronauts(ap-northeast-1)")
+ );
+ let actual = String::from_utf8(output.stdout).unwrap();
+ assert_eq!(expected, actual);
+ Ok(())
+}
+
+#[test]
+fn profile_set_with_display_all() -> io::Result<()> {
+ let output = common::render_module("aws")
+ .env("AWS_PROFILE", "astronauts")
+ .use_config(toml::toml! {
+ [aws]
+ displayed_items = "all"
+ })
+ .output()?;
+ let expected = format!("on {} ", Color::Yellow.bold().paint("☁️ astronauts"));
+ let actual = String::from_utf8(output.stdout).unwrap();
+ assert_eq!(expected, actual);
+ Ok(())
+}
+
+#[test]
+fn region_set_with_display_all() -> io::Result<()> {
+ let output = common::render_module("aws")
+ .env("AWS_REGION", "ap-northeast-1")
+ .use_config(toml::toml! {
+ [aws]
+ displayed_items = "all"
+ })
+ .output()?;
+ let expected = format!("on {} ", Color::Yellow.bold().paint("☁️ ap-northeast-1"));
+ let actual = String::from_utf8(output.stdout).unwrap();
+ assert_eq!(expected, actual);
+ Ok(())
+}
+
+#[test]
+fn profile_and_region_set_with_display_region() -> io::Result<()> {
+ let output = common::render_module("aws")
+ .env("AWS_PROFILE", "astronauts")
+ .env("AWS_DEFAULT_REGION", "ap-northeast-1")
+ .use_config(toml::toml! {
+ [aws]
+ displayed_items = "region"
+ })
+ .output()?;
+ let expected = format!("on {} ", Color::Yellow.bold().paint("☁️ ap-northeast-1"));
+ let actual = String::from_utf8(output.stdout).unwrap();
+ assert_eq!(expected, actual);
+ Ok(())
+}
+
+#[test]
+fn profile_and_region_set_with_display_profile() -> io::Result<()> {
+ let output = common::render_module("aws")
+ .env("AWS_PROFILE", "astronauts")
+ .env("AWS_REGION", "ap-northeast-1")
+ .use_config(toml::toml! {
+ [aws]
+ displayed_items = "profile"
+ })
+ .output()?;
+ let expected = format!("on {} ", Color::Yellow.bold().paint("☁️ astronauts"));
+ let actual = String::from_utf8(output.stdout).unwrap();
+ assert_eq!(expected, actual);
+ Ok(())
+}
+
+#[test]
+fn region_set_with_display_profile() -> io::Result<()> {
+ let output = common::render_module("aws")
+ .env("AWS_REGION", "ap-northeast-1")
+ .use_config(toml::toml! {
+ [aws]
+ displayed_items = "profile"
+ })
+ .output()?;
+ let expected = "";
+ let actual = String::from_utf8(output.stdout).unwrap();
+ assert_eq!(expected, actual);
+ Ok(())
+}
+
+#[test]
+fn region_not_set_with_display_region() -> io::Result<()> {
+ let output = common::render_module("aws")
+ .use_config(toml::toml! {
+ [aws]
+ displayed_items = "region"
+ })
+ .output()?;
+ let expected = "";
+ let actual = String::from_utf8(output.stdout).unwrap();
+ assert_eq!(expected, actual);
+ Ok(())
+}