ScuttleBot

scuttlebot / internal / api / policies_test.go
Source Blame History 36 lines
5ac549c… lmata 1 package api
5ac549c… lmata 2
5ac549c… lmata 3 import (
5ac549c… lmata 4 "path/filepath"
5ac549c… lmata 5 "testing"
5ac549c… lmata 6 )
5ac549c… lmata 7
5ac549c… lmata 8 func TestNewPolicyStoreDefaultsBridgeTTL(t *testing.T) {
5ac549c… lmata 9 ps, err := NewPolicyStore(filepath.Join(t.TempDir(), "policies.json"), 5)
5ac549c… lmata 10 if err != nil {
5ac549c… lmata 11 t.Fatalf("NewPolicyStore() error = %v", err)
5ac549c… lmata 12 }
5ac549c… lmata 13
5ac549c… lmata 14 got := ps.Get().Bridge.WebUserTTLMinutes
5ac549c… lmata 15 if got != 5 {
5ac549c… lmata 16 t.Fatalf("default bridge ttl = %d, want 5", got)
5ac549c… lmata 17 }
5ac549c… lmata 18 }
5ac549c… lmata 19
5ac549c… lmata 20 func TestPolicyStoreSetNormalizesBridgeTTL(t *testing.T) {
5ac549c… lmata 21 ps, err := NewPolicyStore(filepath.Join(t.TempDir(), "policies.json"), 5)
5ac549c… lmata 22 if err != nil {
5ac549c… lmata 23 t.Fatalf("NewPolicyStore() error = %v", err)
5ac549c… lmata 24 }
5ac549c… lmata 25
5ac549c… lmata 26 p := ps.Get()
5ac549c… lmata 27 p.Bridge.WebUserTTLMinutes = 0
5ac549c… lmata 28 if err := ps.Set(p); err != nil {
5ac549c… lmata 29 t.Fatalf("Set() error = %v", err)
5ac549c… lmata 30 }
5ac549c… lmata 31
5ac549c… lmata 32 got := ps.Get().Bridge.WebUserTTLMinutes
5ac549c… lmata 33 if got != 5 {
5ac549c… lmata 34 t.Fatalf("normalized bridge ttl = %d, want 5", got)
5ac549c… lmata 35 }
5ac549c… lmata 36 }

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button