Skip to content

Commit 040338e

Browse files
docs: adding standard GoDoc comments to test files
standardized comments have been added in the GoDoc style to improve test documentation and readability in the following files: - ctx_godoc_test.go - ctx_test.go - group_delete_test.go - group_get_test.go - group_godoc_test.go - group_post_test.go - group_put_test.go - http_status.go - quick_ctx_mock_test.go - quick_default_config_test.go - quick_delete_test.go - quick_display.go - quick_fileserver_test.go - quick_get_test.go - quick_godoc_test.go - quick_post_test.go - quick_put_test.go - quick_test.go
1 parent a60d5c0 commit 040338e

19 files changed

+829
-328
lines changed

ctx_godoc_test.go

+95-19
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import (
1212
"testing"
1313
)
1414

15-
// go test -v -run ^TestCtx_GetReqHeadersAll
15+
// TestCtx_GetReqHeadersAll ensures GetReqHeadersAll returns all request headers.
16+
//
17+
// To run:
18+
//
19+
// go test -v -run ^TestCtx_GetReqHeadersAll$
1620
func TestCtx_GetReqHeadersAll(t *testing.T) {
1721
ctx := &Ctx{
1822
Headers: map[string][]string{
@@ -32,7 +36,11 @@ func TestCtx_GetReqHeadersAll(t *testing.T) {
3236
}
3337
}
3438

35-
// go test -v -run ^TestCtx_GetHeadersAll
39+
// TestCtx_GetHeadersAll ensures GetHeadersAll returns all headers from the context.
40+
//
41+
// To run:
42+
//
43+
// go test -v -run ^TestCtx_GetHeadersAll$
3644
func TestCtx_GetHeadersAll(t *testing.T) {
3745
ctx := &Ctx{
3846
Headers: map[string][]string{
@@ -52,7 +60,11 @@ func TestCtx_GetHeadersAll(t *testing.T) {
5260
}
5361
}
5462

55-
// go test -v -run ^TestCtx_ExampleBind
63+
// TestCtx_ExampleBind verifies that Bind correctly binds JSON body to a struct.
64+
//
65+
// To run:
66+
//
67+
// go test -v -run ^TestCtx_ExampleBind$
5668
func TestCtx_ExampleBind(t *testing.T) {
5769
q := New()
5870

@@ -90,7 +102,11 @@ func TestCtx_ExampleBind(t *testing.T) {
90102
}
91103
}
92104

93-
// go test -v -run ^TestCtx_ExampleBodyParser
105+
// TestCtx_ExampleBodyParser checks if BodyParser parses the request body into a struct.
106+
//
107+
// To run:
108+
//
109+
// go test -v -run ^TestCtx_ExampleBodyParser$
94110
func TestCtx_ExampleBodyParser(t *testing.T) {
95111
q := New()
96112

@@ -126,7 +142,11 @@ func TestCtx_ExampleBodyParser(t *testing.T) {
126142
}
127143
}
128144

129-
// go test -v -run ^TestCtx_ExampleParam
145+
// TestCtx_ExampleParam checks if Param correctly retrieves path parameters.
146+
//
147+
// To run:
148+
//
149+
// go test -v -run ^TestCtx_ExampleParam$
130150
func TestCtx_ExampleParam(t *testing.T) {
131151
q := New()
132152

@@ -146,7 +166,11 @@ func TestCtx_ExampleParam(t *testing.T) {
146166
}
147167
}
148168

149-
// go test -v -run ^TestCtx_ExampleBody
169+
// TestCtx_ExampleBody ensures Body returns the correct raw request body.
170+
//
171+
// To run:
172+
//
173+
// go test -v -run ^TestCtx_ExampleBody$
150174
func TestCtx_ExampleBody(t *testing.T) {
151175
expectedBody := `{"name": "Quick", "age": 28}`
152176

@@ -161,7 +185,11 @@ func TestCtx_ExampleBody(t *testing.T) {
161185
}
162186
}
163187

164-
// go test -v -run ^TestCtx_ExampleBodyString
188+
// TestCtx_ExampleBodyString ensures BodyString returns the body as a string.
189+
//
190+
// To run:
191+
//
192+
// go test -v -run ^TestCtx_ExampleBodyString$
165193
func TestCtx_ExampleBodyString(t *testing.T) {
166194
expectedBody := `{"name": "Quick", "age": 28}`
167195

@@ -176,7 +204,11 @@ func TestCtx_ExampleBodyString(t *testing.T) {
176204
}
177205
}
178206

179-
// go test -v -run ^TestCtx_ExampleJSON
207+
// TestCtx_ExampleJSON validates JSON response generation.
208+
//
209+
// To run:
210+
//
211+
// go test -v -run ^TestCtx_ExampleJSON$
180212
func TestCtx_ExampleJSON(t *testing.T) {
181213
q := New()
182214

@@ -205,7 +237,11 @@ func TestCtx_ExampleJSON(t *testing.T) {
205237
}
206238
}
207239

208-
// go test -v -run ^TestCtx_ExampleJSONIN
240+
// TestCtx_ExampleJSONIN ensures JSONIN returns correct JSON with header set.
241+
//
242+
// To run:
243+
//
244+
// go test -v -run ^TestCtx_ExampleJSONIN$
209245
func TestCtx_ExampleJSONIN(t *testing.T) {
210246
q := New()
211247

@@ -238,7 +274,11 @@ type XMLMessage struct {
238274
Message string `xml:",chardata"`
239275
}
240276

241-
// go test -v -run ^TestCtx_ExampleXML
277+
// TestCtx_ExampleXML verifies that XML responses are returned properly.
278+
//
279+
// To run:
280+
//
281+
// go test -v -run ^TestCtx_ExampleXML$
242282
func TestCtx_ExampleXML(t *testing.T) {
243283
q := New()
244284

@@ -267,7 +307,11 @@ func TestCtx_ExampleXML(t *testing.T) {
267307
}
268308
}
269309

270-
// go test -v -run ^TestCtx_ExamplewriteResponse
310+
// TestCtx_ExamplewriteResponse validates raw byte response writing.
311+
//
312+
// To run:
313+
//
314+
// go test -v -run ^TestCtx_ExamplewriteResponse$
271315
func TestCtx_ExamplewriteResponse(t *testing.T) {
272316
q := New()
273317

@@ -292,7 +336,11 @@ func TestCtx_ExamplewriteResponse(t *testing.T) {
292336
}
293337
}
294338

295-
// go test -v -run ^TestCtx_ExampleByte
339+
// TestCtx_ExampleByte checks that Byte correctly writes raw bytes.
340+
//
341+
// To run:
342+
//
343+
// go test -v -run ^TestCtx_ExampleByte$
296344
func TestCtx_ExampleByte(t *testing.T) {
297345
q := New()
298346

@@ -317,7 +365,11 @@ func TestCtx_ExampleByte(t *testing.T) {
317365
}
318366
}
319367

320-
// go test -v -run ^TestCtx_ExampleSend
368+
// TestCtx_ExampleSend validates that Send writes the correct byte response.
369+
//
370+
// To run:
371+
//
372+
// go test -v -run ^TestCtx_ExampleSend$
321373
func TestCtx_ExampleSend(t *testing.T) {
322374
q := New()
323375

@@ -342,7 +394,11 @@ func TestCtx_ExampleSend(t *testing.T) {
342394
}
343395
}
344396

345-
// go test -v -run ^TestCtx_ExampleSendString
397+
// TestCtx_ExampleSendString checks that SendString writes a plain text response.
398+
//
399+
// To run:
400+
//
401+
// go test -v -run ^TestCtx_ExampleSendString$
346402
func TestCtx_ExampleSendString(t *testing.T) {
347403
q := New()
348404

@@ -367,7 +423,11 @@ func TestCtx_ExampleSendString(t *testing.T) {
367423
}
368424
}
369425

370-
// go test -v -run ^TestCtx_ExampleSendFile
426+
// TestCtx_ExampleSendFile ensures that SendFile correctly sends file content.
427+
//
428+
// To run:
429+
//
430+
// go test -v -run ^TestCtx_ExampleSendFile$
371431
func TestCtx_ExampleSendFile(t *testing.T) {
372432
q := New()
373433

@@ -393,7 +453,11 @@ func TestCtx_ExampleSendFile(t *testing.T) {
393453
}
394454
}
395455

396-
// go test -v -run ^TestCtx_ExampleSet
456+
// TestCtx_ExampleSet verifies that Set adds headers correctly.
457+
//
458+
// To run:
459+
//
460+
// go test -v -run ^TestCtx_ExampleSet$
397461
func TestCtx_ExampleSet(t *testing.T) {
398462
q := New()
399463

@@ -420,7 +484,11 @@ func TestCtx_ExampleSet(t *testing.T) {
420484
}
421485
}
422486

423-
// go test -v -run ^TestCtx_ExampleAppend
487+
// TestCtx_ExampleAppend ensures that headers can be appended properly.
488+
//
489+
// To run:
490+
//
491+
// go test -v -run ^TestCtx_ExampleAppend$
424492
func TestCtx_ExampleAppend(t *testing.T) {
425493
q := New()
426494

@@ -443,7 +511,11 @@ func TestCtx_ExampleAppend(t *testing.T) {
443511
}
444512
}
445513

446-
// go test -v -run ^TestCtx_ExampleAccepts
514+
// TestCtx_ExampleAccepts checks if the Accepts method sets the correct header.
515+
//
516+
// To run:
517+
//
518+
// go test -v -run ^TestCtx_ExampleAccepts$
447519
func TestCtx_ExampleAccepts(t *testing.T) {
448520
q := New()
449521

@@ -465,7 +537,11 @@ func TestCtx_ExampleAccepts(t *testing.T) {
465537
}
466538
}
467539

468-
// go test -v -run ^TestCtx_ExampleStatus
540+
// TestCtx_ExampleStatus verifies that Status sets the correct HTTP status code.
541+
//
542+
// To run:
543+
//
544+
// go test -v -run ^TestCtx_ExampleStatus$
469545
func TestCtx_ExampleStatus(t *testing.T) {
470546
q := New()
471547

0 commit comments

Comments
 (0)