forked from mtusi2026/mtusi2026lab3
25 lines
851 B
Go
25 lines
851 B
Go
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")
|
|
}
|
|
}
|