Browse Source

Updated color to panic on invalid color.

Steve Thielemann 3 years ago
parent
commit
cc60084ca3
2 changed files with 11 additions and 1 deletions
  1. 1 1
      door/color.go
  2. 10 0
      door/color_test.go

+ 1 - 1
door/color.go

@@ -109,7 +109,7 @@ func ColorText(color string) string {
 		case "INV":
 			result = append(result, 7)
 		default:
-			fmt.Println("ColorText Unknown:", part)
+			panic(fmt.Sprintf("ColorText Unknown: [%s] in %s", part, color))
 		}
 
 	}

+ 10 - 0
door/color_test.go

@@ -49,3 +49,13 @@ func TestColorText(t *testing.T) {
 	}
 
 }
+
+func TestColorTextFail(t *testing.T) {
+	defer func() {
+		if r := recover(); r == nil {
+			t.Error("ColorText did not panic on invalid color.")
+		}
+	}()
+
+	ColorText("BRIGHT BANANA ON FISH")
+}