Skip to content

Commit

Permalink
Add Search endpoint
Browse files Browse the repository at this point in the history
[#133191487]

Signed-off-by: Christopher Brown <[email protected]>
  • Loading branch information
cbguder authored and pivotal committed Jan 16, 2017
1 parent 75c2bcf commit 373ee8a
Show file tree
Hide file tree
Showing 4 changed files with 311 additions and 37 deletions.
65 changes: 55 additions & 10 deletions src/cred-alert/revok/revokfakes/fake_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,25 @@ type FakeServer struct {
result1 *revokpb.OrganizationCredentialCountResponse
result2 error
}
GetRepositoryCredentialCountsStub func(ctx context.Context, in *revokpb.RepositoryCredentialCountRequest) (*revokpb.RepositoryCredentialCountResponse, error)
GetRepositoryCredentialCountsStub func(context.Context, *revokpb.RepositoryCredentialCountRequest) (*revokpb.RepositoryCredentialCountResponse, error)
getRepositoryCredentialCountsMutex sync.RWMutex
getRepositoryCredentialCountsArgsForCall []struct {
ctx context.Context
in *revokpb.RepositoryCredentialCountRequest
arg1 context.Context
arg2 *revokpb.RepositoryCredentialCountRequest
}
getRepositoryCredentialCountsReturns struct {
result1 *revokpb.RepositoryCredentialCountResponse
result2 error
}
SearchStub func(*revokpb.SearchQuery, revokpb.Revok_SearchServer) error
searchMutex sync.RWMutex
searchArgsForCall []struct {
arg1 *revokpb.SearchQuery
arg2 revokpb.Revok_SearchServer
}
searchReturns struct {
result1 error
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
Expand Down Expand Up @@ -114,16 +123,16 @@ func (fake *FakeServer) GetOrganizationCredentialCountsReturns(result1 *revokpb.
}{result1, result2}
}

func (fake *FakeServer) GetRepositoryCredentialCounts(ctx context.Context, in *revokpb.RepositoryCredentialCountRequest) (*revokpb.RepositoryCredentialCountResponse, error) {
func (fake *FakeServer) GetRepositoryCredentialCounts(arg1 context.Context, arg2 *revokpb.RepositoryCredentialCountRequest) (*revokpb.RepositoryCredentialCountResponse, error) {
fake.getRepositoryCredentialCountsMutex.Lock()
fake.getRepositoryCredentialCountsArgsForCall = append(fake.getRepositoryCredentialCountsArgsForCall, struct {
ctx context.Context
in *revokpb.RepositoryCredentialCountRequest
}{ctx, in})
fake.recordInvocation("GetRepositoryCredentialCounts", []interface{}{ctx, in})
arg1 context.Context
arg2 *revokpb.RepositoryCredentialCountRequest
}{arg1, arg2})
fake.recordInvocation("GetRepositoryCredentialCounts", []interface{}{arg1, arg2})
fake.getRepositoryCredentialCountsMutex.Unlock()
if fake.GetRepositoryCredentialCountsStub != nil {
return fake.GetRepositoryCredentialCountsStub(ctx, in)
return fake.GetRepositoryCredentialCountsStub(arg1, arg2)
} else {
return fake.getRepositoryCredentialCountsReturns.result1, fake.getRepositoryCredentialCountsReturns.result2
}
Expand All @@ -138,7 +147,7 @@ func (fake *FakeServer) GetRepositoryCredentialCountsCallCount() int {
func (fake *FakeServer) GetRepositoryCredentialCountsArgsForCall(i int) (context.Context, *revokpb.RepositoryCredentialCountRequest) {
fake.getRepositoryCredentialCountsMutex.RLock()
defer fake.getRepositoryCredentialCountsMutex.RUnlock()
return fake.getRepositoryCredentialCountsArgsForCall[i].ctx, fake.getRepositoryCredentialCountsArgsForCall[i].in
return fake.getRepositoryCredentialCountsArgsForCall[i].arg1, fake.getRepositoryCredentialCountsArgsForCall[i].arg2
}

func (fake *FakeServer) GetRepositoryCredentialCountsReturns(result1 *revokpb.RepositoryCredentialCountResponse, result2 error) {
Expand All @@ -149,6 +158,40 @@ func (fake *FakeServer) GetRepositoryCredentialCountsReturns(result1 *revokpb.Re
}{result1, result2}
}

func (fake *FakeServer) Search(arg1 *revokpb.SearchQuery, arg2 revokpb.Revok_SearchServer) error {
fake.searchMutex.Lock()
fake.searchArgsForCall = append(fake.searchArgsForCall, struct {
arg1 *revokpb.SearchQuery
arg2 revokpb.Revok_SearchServer
}{arg1, arg2})
fake.recordInvocation("Search", []interface{}{arg1, arg2})
fake.searchMutex.Unlock()
if fake.SearchStub != nil {
return fake.SearchStub(arg1, arg2)
} else {
return fake.searchReturns.result1
}
}

func (fake *FakeServer) SearchCallCount() int {
fake.searchMutex.RLock()
defer fake.searchMutex.RUnlock()
return len(fake.searchArgsForCall)
}

func (fake *FakeServer) SearchArgsForCall(i int) (*revokpb.SearchQuery, revokpb.Revok_SearchServer) {
fake.searchMutex.RLock()
defer fake.searchMutex.RUnlock()
return fake.searchArgsForCall[i].arg1, fake.searchArgsForCall[i].arg2
}

func (fake *FakeServer) SearchReturns(result1 error) {
fake.SearchStub = nil
fake.searchReturns = struct {
result1 error
}{result1}
}

func (fake *FakeServer) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
Expand All @@ -158,6 +201,8 @@ func (fake *FakeServer) Invocations() map[string][][]interface{} {
defer fake.getOrganizationCredentialCountsMutex.RUnlock()
fake.getRepositoryCredentialCountsMutex.RLock()
defer fake.getRepositoryCredentialCountsMutex.RUnlock()
fake.searchMutex.RLock()
defer fake.searchMutex.RUnlock()
return fake.invocations
}

Expand Down
8 changes: 5 additions & 3 deletions src/cred-alert/revok/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import (
//go:generate counterfeiter . Server

type Server interface {
GetCredentialCounts(context.Context, *revokpb.CredentialCountRequest) (*revokpb.CredentialCountResponse, error)
GetOrganizationCredentialCounts(context.Context, *revokpb.OrganizationCredentialCountRequest) (*revokpb.OrganizationCredentialCountResponse, error)
GetRepositoryCredentialCounts(ctx context.Context, in *revokpb.RepositoryCredentialCountRequest) (*revokpb.RepositoryCredentialCountResponse, error)
revokpb.RevokServer
}

type server struct {
Expand Down Expand Up @@ -140,3 +138,7 @@ func (s *server) GetRepositoryCredentialCounts(

return response, nil
}

func (s *server) Search(*revokpb.SearchQuery, revokpb.Revok_SearchServer) error {
panic("not implemented")
}
Loading

0 comments on commit 373ee8a

Please sign in to comment.