forked from mtusi2026/mtusi2026lab3
Prepare verified laboratory 3 implementation and evidence
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package config
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestRejectsConfigurationOutsideResourceBudget(t *testing.T) {
|
||||
for _, tc := range []struct{ key, value string }{{"MAX_INFLIGHT", "0"}, {"MAX_INFLIGHT", "5"}, {"MAX_QUEUE", "-1"}, {"MAX_QUEUE", "129"}, {"QUEUE_TIMEOUT", "0s"}, {"QUEUE_TIMEOUT", "3s"}, {"MAX_BODY_BYTES", "0"}, {"MAX_BODY_BYTES", "65537"}, {"PG_MAX_CONNS", "0"}, {"PG_MAX_CONNS", "65"}, {"SESSION_TTL_SECONDS", "0"}, {"SESSION_TTL_SECONDS", "86401"}} {
|
||||
t.Run(tc.key+tc.value, func(t *testing.T) {
|
||||
t.Setenv(tc.key, tc.value)
|
||||
if _, e := Load(); e == nil {
|
||||
t.Fatal("accepted configuration beyond tested bounds")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
func TestPoolSizeIsConfigurableWithinBounds(t *testing.T) {
|
||||
t.Setenv("PG_MAX_CONNS", "1")
|
||||
cfg, e := Load()
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if cfg.MaxConns != 1 {
|
||||
t.Fatal("configured pool size ignored")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user