(t *testing.T)
| 179 | } |
| 180 | |
| 181 | func TestReplacerSet(t *testing.T) { |
| 182 | rep := testReplacer() |
| 183 | |
| 184 | for _, tc := range []struct { |
| 185 | variable string |
| 186 | value any |
| 187 | }{ |
| 188 | { |
| 189 | variable: "test1", |
| 190 | value: "val1", |
| 191 | }, |
| 192 | { |
| 193 | variable: "asdf", |
| 194 | value: "123", |
| 195 | }, |
| 196 | { |
| 197 | variable: "numbers", |
| 198 | value: 123.456, |
| 199 | }, |
| 200 | { |
| 201 | variable: "äöü", |
| 202 | value: "öö_äü", |
| 203 | }, |
| 204 | { |
| 205 | variable: "with space", |
| 206 | value: "space value", |
| 207 | }, |
| 208 | { |
| 209 | variable: "1", |
| 210 | value: "test-123", |
| 211 | }, |
| 212 | { |
| 213 | variable: "mySuper_IP", |
| 214 | value: "1.2.3.4", |
| 215 | }, |
| 216 | { |
| 217 | variable: "testEmpty", |
| 218 | value: "", |
| 219 | }, |
| 220 | } { |
| 221 | rep.Set(tc.variable, tc.value) |
| 222 | |
| 223 | // test if key is added |
| 224 | if val, ok := rep.static[tc.variable]; ok { |
| 225 | if val != tc.value { |
| 226 | t.Errorf("Expected value '%s' for key '%s' got '%s'", tc.value, tc.variable, val) |
| 227 | } |
| 228 | } else { |
| 229 | t.Errorf("Expected existing key '%s' found nothing", tc.variable) |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | // test if all keys are still there (by length) |
| 234 | length := len(rep.static) |
| 235 | if len(rep.static) != 8 { |
| 236 | t.Errorf("Expected length '%v' got '%v'", 7, length) |
| 237 | } |
| 238 | } |
nothing calls this directly
no test coverage detected