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,33 @@
|
||||
package audit
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCounterNoDataRace(t *testing.T) {
|
||||
var c Counter
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < 50; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
c.Inc()
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
if c.Value() != 50 {
|
||||
t.Fatalf("got %d, want 50", c.Value())
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtractBearerToken(t *testing.T) {
|
||||
if tok, ok := ExtractBearerToken("Bearer secret123"); !ok || tok != "secret123" {
|
||||
t.Fatalf("got (%q, %v), want (secret123, true)", tok, ok)
|
||||
}
|
||||
for _, bad := range []string{"Bearer ", "Basic abc", "Malformed", ""} {
|
||||
if _, ok := ExtractBearerToken(bad); ok {
|
||||
t.Errorf("expected ok=false for %q", bad)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user