Files

27 lines
816 B
Go

package authgate
import (
"context"
"testing"
)
// TestFetch_NoHoldReturnsZero exercises the early-return branch that fires
// before atproto.ResolveIdentity is called — the only Fetch path that
// stays hermetic. The other branches (authMethod switch, OAuth refresher
// check, success-path read-back) all traverse the directory singleton and
// were explicitly scoped out of unit testing; see the plan file's
// "Out of scope" section.
func TestFetch_NoHoldReturnsZero(t *testing.T) {
d := newTestDB(t)
seedUser(t, d, "did:plc:alice", "alice.test", "")
f := NewServiceAuthFetcher(d, nil, "")
exp, err := f.Fetch(context.Background(), "did:plc:alice", "")
if err != nil {
t.Fatalf("Fetch: %v", err)
}
if !exp.IsZero() {
t.Errorf("Fetch with no hold returned non-zero exp %v, want zero", exp)
}
}