Skip to content

Commit

Permalink
test that empty events make it through (#414)
Browse files Browse the repository at this point in the history
quick test to make sure empty events get handled properly
  • Loading branch information
whyrusleeping authored Nov 2, 2023
2 parents 3c04f0d + 05f6268 commit 5876947
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pds/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,3 +727,7 @@ func (s *Server) UpdateUserHandle(ctx context.Context, u *User, handle string) e

return nil
}

func (s *Server) Repoman() *repomgr.RepoManager {
return s.repoman
}
38 changes: 38 additions & 0 deletions testing/integ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,41 @@ func TestDomainBans(t *testing.T) {
t.Fatal("should have failed with a 400")
}
}

func TestBGSHandleEmptyEvent(t *testing.T) {
if testing.Short() {
t.Skip("skipping BGS test in 'short' test mode")
}
assert := assert.New(t)
didr := TestPLC(t)
p1 := MustSetupPDS(t, ".tpds", didr)
p1.Run(t)

b1 := MustSetupBGS(t, didr)
b1.Run(t)

b1.tr.TrialHosts = []string{p1.RawHost()}

p1.RequestScraping(t, b1)

time.Sleep(time.Millisecond * 50)

evts := b1.Events(t, -1)
defer evts.Cancel()

bob := p1.MustNewUser(t, "bob.tpds")
fmt.Println("event 1")
e1 := evts.Next()
assert.NotNil(e1.RepoCommit)
assert.Equal(e1.RepoCommit.Repo, bob.DID())

ctx := context.TODO()
rm := p1.server.Repoman()
if err := rm.BatchWrite(ctx, 1, nil); err != nil {
t.Fatal(err)
}

e2 := evts.Next()
assert.Equal(len(e2.RepoCommit.Ops), 0)
assert.Equal(e2.RepoCommit.Repo, bob.DID())
}

0 comments on commit 5876947

Please sign in to comment.