package postgres import ( "context" "testing" "github.com/samcharles93/archie-core/internal/domain/org" ) // TestInstanceStatusHiddenFromOrgs pins that a caller confined to an org // other than the system org reads none of the instance's status. The store // has no database: a read that reached one would panic. func TestInstanceStatusHiddenFromOrgs(t *testing.T) { s := New(nil) ctx := org.WithScope(context.Background(), "globex") for _, tt := range []struct { rpc string read func() (int, error) }{ {"ListPresence", func() (int, error) { v, err := s.ListPresence(ctx); return len(v), err }}, {"ListChannelStatus", func() (int, error) { v, err := s.ChannelStatus(ctx); return len(v), err }}, {"ListApplyStatus", func() (int, error) { v, err := s.ListApplyStatus(ctx); return len(v), err }}, {"GetConfigSnapshot", func() (int, error) { _, found, err := s.ConfigSnapshot(ctx) if found { return 1, err } return 0, err }}, } { t.Run(tt.rpc, func(t *testing.T) { if n, err := tt.read(); err != nil || n != 0 { t.Fatalf("read %d rows, err %v; want none", n, err) } }) } }