| /* |
| Copyright 2019 Google Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| https://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| */ |
| |
| package utils |
| |
| import ( |
| "net/http" |
| |
| "github.com/golang/protobuf/jsonpb" |
| ) |
| |
| // Config holds all test configuration options. |
| type Config struct { |
| BookingAllFlows bool |
| BookingHealthFlow bool |
| BookingCheckFlow bool |
| BookingBookFlow bool |
| BookingListFlow bool |
| BookingStatusFlow bool |
| BookingRescheduleFlow bool |
| BookingCancelAllBookings bool |
| BookingUseBal bool |
| |
| OrderAllFlows bool |
| OrderHealthFlow bool |
| OrderCheckFlow bool |
| OrderOrderFlow bool |
| OrderListFlow bool |
| |
| WaitlistAllFlows bool |
| WaitlistHealthFlow bool |
| WaitlistBatchGetWaitEstimatesFlow bool |
| WaitlistCreateWaitlistEntryFlow bool |
| WaitlistGetWaitlistEntryFlow bool |
| WaitlistDeleteWaitlistEntryFlow bool |
| |
| Conn *HTTPConnection |
| } |
| |
| // ShouldTestBookings determines whether any booking tests need to be run. |
| func (c *Config) ShouldTestBookings() bool { |
| return c.BookingAllFlows || |
| c.BookingHealthFlow || |
| c.BookingCheckFlow || |
| c.BookingBookFlow || |
| c.BookingListFlow || |
| c.BookingStatusFlow || |
| c.BookingRescheduleFlow || |
| c.BookingCancelAllBookings |
| } |
| |
| // ShouldTestOrders determines whether any orders tests need to be run. |
| func (c *Config) ShouldTestOrders() bool { |
| return c.OrderAllFlows || |
| c.OrderHealthFlow || |
| c.OrderCheckFlow || |
| c.OrderOrderFlow || |
| c.OrderListFlow |
| } |
| |
| // ShouldTestWaitlists determines whether any waitlist tests need to be run. |
| func (c *Config) ShouldTestWaitlists() bool { |
| return c.WaitlistAllFlows || |
| c.WaitlistHealthFlow || |
| c.WaitlistBatchGetWaitEstimatesFlow || |
| c.WaitlistCreateWaitlistEntryFlow || |
| c.WaitlistGetWaitlistEntryFlow || |
| c.WaitlistDeleteWaitlistEntryFlow |
| } |
| |
| // TestSummary contains a summary of all test results. |
| type TestSummary struct { |
| BookingTotalSlotsProcessed int |
| BookingHealthCheckSuccess bool |
| BookingHealthCheckCompleted bool |
| BookingBatchAvailabilityLookupErrors int |
| BookingBatchAvailabilityLookupSuccess int |
| BookingBatchAvailabilityLookupCompleted bool |
| BookingCheckAvailabilitySuccess int |
| BookingCheckAvailabilityErrors int |
| BookingCheckAvailabilityCompleted bool |
| BookingCreateBookingSuccess int |
| BookingCreateBookingErrors int |
| BookingCreateBookingCompleted bool |
| BookingListBookingsSuccess bool |
| BookingListBookingsCompleted bool |
| BookingGetBookingStatusSuccess int |
| BookingGetBookingStatusErrors int |
| BookingGetBookingStatusCompleted bool |
| BookingCancelBookingsSuccess int |
| BookingCancelBookingsErrors int |
| BookingCancelBookingsCompleted bool |
| BookingReschedulingSuccess bool |
| BookingReschedulingCompleted bool |
| |
| OrderTotalSlotsProcessed int |
| OrderHealthCheckSuccess bool |
| OrderHealthCheckCompleted bool |
| OrderCheckOrderFulfillabilitySuccess int |
| OrderCheckOrderFulfillabilityErrors int |
| OrderCheckOrderFulfillabilityCompleted bool |
| OrderCreateOrderSuccess int |
| OrderCreateOrderErrors int |
| OrderCreateOrderCompleted bool |
| OrderListOrdersSuccess bool |
| OrderListOrdersCompleted bool |
| |
| WaitlistTotalServicesProcessed int |
| WaitlistHealthCheckSuccess bool |
| WaitlistHealthCheckCompleted bool |
| WaitlistBatchGetWaitEstimatesSuccess int |
| WaitlistBatchGetWaitEstimatesErrors int |
| WaitlistBatchGetWaitEstimatesCompleted bool |
| WaitlistCreateWaitlistEntrySuccess int |
| WaitlistCreateWaitlistEntryErrors int |
| WaitlistCreateWaitlistEntryCompleted bool |
| WaitlistGetWaitlistEntrySuccess int |
| WaitlistGetWaitlistEntryErrors int |
| WaitlistGetWaitlistEntryCompleted bool |
| WaitlistDeleteWaitlistEntrySuccess int |
| WaitlistDeleteWaitlistEntryErrors int |
| WaitlistDeleteWaitlistEntryCompleted bool |
| } |
| |
| // HTTPConnection is a convenience struct for holding connection-related objects. |
| type HTTPConnection struct { |
| Client *http.Client |
| Credentials string |
| Marshaler *jsonpb.Marshaler |
| BaseURL string |
| } |
| |
| // GetURL computes the URL for an RPC. |
| func (h HTTPConnection) GetURL(rpcName string) string { |
| if rpcName != "" { |
| return h.BaseURL + "/v3/" + rpcName |
| } |
| return h.BaseURL |
| } |