| 1 | package colorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src . bytes/" |
| 5 | "strconvscip-go gomod github.com/golang/go/src . strconv/" |
| 6 | "testingscip-go gomod github.com/golang/go/src . testing/" |
| 7 | |
| 8 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/" |
| 9 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/" |
| 10 | ) |
| 11 | |
| 12 | func Test_colorPrintscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Test_colorPrint().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 13 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 14 | |
| 15 | tests := []struct { |
| 16 | name string |
| 17 | format string |
| 18 | attribute Attributescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Attribute# |
| 19 | args []any |
| 20 | noColor bool |
| 21 | checkOutput func(*testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#, string) |
| 22 | }{ |
| 23 | { |
| 24 | name: "prints with foreground color red", |
| 25 | format: "hello", |
| 26 | attribute: FgRedscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgRed., |
| 27 | args: nil, |
| 28 | noColor: false, |
| 29 | checkOutput: func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#, output string) { |
| 30 | t.Helperscip-go gomod github.com/golang/go/src . testing/common#Helper().() |
| 31 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.NotEmptyscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/NotEmpty().(t, output) |
| 32 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Contains().(t, output, "hello") |
| 33 | }, |
| 34 | }, |
| 35 | { |
| 36 | name: "prints with foreground color green", |
| 37 | format: "world", |
| 38 | attribute: FgGreenscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgGreen., |
| 39 | args: nil, |
| 40 | noColor: false, |
| 41 | checkOutput: func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#, output string) { |
| 42 | t.Helperscip-go gomod github.com/golang/go/src . testing/common#Helper().() |
| 43 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.NotEmptyscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/NotEmpty().(t, output) |
| 44 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Contains().(t, output, "world") |
| 45 | }, |
| 46 | }, |
| 47 | { |
| 48 | name: "prints with format and args", |
| 49 | format: "value: %d", |
| 50 | attribute: FgBluescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgBlue., |
| 51 | args: []any{42}, |
| 52 | noColor: false, |
| 53 | checkOutput: func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#, output string) { |
| 54 | t.Helperscip-go gomod github.com/golang/go/src . testing/common#Helper().() |
| 55 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.NotEmptyscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/NotEmpty().(t, output) |
| 56 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Contains().(t, output, "value: 42") |
| 57 | }, |
| 58 | }, |
| 59 | { |
| 60 | name: "prints nothing when NoColor is set", |
| 61 | format: "test", |
| 62 | attribute: FgRedscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgRed., |
| 63 | args: nil, |
| 64 | noColor: true, |
| 65 | checkOutput: func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#, output string) { |
| 66 | t.Helperscip-go gomod github.com/golang/go/src . testing/common#Helper().() |
| 67 | // When NoColor is set, the color codes should not be present |
| 68 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.NotContainsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/NotContains().(t, output, "\x1b[") |
| 69 | }, |
| 70 | }, |
| 71 | { |
| 72 | name: "adds newline if not present", |
| 73 | format: "test", |
| 74 | attribute: FgRedscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgRed., |
| 75 | args: nil, |
| 76 | noColor: false, |
| 77 | checkOutput: func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#, output string) { |
| 78 | t.Helperscip-go gomod github.com/golang/go/src . testing/common#Helper().() |
| 79 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.NotEmptyscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/NotEmpty().(t, output) |
| 80 | }, |
| 81 | }, |
| 82 | } |
| 83 | |
| 84 | for _, tt := range tests { |
| 85 | t.Runscip-go gomod github.com/golang/go/src . testing/T#Run().(tt.name, func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 86 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 87 | |
| 88 | // Create a test config with custom output buffer |
| 89 | buf := &bytesscip-go gomod github.com/golang/go/src . bytes/.Bufferscip-go gomod github.com/golang/go/src . bytes/Buffer#{} |
| 90 | cfg := &Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Config#{ |
| 91 | NoColorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Config#NoColor.: tt.noColor, |
| 92 | Outputscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Config#Output.: buf, |
| 93 | Errorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Config#Error.: buf, |
| 94 | } |
| 95 | |
| 96 | // Create color with config and use Fprintln for testing |
| 97 | c := NewWithConfigscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/NewWithConfig().(cfg, tt.attribute) |
| 98 | switch { |
| 99 | case !tt.noColor && tt.args == nil: |
| 100 | _, _ = c.Fprintlnscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Color#Fprintln().(buf, tt.format) |
| 101 | case !tt.noColor: |
| 102 | _, _ = c.Fprintfscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Color#Fprintf().(buf, tt.format+"\n", tt.args...) |
| 103 | default: |
| 104 | _, _ = buf.WriteStringscip-go gomod github.com/golang/go/src . bytes/Buffer#WriteString().(tt.format + "\n") |
| 105 | } |
| 106 | |
| 107 | output := buf.Stringscip-go gomod github.com/golang/go/src . bytes/Buffer#String().() |
| 108 | |
| 109 | tt.checkOutput(t, output) |
| 110 | }) |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | func Test_colorStringscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Test_colorString().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 115 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 116 | |
| 117 | tests := []struct { |
| 118 | name string |
| 119 | format string |
| 120 | attribute Attributescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Attribute# |
| 121 | args []any |
| 122 | noColor bool |
| 123 | want string |
| 124 | }{ |
| 125 | { |
| 126 | name: "returns colored string for red", |
| 127 | format: "hello", |
| 128 | attribute: FgRedscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgRed., |
| 129 | args: nil, |
| 130 | noColor: false, |
| 131 | want: "", |
| 132 | }, |
| 133 | { |
| 134 | name: "returns colored string for green", |
| 135 | format: "world", |
| 136 | attribute: FgGreenscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgGreen., |
| 137 | args: nil, |
| 138 | noColor: false, |
| 139 | want: "", |
| 140 | }, |
| 141 | { |
| 142 | name: "returns colored string with format args", |
| 143 | format: "value: %d", |
| 144 | attribute: FgBluescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgBlue., |
| 145 | args: []any{42}, |
| 146 | noColor: false, |
| 147 | want: "", |
| 148 | }, |
| 149 | { |
| 150 | name: "returns plain string when NoColor is set", |
| 151 | format: "test", |
| 152 | attribute: FgRedscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgRed., |
| 153 | args: nil, |
| 154 | noColor: true, |
| 155 | want: "test", |
| 156 | }, |
| 157 | { |
| 158 | name: "returns plain string with args when NoColor is set", |
| 159 | format: "value: %d", |
| 160 | attribute: FgRedscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgRed., |
| 161 | args: []any{123}, |
| 162 | noColor: true, |
| 163 | want: "value: 123", |
| 164 | }, |
| 165 | } |
| 166 | |
| 167 | for _, tt := range tests { |
| 168 | t.Runscip-go gomod github.com/golang/go/src . testing/T#Run().(tt.name, func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 169 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 170 | |
| 171 | // Create color with config |
| 172 | buf := &bytesscip-go gomod github.com/golang/go/src . bytes/.Bufferscip-go gomod github.com/golang/go/src . bytes/Buffer#{} |
| 173 | cfg := &Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Config#{ |
| 174 | NoColorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Config#NoColor.: tt.noColor, |
| 175 | Outputscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Config#Output.: buf, |
| 176 | Errorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Config#Error.: buf, |
| 177 | } |
| 178 | c := NewWithConfigscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/NewWithConfig().(cfg, tt.attribute) |
| 179 | |
| 180 | var result string |
| 181 | if tt.args == nil { |
| 182 | result = c.SprintFuncscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Color#SprintFunc().()(tt.format) |
| 183 | } else { |
| 184 | result = c.SprintfFuncscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Color#SprintfFunc().()(tt.format, tt.args...) |
| 185 | } |
| 186 | |
| 187 | if tt.noColor { |
| 188 | // When NoColor is set, result should be plain |
| 189 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Equal().(t, tt.want, result) |
| 190 | } else { |
| 191 | // When color is enabled, result should contain escape codes |
| 192 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.NotEmptyscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/NotEmpty().(t, result) |
| 193 | |
| 194 | if tt.args == nil { |
| 195 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Contains().(t, result, tt.format) |
| 196 | } else { |
| 197 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Contains().(t, result, "value: 42") |
| 198 | } |
| 199 | } |
| 200 | }) |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | // Test helper functions with various color attributes. |
| 205 | func Test_colorPrint_variousAttributesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Test_colorPrint_variousAttributes().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 206 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 207 | |
| 208 | attributes := []Attributescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Attribute#{ |
| 209 | FgBlackscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgBlack., FgRedscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgRed., FgGreenscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgGreen., FgYellowscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgYellow., FgBluescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgBlue., FgMagentascip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgMagenta., FgCyanscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgCyan., FgWhitescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgWhite., |
| 210 | FgHiBlackscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgHiBlack., FgHiRedscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgHiRed., FgHiGreenscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgHiGreen., FgHiYellowscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgHiYellow., FgHiBluescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgHiBlue., FgHiMagentascip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgHiMagenta., FgHiCyanscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgHiCyan., FgHiWhitescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgHiWhite., |
| 211 | BgBlackscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/BgBlack., BgRedscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/BgRed., BgGreenscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/BgGreen., BgYellowscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/BgYellow., BgBluescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/BgBlue., BgMagentascip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/BgMagenta., BgCyanscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/BgCyan., BgWhitescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/BgWhite., |
| 212 | Boldscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Bold., Faintscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Faint., Italicscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Italic., Underlinescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Underline., BlinkSlowscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/BlinkSlow., ReverseVideoscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/ReverseVideo., Concealedscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Concealed., CrossedOutscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/CrossedOut., |
| 213 | } |
| 214 | |
| 215 | for _, attr := range attributes { |
| 216 | t.Runscip-go gomod github.com/golang/go/src . testing/T#Run().("attribute_"+strconvscip-go gomod github.com/golang/go/src . strconv/.Itoascip-go gomod github.com/golang/go/src . strconv/Itoa().(int(attr)), func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 217 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 218 | |
| 219 | buf := &bytesscip-go gomod github.com/golang/go/src . bytes/.Bufferscip-go gomod github.com/golang/go/src . bytes/Buffer#{} |
| 220 | cfg := &Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Config#{ |
| 221 | NoColorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Config#NoColor.: false, |
| 222 | Outputscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Config#Output.: buf, |
| 223 | Errorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Config#Error.: buf, |
| 224 | } |
| 225 | c := NewWithConfigscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/NewWithConfig().(cfg, attr) |
| 226 | _, _ = c.Fprintlnscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Color#Fprintln().(buf, "test") |
| 227 | |
| 228 | output := buf.Stringscip-go gomod github.com/golang/go/src . bytes/Buffer#String().() |
| 229 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.NotEmptyscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/NotEmpty().(t, output, "expected output for attribute %v", attr) |
| 230 | }) |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | func Test_colorString_variousAttributesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Test_colorString_variousAttributes().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 235 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 236 | |
| 237 | attributes := []Attributescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Attribute#{ |
| 238 | FgBlackscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgBlack., FgRedscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgRed., FgGreenscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgGreen., FgYellowscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgYellow., FgBluescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgBlue., FgMagentascip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgMagenta., FgCyanscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgCyan., FgWhitescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/FgWhite., |
| 239 | Boldscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Bold., Italicscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Italic., Underlinescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Underline., |
| 240 | } |
| 241 | |
| 242 | for _, attr := range attributes { |
| 243 | t.Runscip-go gomod github.com/golang/go/src . testing/T#Run().("attribute_"+strconvscip-go gomod github.com/golang/go/src . strconv/.Itoascip-go gomod github.com/golang/go/src . strconv/Itoa().(int(attr)), func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 244 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 245 | |
| 246 | buf := &bytesscip-go gomod github.com/golang/go/src . bytes/.Bufferscip-go gomod github.com/golang/go/src . bytes/Buffer#{} |
| 247 | cfg := &Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Config#{ |
| 248 | NoColorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Config#NoColor.: false, |
| 249 | Outputscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Config#Output.: buf, |
| 250 | Errorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Config#Error.: buf, |
| 251 | } |
| 252 | c := NewWithConfigscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/NewWithConfig().(cfg, attr) |
| 253 | result := c.SprintFuncscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/color`/Color#SprintFunc().()("test") |
| 254 | |
| 255 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.NotEmptyscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/NotEmpty().(t, result, "expected output for attribute %v", attr) |
| 256 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Contains().(t, result, "test", "result should contain the input string for attribute %v", attr) |
| 257 | }) |
| 258 | } |
| 259 | } |