chore: initialize containerized Go learning workbook (2026 DevOps/SRE)
This commit is contained in:
commit
84be3e5d77
64 files changed
+1382
No files matched your search
@@ -0,0 +1,27 @@
|
||||
package patterns
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestFunctionalOptions(t *testing.T) {
|
||||
c := NewClient(WithTimeout(2*time.Second), WithRetries(5))
|
||||
if c.Timeout != 2*time.Second || c.Retries != 5 {
|
||||
t.Fatalf("unexpected client: %+v", c)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorkerPool(t *testing.T) {
|
||||
results := RunWorkerPool(3, []int{1, 2, 3, 4, 5}, func(x int) int { return x * 10 })
|
||||
if len(results) != 5 {
|
||||
t.Fatalf("expected 5 results, got %d", len(results))
|
||||
}
|
||||
sum := 0
|
||||
for _, r := range results {
|
||||
sum += r
|
||||
}
|
||||
if sum != 150 {
|
||||
t.Fatalf("got sum %d, want 150", sum)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user