Skip to content

Commit

Permalink
Merge pull request #28 from m-lab/sandbox-soltesz
Browse files Browse the repository at this point in the history
Prevent cached results and add test to check for error
  • Loading branch information
stephen-soltesz authored Feb 28, 2019
2 parents 5f24582 + 14aafce commit f696d30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions aeflex/aeflex.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func NewService(project string) (*Service, error) {
func (source *Service) Discover(ctx context.Context) ([]discovery.StaticConfig, error) {
// List all services.
services := 0
source.targets = []discovery.StaticConfig{}
err := source.api.ServicesPages(
ctx, func(listSvc *appengine.ListServicesResponse) error {
services += len(listSvc.Services)
Expand Down
9 changes: 9 additions & 0 deletions aeflex/aeflex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,15 @@ func TestService_Discover(t *testing.T) {
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Service.Discover() = %v, want %v", got, tt.want)
}
// Call Discover again, to verify it returns the same set of targets.
got2, err := source.Discover(tt.ctx)
if (err != nil) != tt.wantErr {
t.Errorf("Service.Discover() error = %v", err)
return
}
if !reflect.DeepEqual(got, got2) {
t.Errorf("Service.Discover() = %v, want %v", got, got2)
}
})
}
}
Expand Down

0 comments on commit f696d30

Please sign in to comment.