MCPcopy Create free account
hub / github.com/github/gh-aw / TestGatewayTruncateString

Function TestGatewayTruncateString

pkg/cli/gateway_logs_test.go:236–276  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

234}
235
236func TestGatewayTruncateString(t *testing.T) {
237 tests := []struct {
238 name string
239 input string
240 maxLen int
241 want string
242 }{
243 {
244 name: "string shorter than max",
245 input: "short",
246 maxLen: 10,
247 want: "short",
248 },
249 {
250 name: "string equal to max",
251 input: "exactlyten",
252 maxLen: 10,
253 want: "exactlyten",
254 },
255 {
256 name: "string longer than max",
257 input: "this is a very long string",
258 maxLen: 10,
259 want: "this is...",
260 },
261 {
262 name: "max length very small",
263 input: "test",
264 maxLen: 2,
265 want: "te",
266 },
267 }
268
269 for _, tt := range tests {
270 t.Run(tt.name, func(t *testing.T) {
271 result := stringutil.Truncate(tt.input, tt.maxLen)
272 assert.Equal(t, tt.want, result)
273 assert.LessOrEqual(t, len(result), tt.maxLen)
274 })
275 }
276}
277
278func TestProcessGatewayLogEntry(t *testing.T) {
279 metrics := &GatewayMetrics{

Callers

nothing calls this directly

Calls 2

TruncateFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected