github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/pkg/control/controldisplay/result_status_test.go (about) 1 package controldisplay 2 3 import ( 4 "fmt" 5 "testing" 6 ) 7 8 type resultStatusTest struct { 9 status string 10 expected string 11 } 12 13 func testCasesResultStatus() map[string]resultStatusTest { 14 return map[string]resultStatusTest{ 15 "error": { 16 status: "error", 17 expected: fmt.Sprintf("%-6s", ControlColors.StatusColors["error"]("ERROR: ")), 18 }, 19 "ok": { 20 status: "ok", 21 expected: fmt.Sprintf("%-6s", ControlColors.StatusColors["ok"]("OK : ")), 22 }, 23 } 24 } 25 26 func TestResultStatus(t *testing.T) { 27 themeDef := ColorSchemes["plain"] 28 scheme, _ := NewControlColorScheme(themeDef) 29 ControlColors = scheme 30 for name, test := range testCasesResultStatus() { 31 output := NewResultStatusRenderer(test.status).Render() 32 if output != test.expected { 33 t.Errorf("Test: '%s'' FAILED : \nexpected:\n %v \ngot:\n %v\n", name, test.expected, output) 34 } 35 } 36 }