Skip to content

Commit

Permalink
Merge pull request #119 from guardian/improve-error-messages
Browse files Browse the repository at this point in the history
Make error messages more helpful
  • Loading branch information
Amina Adewusi authored Aug 21, 2020
2 parents eb3eda7 + b03a0a3 commit 2f429d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/com/gu/ssm/Logic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ object Logic {
}

def extractSASTags(tags: Seq[String]): Either[String, List[String]] = {
if (tags.length < 1 || tags.head.length == 0) Left("Please supply an app, stack and stage tag in any order. For example, -t grafana,PROD,deploy")
else if (tags.length >= 10) Left("Please provide fewer than 10 tags")
if (tags.length != 3) Left("Please provide app, stack and stage tags")
else if (tags.head.length == 0) Left("Please supply an app, stack and stage tag in any order. For example, -t grafana,PROD,deploy")
else Right(tags.toList)
}

Expand Down
8 changes: 6 additions & 2 deletions src/test/scala/com/gu/ssm/LogicTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ class LogicTest extends FreeSpec with Matchers with EitherValues {
extractSASTags(Seq("")).isLeft shouldEqual true
}

"returns error if more than 10 tags are provided" in {
extractSASTags(Seq("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k")).isLeft shouldEqual true
"returns error if more than 3 tags are provided" in {
extractSASTags(Seq("a", "b", "c", "d")).isLeft shouldEqual true
}

"returns error if less than 3 tags are provided" in {
extractSASTags(Seq("a", "b")).isLeft shouldEqual true
}
}

Expand Down

0 comments on commit 2f429d0

Please sign in to comment.