[{"data":1,"prerenderedAt":1655},["ShallowReactive",2],{"navigation_docs":3,"-standard-library-testing":377,"-standard-library-testing-surround":1650},[4,39,114,144,184,244,293,362],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":6},"Getting Started",false,"\u002Fgetting-started","1.getting-started",[10,15,20,25,30,35],{"title":11,"path":12,"stem":13,"icon":14},"Learning Path","\u002Fgetting-started\u002Flearning-path","1.getting-started\u002F1.learning-path","i-lucide-map",{"title":16,"path":17,"stem":18,"icon":19},"Introduction","\u002Fgetting-started\u002Fintroduction","1.getting-started\u002F2.introduction","i-lucide-house",{"title":21,"path":22,"stem":23,"icon":24},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F3.installation","i-lucide-download",{"title":26,"path":27,"stem":28,"icon":29},"Your First Program","\u002Fgetting-started\u002Ffirst-program","1.getting-started\u002F4.first-program","i-lucide-play",{"title":31,"path":32,"stem":33,"icon":34},"Modules and Dependencies","\u002Fgetting-started\u002Fmodules-and-dependencies","1.getting-started\u002F5.modules-and-dependencies","i-lucide-package-open",{"title":36,"path":37,"stem":38,"icon":34},"Advanced Modules","\u002Fgetting-started\u002Fadvanced-modules","1.getting-started\u002F6.advanced-modules",{"title":40,"path":41,"stem":42,"children":43,"page":6},"Fundamentals","\u002Ffundamentals","2.fundamentals",[44,49,54,59,64,69,74,79,84,89,94,99,104,109],{"title":45,"path":46,"stem":47,"icon":48},"Program Structure","\u002Ffundamentals\u002Fprogram-structure","2.fundamentals\u002F1.program-structure","i-lucide-workflow",{"title":50,"path":51,"stem":52,"icon":53},"Structs and Methods","\u002Ffundamentals\u002Fstructs-and-methods","2.fundamentals\u002F10.structs-and-methods","i-lucide-box",{"title":55,"path":56,"stem":57,"icon":58},"Interfaces","\u002Ffundamentals\u002Finterfaces","2.fundamentals\u002F11.interfaces","i-lucide-plug",{"title":60,"path":61,"stem":62,"icon":63},"Error Handling","\u002Ffundamentals\u002Ferrors","2.fundamentals\u002F12.errors","i-lucide-triangle-alert",{"title":65,"path":66,"stem":67,"icon":68},"Defined Types and Type Aliases","\u002Ffundamentals\u002Fdefined-types","2.fundamentals\u002F13.defined-types","i-lucide-tags",{"title":70,"path":71,"stem":72,"icon":73},"Generics","\u002Ffundamentals\u002Fgenerics","2.fundamentals\u002F14.generics","i-lucide-blocks",{"title":75,"path":76,"stem":77,"icon":78},"Project Structure","\u002Ffundamentals\u002Fproject-structure","2.fundamentals\u002F2.project-structure","i-lucide-folder-tree",{"title":80,"path":81,"stem":82,"icon":83},"Project Layout","\u002Ffundamentals\u002Fproject-layout","2.fundamentals\u002F3.project-layout","i-lucide-layout",{"title":85,"path":86,"stem":87,"icon":88},"Variables and Data Types","\u002Ffundamentals\u002Fvariables-and-types","2.fundamentals\u002F4.variables-and-types","i-lucide-variable",{"title":90,"path":91,"stem":92,"icon":93},"Functions","\u002Ffundamentals\u002Ffunctions","2.fundamentals\u002F5.functions","i-lucide-braces",{"title":95,"path":96,"stem":97,"icon":98},"Control Statements","\u002Ffundamentals\u002Fcontrol-statements","2.fundamentals\u002F6.control-statements","i-lucide-git-branch",{"title":100,"path":101,"stem":102,"icon":103},"Pointers","\u002Ffundamentals\u002Fpointers","2.fundamentals\u002F7.pointers","i-lucide-mouse-pointer-2",{"title":105,"path":106,"stem":107,"icon":108},"Arrays and Slices","\u002Ffundamentals\u002Farrays-and-slices","2.fundamentals\u002F8.arrays-and-slices","i-lucide-list",{"title":110,"path":111,"stem":112,"icon":113},"Maps","\u002Ffundamentals\u002Fmaps","2.fundamentals\u002F9.maps","i-lucide-table-properties",{"title":115,"path":116,"stem":117,"children":118,"page":6},"Concurrency","\u002Fconcurrency","3.concurrency",[119,124,129,134,139],{"title":120,"path":121,"stem":122,"icon":123},"Concurrency Model","\u002Fconcurrency\u002Fconcurrency-model","3.concurrency\u002F1.concurrency-model","i-lucide-network",{"title":125,"path":126,"stem":127,"icon":128},"Goroutines","\u002Fconcurrency\u002Fgoroutines","3.concurrency\u002F2.goroutines","i-lucide-git-fork",{"title":130,"path":131,"stem":132,"icon":133},"Channels","\u002Fconcurrency\u002Fchannels","3.concurrency\u002F3.channels","i-lucide-arrow-left-right",{"title":135,"path":136,"stem":137,"icon":138},"Select and Cancellation","\u002Fconcurrency\u002Fselect-and-cancellation","3.concurrency\u002F4.select-and-cancellation","i-lucide-circle-stop",{"title":140,"path":141,"stem":142,"icon":143},"Synchronization","\u002Fconcurrency\u002Fsynchronization","3.concurrency\u002F5.synchronization","i-lucide-lock-keyhole",{"title":145,"path":146,"stem":147,"children":148,"page":6},"Standard Library","\u002Fstandard-library","4.standard-library",[149,154,159,164,169,174,179],{"title":150,"path":151,"stem":152,"icon":153},"Standard Library Overview","\u002Fstandard-library\u002Foverview","4.standard-library\u002F1.overview","i-lucide-library",{"title":155,"path":156,"stem":157,"icon":158},"Text and Formatting","\u002Fstandard-library\u002Ftext-and-formatting","4.standard-library\u002F2.text-and-formatting","i-lucide-text",{"title":160,"path":161,"stem":162,"icon":163},"Files and JSON","\u002Fstandard-library\u002Ffiles-and-json","4.standard-library\u002F3.files-and-json","i-lucide-file-json",{"title":165,"path":166,"stem":167,"icon":168},"HTTP Clients and Servers","\u002Fstandard-library\u002Fhttp","4.standard-library\u002F4.http","i-lucide-server",{"title":170,"path":171,"stem":172,"icon":173},"Testing","\u002Fstandard-library\u002Ftesting","4.standard-library\u002F5.testing","i-lucide-flask-conical",{"title":175,"path":176,"stem":177,"icon":178},"Command-Line Tools and Configuration","\u002Fstandard-library\u002Fcommand-line-and-configuration","4.standard-library\u002F6.command-line-and-configuration","i-lucide-terminal-square",{"title":180,"path":181,"stem":182,"icon":183},"Structured Logging","\u002Fstandard-library\u002Fstructured-logging","4.standard-library\u002F7.structured-logging","i-lucide-scroll-text",{"title":185,"path":186,"stem":187,"children":188,"page":6},"Backend Development","\u002Fbackend-development","5.backend-development",[189,194,199,204,209,214,219,224,229,234,239],{"title":190,"path":191,"stem":192,"icon":193},"Backend Roadmap","\u002Fbackend-development\u002Fbackend-roadmap","5.backend-development\u002F1.backend-roadmap","i-lucide-route",{"title":195,"path":196,"stem":197,"icon":198},"Graceful Shutdown","\u002Fbackend-development\u002Fgraceful-shutdown","5.backend-development\u002F10.graceful-shutdown","i-lucide-power",{"title":200,"path":201,"stem":202,"icon":203},"Production Checklist","\u002Fbackend-development\u002Fproduction-checklist","5.backend-development\u002F11.production-checklist","i-lucide-clipboard-check",{"title":205,"path":206,"stem":207,"icon":208},"HTTP API Design","\u002Fbackend-development\u002Fhttp-api-design","5.backend-development\u002F2.http-api-design","i-lucide-waypoints",{"title":210,"path":211,"stem":212,"icon":213},"Middleware","\u002Fbackend-development\u002Fmiddleware","5.backend-development\u002F3.middleware","i-lucide-layers-3",{"title":215,"path":216,"stem":217,"icon":218},"Validation","\u002Fbackend-development\u002Fvalidation","5.backend-development\u002F4.validation","i-lucide-list-checks",{"title":220,"path":221,"stem":222,"icon":223},"Application Wiring","\u002Fbackend-development\u002Fapplication-wiring","5.backend-development\u002F5.application-wiring","i-lucide-cable",{"title":225,"path":226,"stem":227,"icon":228},"Observability","\u002Fbackend-development\u002Fobservability","5.backend-development\u002F6.observability","i-lucide-activity",{"title":230,"path":231,"stem":232,"icon":233},"Database SQL","\u002Fbackend-development\u002Fdatabase-sql","5.backend-development\u002F7.database-sql","i-lucide-database",{"title":235,"path":236,"stem":237,"icon":238},"Transactions","\u002Fbackend-development\u002Ftransactions","5.backend-development\u002F8.transactions","i-lucide-repeat-2",{"title":240,"path":241,"stem":242,"icon":243},"Authentication and Authorization","\u002Fbackend-development\u002Fauthentication","5.backend-development\u002F9.authentication","i-lucide-shield-check",{"title":245,"path":246,"stem":247,"children":248,"page":6},"Advanced Go","\u002Fadvanced-go","6.advanced-go",[249,254,259,264,269,274,278,283,288],{"title":250,"path":251,"stem":252,"icon":253},"Advanced Go Roadmap","\u002Fadvanced-go\u002Fadvanced-roadmap","6.advanced-go\u002F1.advanced-roadmap","i-lucide-brain-circuit",{"title":255,"path":256,"stem":257,"icon":258},"Reflection","\u002Fadvanced-go\u002Freflection","6.advanced-go\u002F2.reflection","i-lucide-scan-search",{"title":260,"path":261,"stem":262,"icon":263},"Memory and Garbage Collection","\u002Fadvanced-go\u002Fmemory-and-garbage-collection","6.advanced-go\u002F3.memory-and-garbage-collection","i-lucide-memory-stick",{"title":265,"path":266,"stem":267,"icon":268},"Benchmarking and Profiling","\u002Fadvanced-go\u002Fbenchmarking-and-profiling","6.advanced-go\u002F4.benchmarking-and-profiling","i-lucide-gauge",{"title":270,"path":271,"stem":272,"icon":273},"Advanced Testing and Fuzzing","\u002Fadvanced-go\u002Fadvanced-testing-and-fuzzing","6.advanced-go\u002F5.advanced-testing-and-fuzzing","i-lucide-microscope",{"title":275,"path":276,"stem":277,"icon":48},"Advanced Concurrency","\u002Fadvanced-go\u002Fadvanced-concurrency","6.advanced-go\u002F6.advanced-concurrency",{"title":279,"path":280,"stem":281,"icon":282},"Unsafe and C Boundaries","\u002Fadvanced-go\u002Funsafe-and-cgo","6.advanced-go\u002F7.unsafe-and-cgo","i-lucide-radiation",{"title":284,"path":285,"stem":286,"icon":287},"Package and API Design","\u002Fadvanced-go\u002Fpackage-and-api-design","6.advanced-go\u002F8.package-and-api-design","i-lucide-boxes",{"title":289,"path":290,"stem":291,"icon":292},"Distributed Reliability","\u002Fadvanced-go\u002Fdistributed-reliability","6.advanced-go\u002F9.distributed-reliability","i-lucide-cloud-cog",{"title":294,"path":295,"stem":296,"children":297,"page":6},"Projects","\u002Fprojects","7.projects",[298,316,332,347],{"title":299,"path":300,"stem":301,"children":302,"icon":305},"CLI Task Manager","\u002Fprojects\u002Fcli-task-manager","7.projects\u002F1.cli-task-manager\u002Findex",[303,306,311],{"title":304,"path":300,"stem":301,"icon":305},"Project — CLI Task Manager","i-lucide-list-todo",{"title":307,"path":308,"stem":309,"icon":310},"CLI — Domain and Storage","\u002Fprojects\u002Fcli-task-manager\u002Fdomain-and-storage","7.projects\u002F1.cli-task-manager\u002F1.domain-and-storage","i-lucide-save",{"title":312,"path":313,"stem":314,"icon":315},"CLI — Commands and Tests","\u002Fprojects\u002Fcli-task-manager\u002Fcommands-and-tests","7.projects\u002F1.cli-task-manager\u002F2.commands-and-tests","i-lucide-terminal",{"title":317,"path":318,"stem":319,"children":320,"icon":323},"Concurrent URL Checker","\u002Fprojects\u002Fconcurrent-url-checker","7.projects\u002F2.concurrent-url-checker\u002Findex",[321,324,328],{"title":322,"path":318,"stem":319,"icon":323},"Project — Concurrent URL Checker","i-lucide-radar",{"title":325,"path":326,"stem":327,"icon":128},"URL Checker — Worker Pipeline","\u002Fprojects\u002Fconcurrent-url-checker\u002Fworker-pipeline","7.projects\u002F2.concurrent-url-checker\u002F1.worker-pipeline",{"title":329,"path":330,"stem":331,"icon":173},"URL Checker — Cancellation and Tests","\u002Fprojects\u002Fconcurrent-url-checker\u002Fcancellation-and-tests","7.projects\u002F2.concurrent-url-checker\u002F2.cancellation-and-tests",{"title":333,"path":334,"stem":335,"children":336},"File-backed API","\u002Fprojects\u002Ffile-backed-api","7.projects\u002F3.file-backed-api\u002Findex",[337,339,343],{"title":338,"path":334,"stem":335},"File-backed notes API",{"title":340,"path":341,"stem":342},"File store and concurrency","\u002Fprojects\u002Ffile-backed-api\u002Ffile-store-and-concurrency","7.projects\u002F3.file-backed-api\u002F1.file-store-and-concurrency",{"title":344,"path":345,"stem":346},"HTTP layer and tests","\u002Fprojects\u002Ffile-backed-api\u002Fhttp-and-tests","7.projects\u002F3.file-backed-api\u002F2.http-and-tests",{"title":348,"path":349,"stem":350,"children":351},"Production REST API","\u002Fprojects\u002Fproduction-rest-api","7.projects\u002F4.production-rest-api\u002Findex",[352,354,358],{"title":353,"path":349,"stem":350},"Production REST API capstone",{"title":355,"path":356,"stem":357},"Persistence and authentication","\u002Fprojects\u002Fproduction-rest-api\u002Fpersistence-and-auth","7.projects\u002F4.production-rest-api\u002F1.persistence-and-auth",{"title":359,"path":360,"stem":361},"Operations and release","\u002Fprojects\u002Fproduction-rest-api\u002Foperations-and-release","7.projects\u002F4.production-rest-api\u002F2.operations-and-release",{"title":363,"path":364,"stem":365,"children":366,"page":6},"Meta","\u002Fmeta","99.meta",[367,372],{"title":368,"path":369,"stem":370,"icon":371},"About","\u002Fmeta\u002Fabout","99.meta\u002F1.about","i-lucide-info",{"title":373,"path":374,"stem":375,"icon":376},"Acknowledgements","\u002Fmeta\u002Facknowledgements","99.meta\u002F2.acknowledgements","i-lucide-heart-handshake",{"id":378,"title":170,"body":379,"description":1642,"extension":1643,"links":1644,"meta":1645,"navigation":1646,"path":171,"seo":1647,"stem":172,"__hash__":1649},"docs\u002F4.standard-library\u002F5.testing.md",{"type":380,"value":381,"toc":1631},"minimark",[382,389,394,407,416,420,423,512,515,690,693,711,717,721,724,1150,1153,1157,1229,1240,1244,1467,1473,1477,1554,1557,1561,1578,1582,1585,1604,1608,1619,1622,1627],[383,384],"learning-lesson-meta",{"description":385,"difficulty":386,"prerequisites":387,"time":388},"Test observable contracts with focused, repeatable cases.","Intermediate","Functions, errors, and HTTP","45 minutes",[390,391,393],"h2",{"id":392},"what-you-will-learn","What you will learn",[395,396,397,401,404],"ul",{},[398,399,400],"li",{},"write focused unit and table-driven tests;",[398,402,403],{},"test error meaning rather than text when possible;",[398,405,406],{},"test HTTP handlers without binding a real port;",[408,409,410,411,415],"p",{},"Tests are ordinary Go functions stored in files ending with ",[412,413,414],"code",{},"_test.go",". They give you confidence to change code and help document expected behaviour.",[390,417,419],{"id":418},"a-first-unit-test","A first unit test",[408,421,422],{},"Production code:",[424,425,431],"pre",{"className":426,"code":427,"filename":428,"language":429,"meta":430,"style":430},"language-go shiki shiki-themes solarized-light material-theme one-dark-pro","package mathx\n\nfunc Add(a, b int) int {\n    return a + b\n}\n","math.go","go","",[412,432,433,446,453,489,506],{"__ignoreMap":430},[434,435,438,442],"span",{"class":436,"line":437},"line",1,[434,439,441],{"class":440},"sEOdo","package",[434,443,445],{"class":444},"snwKR"," mathx\n",[434,447,449],{"class":436,"line":448},2,[434,450,452],{"emptyLinePlaceholder":451},true,"\n",[434,454,456,459,463,467,471,474,477,481,484,486],{"class":436,"line":455},3,[434,457,458],{"class":440},"func",[434,460,462],{"class":461},"sisdC"," Add",[434,464,466],{"class":465},"shFME","(",[434,468,470],{"class":469},"syre3","a",[434,472,473],{"class":465},",",[434,475,476],{"class":469}," b",[434,478,480],{"class":479},"sF6sA"," int",[434,482,483],{"class":465},")",[434,485,480],{"class":479},[434,487,488],{"class":465}," {\n",[434,490,492,496,500,503],{"class":436,"line":491},4,[434,493,495],{"class":494},"s7Bcg","    return",[434,497,499],{"class":498},"s45-6"," a",[434,501,502],{"class":440}," +",[434,504,505],{"class":498}," b\n",[434,507,509],{"class":436,"line":508},5,[434,510,511],{"class":465},"}\n",[408,513,514],{},"Test code:",[424,516,519],{"className":426,"code":517,"filename":518,"language":429,"meta":430,"style":430},"package mathx\n\nimport \"testing\"\n\nfunc TestAdd(t *testing.T) {\n    got := Add(2, 3)\n    want := 5\n\n    if got != want {\n        t.Fatalf(\"Add(2, 3) = %d; want %d\", got, want)\n    }\n}\n","math_test.go",[412,520,521,527,531,547,551,578,604,615,620,638,679,685],{"__ignoreMap":430},[434,522,523,525],{"class":436,"line":437},[434,524,441],{"class":440},[434,526,445],{"class":444},[434,528,529],{"class":436,"line":448},[434,530,452],{"emptyLinePlaceholder":451},[434,532,533,536,540,544],{"class":436,"line":455},[434,534,535],{"class":494},"import",[434,537,539],{"class":538},"sED5a"," \"",[434,541,543],{"class":542},"sdLNw","testing",[434,545,546],{"class":538},"\"\n",[434,548,549],{"class":436,"line":491},[434,550,452],{"emptyLinePlaceholder":451},[434,552,553,555,558,560,563,566,568,571,574,576],{"class":436,"line":508},[434,554,458],{"class":440},[434,556,557],{"class":461}," TestAdd",[434,559,466],{"class":465},[434,561,562],{"class":469},"t",[434,564,565],{"class":440}," *",[434,567,543],{"class":444},[434,569,570],{"class":465},".",[434,572,573],{"class":444},"T",[434,575,483],{"class":465},[434,577,488],{"class":465},[434,579,581,584,588,590,592,596,598,601],{"class":436,"line":580},6,[434,582,583],{"class":498},"    got",[434,585,587],{"class":586},"su2KV"," :=",[434,589,462],{"class":461},[434,591,466],{"class":465},[434,593,595],{"class":594},"sAJzr","2",[434,597,473],{"class":465},[434,599,600],{"class":594}," 3",[434,602,603],{"class":465},")\n",[434,605,607,610,612],{"class":436,"line":606},7,[434,608,609],{"class":498},"    want",[434,611,587],{"class":586},[434,613,614],{"class":594}," 5\n",[434,616,618],{"class":436,"line":617},8,[434,619,452],{"emptyLinePlaceholder":451},[434,621,623,626,629,633,636],{"class":436,"line":622},9,[434,624,625],{"class":494},"    if",[434,627,628],{"class":498}," got",[434,630,632],{"class":631},"sRBoR"," !=",[434,634,635],{"class":498}," want",[434,637,488],{"class":465},[434,639,641,644,646,649,651,654,658,662,665,667,669,671,673,675,677],{"class":436,"line":640},10,[434,642,643],{"class":498},"        t",[434,645,570],{"class":465},[434,647,648],{"class":461},"Fatalf",[434,650,466],{"class":465},[434,652,653],{"class":538},"\"",[434,655,657],{"class":656},"sVazx","Add(2, 3) = ",[434,659,661],{"class":660},"st3jj","%d",[434,663,664],{"class":656},"; want ",[434,666,661],{"class":660},[434,668,653],{"class":538},[434,670,473],{"class":465},[434,672,628],{"class":498},[434,674,473],{"class":465},[434,676,635],{"class":498},[434,678,603],{"class":465},[434,680,682],{"class":436,"line":681},11,[434,683,684],{"class":465},"    }\n",[434,686,688],{"class":436,"line":687},12,[434,689,511],{"class":465},[408,691,692],{},"Run it with:",[424,694,698],{"className":695,"code":696,"language":697,"meta":430,"style":430},"language-bash shiki shiki-themes solarized-light material-theme one-dark-pro","go test .\u002F...\n","bash",[412,699,700],{"__ignoreMap":430},[434,701,702,705,708],{"class":436,"line":437},[434,703,429],{"class":704},"sqRHY",[434,706,707],{"class":656}," test",[434,709,710],{"class":656}," .\u002F...\n",[408,712,713,716],{},[412,714,715],{},".\u002F..."," means every package below the current directory.",[390,718,720],{"id":719},"table-driven-tests","Table-driven tests",[408,722,723],{},"Tables make several cases easy to read and extend:",[424,725,727],{"className":426,"code":726,"language":429,"meta":430,"style":430},"func TestAdd(t *testing.T) {\n    tests := []struct {\n        name string\n        a    int\n        b    int\n        want int\n    }{\n        {name: \"positive\", a: 2, b: 3, want: 5},\n        {name: \"negative\", a: -2, b: -3, want: -5},\n        {name: \"zero\", a: 8, b: 0, want: 8},\n    }\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            got := Add(tt.a, tt.b)\n            if got != tt.want {\n                t.Errorf(\"Add(%d, %d) = %d; want %d\", tt.a, tt.b, got, tt.want)\n            }\n        })\n    }\n}\n",[412,728,729,751,766,774,782,789,797,802,849,899,942,946,950,974,1014,1043,1062,1128,1134,1140,1145],{"__ignoreMap":430},[434,730,731,733,735,737,739,741,743,745,747,749],{"class":436,"line":437},[434,732,458],{"class":440},[434,734,557],{"class":461},[434,736,466],{"class":465},[434,738,562],{"class":469},[434,740,565],{"class":440},[434,742,543],{"class":444},[434,744,570],{"class":465},[434,746,573],{"class":444},[434,748,483],{"class":465},[434,750,488],{"class":465},[434,752,753,756,758,761,764],{"class":436,"line":448},[434,754,755],{"class":498},"    tests",[434,757,587],{"class":586},[434,759,760],{"class":465}," []",[434,762,763],{"class":440},"struct",[434,765,488],{"class":465},[434,767,768,771],{"class":436,"line":455},[434,769,770],{"class":498},"        name",[434,772,773],{"class":479}," string\n",[434,775,776,779],{"class":436,"line":491},[434,777,778],{"class":498},"        a",[434,780,781],{"class":479},"    int\n",[434,783,784,787],{"class":436,"line":508},[434,785,786],{"class":498},"        b",[434,788,781],{"class":479},[434,790,791,794],{"class":436,"line":580},[434,792,793],{"class":498},"        want",[434,795,796],{"class":479}," int\n",[434,798,799],{"class":436,"line":606},[434,800,801],{"class":465},"    }{\n",[434,803,804,807,810,813,815,818,820,822,824,826,829,831,833,835,837,839,841,843,846],{"class":436,"line":617},[434,805,806],{"class":465},"        {",[434,808,809],{"class":498},"name",[434,811,812],{"class":465},":",[434,814,539],{"class":538},[434,816,817],{"class":656},"positive",[434,819,653],{"class":538},[434,821,473],{"class":465},[434,823,499],{"class":498},[434,825,812],{"class":465},[434,827,828],{"class":594}," 2",[434,830,473],{"class":465},[434,832,476],{"class":498},[434,834,812],{"class":465},[434,836,600],{"class":594},[434,838,473],{"class":465},[434,840,635],{"class":498},[434,842,812],{"class":465},[434,844,845],{"class":594}," 5",[434,847,848],{"class":465},"},\n",[434,850,851,853,855,857,859,862,864,866,868,870,873,875,877,879,881,883,886,888,890,892,894,897],{"class":436,"line":622},[434,852,806],{"class":465},[434,854,809],{"class":498},[434,856,812],{"class":465},[434,858,539],{"class":538},[434,860,861],{"class":656},"negative",[434,863,653],{"class":538},[434,865,473],{"class":465},[434,867,499],{"class":498},[434,869,812],{"class":465},[434,871,872],{"class":440}," -",[434,874,595],{"class":594},[434,876,473],{"class":465},[434,878,476],{"class":498},[434,880,812],{"class":465},[434,882,872],{"class":440},[434,884,885],{"class":594},"3",[434,887,473],{"class":465},[434,889,635],{"class":498},[434,891,812],{"class":465},[434,893,872],{"class":440},[434,895,896],{"class":594},"5",[434,898,848],{"class":465},[434,900,901,903,905,907,909,912,914,916,918,920,923,925,927,929,932,934,936,938,940],{"class":436,"line":640},[434,902,806],{"class":465},[434,904,809],{"class":498},[434,906,812],{"class":465},[434,908,539],{"class":538},[434,910,911],{"class":656},"zero",[434,913,653],{"class":538},[434,915,473],{"class":465},[434,917,499],{"class":498},[434,919,812],{"class":465},[434,921,922],{"class":594}," 8",[434,924,473],{"class":465},[434,926,476],{"class":498},[434,928,812],{"class":465},[434,930,931],{"class":594}," 0",[434,933,473],{"class":465},[434,935,635],{"class":498},[434,937,812],{"class":465},[434,939,922],{"class":594},[434,941,848],{"class":465},[434,943,944],{"class":436,"line":681},[434,945,684],{"class":465},[434,947,948],{"class":436,"line":687},[434,949,452],{"emptyLinePlaceholder":451},[434,951,953,956,959,961,964,966,969,972],{"class":436,"line":952},13,[434,954,955],{"class":494},"    for",[434,957,958],{"class":498}," _",[434,960,473],{"class":465},[434,962,963],{"class":498}," tt",[434,965,587],{"class":586},[434,967,968],{"class":494}," range",[434,970,971],{"class":498}," tests",[434,973,488],{"class":465},[434,975,977,979,981,984,986,989,991,993,995,998,1000,1002,1004,1006,1008,1010,1012],{"class":436,"line":976},14,[434,978,643],{"class":498},[434,980,570],{"class":465},[434,982,983],{"class":461},"Run",[434,985,466],{"class":465},[434,987,988],{"class":498},"tt",[434,990,570],{"class":465},[434,992,809],{"class":498},[434,994,473],{"class":465},[434,996,997],{"class":440}," func",[434,999,466],{"class":465},[434,1001,562],{"class":469},[434,1003,565],{"class":440},[434,1005,543],{"class":444},[434,1007,570],{"class":465},[434,1009,573],{"class":444},[434,1011,483],{"class":465},[434,1013,488],{"class":465},[434,1015,1017,1020,1022,1024,1026,1028,1030,1032,1034,1036,1038,1041],{"class":436,"line":1016},15,[434,1018,1019],{"class":498},"            got",[434,1021,587],{"class":586},[434,1023,462],{"class":461},[434,1025,466],{"class":465},[434,1027,988],{"class":498},[434,1029,570],{"class":465},[434,1031,470],{"class":498},[434,1033,473],{"class":465},[434,1035,963],{"class":498},[434,1037,570],{"class":465},[434,1039,1040],{"class":498},"b",[434,1042,603],{"class":465},[434,1044,1046,1049,1051,1053,1055,1057,1060],{"class":436,"line":1045},16,[434,1047,1048],{"class":494},"            if",[434,1050,628],{"class":498},[434,1052,632],{"class":631},[434,1054,963],{"class":498},[434,1056,570],{"class":465},[434,1058,1059],{"class":498},"want",[434,1061,488],{"class":465},[434,1063,1065,1068,1070,1073,1075,1077,1080,1082,1085,1087,1090,1092,1094,1096,1098,1100,1102,1104,1106,1108,1110,1112,1114,1116,1118,1120,1122,1124,1126],{"class":436,"line":1064},17,[434,1066,1067],{"class":498},"                t",[434,1069,570],{"class":465},[434,1071,1072],{"class":461},"Errorf",[434,1074,466],{"class":465},[434,1076,653],{"class":538},[434,1078,1079],{"class":656},"Add(",[434,1081,661],{"class":660},[434,1083,1084],{"class":656},", ",[434,1086,661],{"class":660},[434,1088,1089],{"class":656},") = ",[434,1091,661],{"class":660},[434,1093,664],{"class":656},[434,1095,661],{"class":660},[434,1097,653],{"class":538},[434,1099,473],{"class":465},[434,1101,963],{"class":498},[434,1103,570],{"class":465},[434,1105,470],{"class":498},[434,1107,473],{"class":465},[434,1109,963],{"class":498},[434,1111,570],{"class":465},[434,1113,1040],{"class":498},[434,1115,473],{"class":465},[434,1117,628],{"class":498},[434,1119,473],{"class":465},[434,1121,963],{"class":498},[434,1123,570],{"class":465},[434,1125,1059],{"class":498},[434,1127,603],{"class":465},[434,1129,1131],{"class":436,"line":1130},18,[434,1132,1133],{"class":465},"            }\n",[434,1135,1137],{"class":436,"line":1136},19,[434,1138,1139],{"class":465},"        })\n",[434,1141,1143],{"class":436,"line":1142},20,[434,1144,684],{"class":465},[434,1146,1148],{"class":436,"line":1147},21,[434,1149,511],{"class":465},[408,1151,1152],{},"Test names should describe behaviour, not implementation details.",[390,1154,1156],{"id":1155},"test-errors-correctly","Test errors correctly",[424,1158,1160],{"className":426,"code":1159,"language":429,"meta":430,"style":430},"value, err := ParsePort(\"invalid\")\nif err == nil {\n    t.Fatal(\"ParsePort() error = nil; want an error\")\n}\n",[412,1161,1162,1188,1204,1225],{"__ignoreMap":430},[434,1163,1164,1167,1169,1172,1174,1177,1179,1181,1184,1186],{"class":436,"line":437},[434,1165,1166],{"class":498},"value",[434,1168,473],{"class":465},[434,1170,1171],{"class":498}," err",[434,1173,587],{"class":586},[434,1175,1176],{"class":461}," ParsePort",[434,1178,466],{"class":465},[434,1180,653],{"class":538},[434,1182,1183],{"class":656},"invalid",[434,1185,653],{"class":538},[434,1187,603],{"class":465},[434,1189,1190,1193,1195,1198,1202],{"class":436,"line":448},[434,1191,1192],{"class":494},"if",[434,1194,1171],{"class":498},[434,1196,1197],{"class":631}," ==",[434,1199,1201],{"class":1200},"sp8Z5"," nil",[434,1203,488],{"class":465},[434,1205,1206,1209,1211,1214,1216,1218,1221,1223],{"class":436,"line":455},[434,1207,1208],{"class":498},"    t",[434,1210,570],{"class":465},[434,1212,1213],{"class":461},"Fatal",[434,1215,466],{"class":465},[434,1217,653],{"class":538},[434,1219,1220],{"class":656},"ParsePort() error = nil; want an error",[434,1222,653],{"class":538},[434,1224,603],{"class":465},[434,1226,1227],{"class":436,"line":491},[434,1228,511],{"class":465},[408,1230,1231,1232,1235,1236,1239],{},"Use ",[412,1233,1234],{},"errors.Is"," or ",[412,1237,1238],{},"errors.As"," when callers depend on a specific error identity or type. Avoid matching entire error strings unless the text itself is the contract.",[390,1241,1243],{"id":1242},"test-http-handlers","Test HTTP handlers",[424,1245,1247],{"className":426,"code":1246,"language":429,"meta":430,"style":430},"func TestStatus(t *testing.T) {\n    request := httptest.NewRequest(http.MethodGet, \"\u002Fstatus\", nil)\n    recorder := httptest.NewRecorder()\n\n    status(recorder, request)\n\n    response := recorder.Result()\n    defer response.Body.Close()\n\n    if response.StatusCode != http.StatusOK {\n        t.Fatalf(\"status = %d; want %d\", response.StatusCode, http.StatusOK)\n    }\n}\n",[412,1248,1249,1272,1312,1329,1333,1350,1354,1371,1391,1395,1418,1459,1463],{"__ignoreMap":430},[434,1250,1251,1253,1256,1258,1260,1262,1264,1266,1268,1270],{"class":436,"line":437},[434,1252,458],{"class":440},[434,1254,1255],{"class":461}," TestStatus",[434,1257,466],{"class":465},[434,1259,562],{"class":469},[434,1261,565],{"class":440},[434,1263,543],{"class":444},[434,1265,570],{"class":465},[434,1267,573],{"class":444},[434,1269,483],{"class":465},[434,1271,488],{"class":465},[434,1273,1274,1277,1279,1282,1284,1287,1289,1292,1294,1297,1299,1301,1304,1306,1308,1310],{"class":436,"line":448},[434,1275,1276],{"class":498},"    request",[434,1278,587],{"class":586},[434,1280,1281],{"class":498}," httptest",[434,1283,570],{"class":465},[434,1285,1286],{"class":461},"NewRequest",[434,1288,466],{"class":465},[434,1290,1291],{"class":498},"http",[434,1293,570],{"class":465},[434,1295,1296],{"class":498},"MethodGet",[434,1298,473],{"class":465},[434,1300,539],{"class":538},[434,1302,1303],{"class":656},"\u002Fstatus",[434,1305,653],{"class":538},[434,1307,473],{"class":465},[434,1309,1201],{"class":1200},[434,1311,603],{"class":465},[434,1313,1314,1317,1319,1321,1323,1326],{"class":436,"line":455},[434,1315,1316],{"class":498},"    recorder",[434,1318,587],{"class":586},[434,1320,1281],{"class":498},[434,1322,570],{"class":465},[434,1324,1325],{"class":461},"NewRecorder",[434,1327,1328],{"class":465},"()\n",[434,1330,1331],{"class":436,"line":491},[434,1332,452],{"emptyLinePlaceholder":451},[434,1334,1335,1338,1340,1343,1345,1348],{"class":436,"line":508},[434,1336,1337],{"class":461},"    status",[434,1339,466],{"class":465},[434,1341,1342],{"class":498},"recorder",[434,1344,473],{"class":465},[434,1346,1347],{"class":498}," request",[434,1349,603],{"class":465},[434,1351,1352],{"class":436,"line":580},[434,1353,452],{"emptyLinePlaceholder":451},[434,1355,1356,1359,1361,1364,1366,1369],{"class":436,"line":606},[434,1357,1358],{"class":498},"    response",[434,1360,587],{"class":586},[434,1362,1363],{"class":498}," recorder",[434,1365,570],{"class":465},[434,1367,1368],{"class":461},"Result",[434,1370,1328],{"class":465},[434,1372,1373,1376,1379,1381,1384,1386,1389],{"class":436,"line":617},[434,1374,1375],{"class":494},"    defer",[434,1377,1378],{"class":498}," response",[434,1380,570],{"class":465},[434,1382,1383],{"class":498},"Body",[434,1385,570],{"class":465},[434,1387,1388],{"class":461},"Close",[434,1390,1328],{"class":465},[434,1392,1393],{"class":436,"line":622},[434,1394,452],{"emptyLinePlaceholder":451},[434,1396,1397,1399,1401,1403,1406,1408,1411,1413,1416],{"class":436,"line":640},[434,1398,625],{"class":494},[434,1400,1378],{"class":498},[434,1402,570],{"class":465},[434,1404,1405],{"class":498},"StatusCode",[434,1407,632],{"class":631},[434,1409,1410],{"class":498}," http",[434,1412,570],{"class":465},[434,1414,1415],{"class":498},"StatusOK",[434,1417,488],{"class":465},[434,1419,1420,1422,1424,1426,1428,1430,1433,1435,1437,1439,1441,1443,1445,1447,1449,1451,1453,1455,1457],{"class":436,"line":681},[434,1421,643],{"class":498},[434,1423,570],{"class":465},[434,1425,648],{"class":461},[434,1427,466],{"class":465},[434,1429,653],{"class":538},[434,1431,1432],{"class":656},"status = ",[434,1434,661],{"class":660},[434,1436,664],{"class":656},[434,1438,661],{"class":660},[434,1440,653],{"class":538},[434,1442,473],{"class":465},[434,1444,1378],{"class":498},[434,1446,570],{"class":465},[434,1448,1405],{"class":498},[434,1450,473],{"class":465},[434,1452,1410],{"class":498},[434,1454,570],{"class":465},[434,1456,1415],{"class":498},[434,1458,603],{"class":465},[434,1460,1461],{"class":436,"line":687},[434,1462,684],{"class":465},[434,1464,1465],{"class":436,"line":952},[434,1466,511],{"class":465},[408,1468,1469,1472],{},[412,1470,1471],{},"httptest"," can also start a temporary real server when you need to test client behaviour.",[390,1474,1476],{"id":1475},"useful-commands","Useful commands",[424,1478,1480],{"className":695,"code":1479,"language":697,"meta":430,"style":430},"go test .\u002F...              # all tests\ngo test -run TestAdd .\u002F... # matching tests\ngo test -race .\u002F...        # tests with the race detector\ngo test -cover .\u002F...       # coverage summary\ngo test -count=1 .\u002F...     # bypass cached successful results\n",[412,1481,1482,1495,1512,1526,1540],{"__ignoreMap":430},[434,1483,1484,1486,1488,1491],{"class":436,"line":437},[434,1485,429],{"class":704},[434,1487,707],{"class":656},[434,1489,1490],{"class":656}," .\u002F...",[434,1492,1494],{"class":1493},"sJsHy","              # all tests\n",[434,1496,1497,1499,1501,1505,1507,1509],{"class":436,"line":448},[434,1498,429],{"class":704},[434,1500,707],{"class":656},[434,1502,1504],{"class":1503},"s2SA0"," -run",[434,1506,557],{"class":656},[434,1508,1490],{"class":656},[434,1510,1511],{"class":1493}," # matching tests\n",[434,1513,1514,1516,1518,1521,1523],{"class":436,"line":455},[434,1515,429],{"class":704},[434,1517,707],{"class":656},[434,1519,1520],{"class":1503}," -race",[434,1522,1490],{"class":656},[434,1524,1525],{"class":1493},"        # tests with the race detector\n",[434,1527,1528,1530,1532,1535,1537],{"class":436,"line":491},[434,1529,429],{"class":704},[434,1531,707],{"class":656},[434,1533,1534],{"class":1503}," -cover",[434,1536,1490],{"class":656},[434,1538,1539],{"class":1493},"       # coverage summary\n",[434,1541,1542,1544,1546,1549,1551],{"class":436,"line":508},[434,1543,429],{"class":704},[434,1545,707],{"class":656},[434,1547,1548],{"class":1503}," -count=1",[434,1550,1490],{"class":656},[434,1552,1553],{"class":1493},"     # bypass cached successful results\n",[408,1555,1556],{},"Coverage shows which statements ran; it does not tell you whether the assertions are meaningful.",[390,1558,1560],{"id":1559},"test-design","Test design",[395,1562,1563,1566,1569,1572,1575],{},[398,1564,1565],{},"Keep tests deterministic; avoid real sleeps and public network services.",[398,1567,1568],{},"Inject clocks, randomness, storage, or clients when those dependencies need control.",[398,1570,1571],{},"Test public behaviour and important edge cases.",[398,1573,1574],{},"Do not mock every function. Small real values are often clearer than large mock frameworks.",[398,1576,1577],{},"A bug fix should usually include a test that fails before the fix.",[390,1579,1581],{"id":1580},"practice","Practice",[408,1583,1584],{},"Test the lesson API from the HTTP guide. Cover a successful request, malformed JSON, missing required fields, and an unsupported method. Run the tests with the race detector.",[1586,1587,1588],"accordion",{},[1589,1590,1593,1594,1597,1598,1600,1601,1603],"accordion-item",{"icon":1591,"label":1592},"i-lucide-lightbulb","Show solution","Create table cases containing input and expected result or error, run each with ",[412,1595,1596],{},"t.Run",", and compare behaviour that forms the contract. Use ",[412,1599,1234],{}," for wrapped sentinel errors and ",[412,1602,1471],{}," for handler status, headers, and decoded bodies.",[390,1605,1607],{"id":1606},"summary","Summary",[395,1609,1610,1613,1616],{},[398,1611,1612],{},"Tests document observable contracts and protect changes.",[398,1614,1615],{},"Table-driven tests make related cases easy to extend.",[398,1617,1618],{},"Test outcomes and error identity, avoiding irrelevant implementation detail.",[1620,1621],"learning-lesson-complete",{},[1623,1624],"learning-lesson-navigation",{"next":176,"nextTitle":1625,"previous":166,"previousTitle":1626},"CLI and configuration","HTTP clients and servers",[1628,1629,1630],"style",{},"html pre.shiki code .sEOdo, html code.shiki .sEOdo{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#C678DD}html pre.shiki code .snwKR, html code.shiki .snwKR{--shiki-light:#CB4B16;--shiki-default:#FFCB6B;--shiki-dark:#E5C07B}html pre.shiki code .sisdC, html code.shiki .sisdC{--shiki-light:#268BD2;--shiki-default:#82AAFF;--shiki-dark:#61AFEF}html pre.shiki code .shFME, html code.shiki .shFME{--shiki-light:#657B83;--shiki-default:#89DDFF;--shiki-dark:#ABB2BF}html pre.shiki code .syre3, html code.shiki .syre3{--shiki-light:#657B83;--shiki-light-font-style:inherit;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#E06C75;--shiki-dark-font-style:italic}html pre.shiki code .sF6sA, html code.shiki .sF6sA{--shiki-light:#586E75;--shiki-light-font-weight:bold;--shiki-default:#C792EA;--shiki-default-font-weight:inherit;--shiki-dark:#C678DD;--shiki-dark-font-weight:inherit}html pre.shiki code .s7Bcg, html code.shiki .s7Bcg{--shiki-light:#859900;--shiki-light-font-style:inherit;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#C678DD;--shiki-dark-font-style:inherit}html pre.shiki code .s45-6, html code.shiki .s45-6{--shiki-light:#268BD2;--shiki-default:#EEFFFF;--shiki-dark:#E06C75}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sED5a, html code.shiki .sED5a{--shiki-light:#2AA198;--shiki-default:#89DDFF;--shiki-dark:#98C379}html pre.shiki code .sdLNw, html code.shiki .sdLNw{--shiki-light:#2AA198;--shiki-default:#FFCB6B;--shiki-dark:#98C379}html pre.shiki code .su2KV, html code.shiki .su2KV{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#E5C07B}html pre.shiki code .sAJzr, html code.shiki .sAJzr{--shiki-light:#D33682;--shiki-default:#F78C6C;--shiki-dark:#D19A66}html pre.shiki code .sRBoR, html code.shiki .sRBoR{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#56B6C2}html pre.shiki code .sVazx, html code.shiki .sVazx{--shiki-light:#2AA198;--shiki-default:#C3E88D;--shiki-dark:#98C379}html pre.shiki code .st3jj, html code.shiki .st3jj{--shiki-light:#CB4B16;--shiki-default:#F07178;--shiki-dark:#D19A66}html pre.shiki code .sqRHY, html code.shiki .sqRHY{--shiki-light:#268BD2;--shiki-default:#FFCB6B;--shiki-dark:#61AFEF}html pre.shiki code .sp8Z5, html code.shiki .sp8Z5{--shiki-light:#B58900;--shiki-default:#89DDFF;--shiki-dark:#D19A66}html pre.shiki code .sJsHy, html code.shiki .sJsHy{--shiki-light:#93A1A1;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic}html pre.shiki code .s2SA0, html code.shiki .s2SA0{--shiki-light:#CB4B16;--shiki-default:#C3E88D;--shiki-dark:#D19A66}",{"title":430,"searchDepth":448,"depth":448,"links":1632},[1633,1634,1635,1636,1637,1638,1639,1640,1641],{"id":392,"depth":448,"text":393},{"id":418,"depth":448,"text":419},{"id":719,"depth":448,"text":720},{"id":1155,"depth":448,"text":1156},{"id":1242,"depth":448,"text":1243},{"id":1475,"depth":448,"text":1476},{"id":1559,"depth":448,"text":1560},{"id":1580,"depth":448,"text":1581},{"id":1606,"depth":448,"text":1607},"Write table-driven tests, test HTTP handlers, use subtests, and understand useful test commands.","md",null,{},{"icon":173},{"description":1648,"title":170},"Learn idiomatic Go testing with table-driven tests, subtests, httptest, benchmarks, coverage, and the race detector.","OTMf2Dm8VdhkLYI9efZVwKAWYlWDfB0idfe2kR9zS08",[1651,1653],{"title":165,"path":166,"stem":167,"description":1652,"icon":168,"children":-1},"Build a small HTTP server and call external services safely with net\u002Fhttp.",{"title":175,"path":176,"stem":177,"description":1654,"icon":178,"children":-1},"Accept flags and environment variables, validate configuration, and keep startup behaviour predictable.",1794118100659]