Documentation ¶
Overview ¶
Package testhospital contains functionality to test hospitals. It allows to create hospitals easily and run the events and messages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Arguments contains default arguments for testing. Arguments = hospital.Arguments{ DoctorsFile: &test.DoctorsConfigTest, OrderProfilesFile: &test.OrderProfilesConfigTest, PathwayArguments: &hospital.PathwayArguments{Dir: test.PathwaysDirTest, Type: "distribution"}, Hl7ConfigFile: &test.MessageConfigTest, HeaderConfigFile: &test.HeaderConfigTest, HardcodedMessagesDir: &test.HardcodedMessagesDirTest, LocationsFile: &test.LocationsConfigTest, DataFiles: &dataFilesTest, } )
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config is the configuration of a test hospital. Fields common to both Config and Arguments are taken from hospital.Config.
type Hospital ¶
type Hospital struct { *hospital.Hospital Sender *testhl7.Sender Parser *pathway.Parser PathwayManager pathway.Manager LocationManager *location.Manager MessageConfig *config.HL7Config // contains filtered or unexported fields }
Hospital represents a hospital that can be used for testing. Some of the fields this hospital is created with are exposed so that they can be accessed in the tests.
func (*Hospital) ConsumeQueues ¶
ConsumeQueues consumes all events and messages and returns the number of events that were run and the messages that were sent. ConsumeQueues fails if processing a message or an event fails. See ConsumeQueuesWithLimit for the order in which events and messages are processed.
func (*Hospital) ConsumeQueuesWithLimit ¶
func (h *Hospital) ConsumeQueuesWithLimit(ctx context.Context, t *testing.T, limit int, failIfError bool) (events int, messages []string)
ConsumeQueuesWithLimit consumes limit events and their corresponding messages, and returns the number of events that were run and the messages that were sent. Parameters:
- limit is the maximum number of events to run. All messages relevant to those events will be sent. If there are less than limit events in the queue, this method consumes the events in the queue and returns. Set <1 for no limit.
- 'failIfError' specifies whether errors running events or sending messages should make the method fail.
The order in which events and messages are processed is the following:
- Run all events that are due at the current time.
- Send all messages that are due at the current time.
- If there were no events due, advance the clock, and process any messages for that time so that we give priority to the existing messages before running new events.
- If there are still events in the queue, go back to step 1.
- After all events are consumed, process all of the remaining messages advancing the clock if needed.