testhelper

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayOfMapsToCSV

func ArrayOfMapsToCSV(arr []map[string]any, targetCSVFile string) error

ArrayOfMapsToCSV converts an array of maps into a CSV file

func PrepareMockMobilityDBMockFromGTFSYMLs

func PrepareMockMobilityDBMockFromGTFSYMLs(
	mapSourceIDToYMLSpecfilepath map[int]string,
) (string, []string, error)

PrepareMockMobilityDBMockFromGTFSYML prepares a mock Mobility DB CSV that references a dynamically created GTFS zip mock from the input YML file passed as param. The output CSV can be treated as a input for Mobsql etc. in place of where Mobsql typical ingests the Mobility CSV from Mobility DB's bit.ly upstream URL.

The YML file input is structured in a way to simply and concisely represent GTFS for the purpose of mocking out tests. The top level key is the ZIP archive contents filename, and each value is an array of object values that will be converted to CSV entries in the DB mock.

Example YML input file might look like:

agency.txt:
  - {agency_id: fooagency, agency_name: foo agency, agency_url: http://foo.com}

stops.txt:
  - { stop_id: 101, stop_name: "foostop", stop_lat: 40.889248, stop_lon: -73.898583, parent_station: 101N }
  - { stop_id: 101N, stop_name: "foostop", stop_lat: 40.889248, stop_lon: -73.898583, parent_station: 101 }

stop_times.txt:
  - { trip_id: trip_wk_foo_up, stop_id: 101N, stop_sequence: 1, arrival_time: 00:06:00, departure_time: 00:06:00 }
  - { trip_id: trip_wk_foo_up, stop_id: 101N, stop_sequence: 3, arrival_time: 00:07:00, departure_time: 00:07:00 }

func YMLToCSVZip

func YMLToCSVZip(yamlFilepath string) (string, error)

YMLToCSVZip takes a YML filepath as input with YML sepcification for a ZIP of CSVs looking like:

foo.csv:

  • { bar: baz, bil: bin }
  • { bar: baz, bil: bin }

bar.csv:

  • { bar: baz, bil: bin }
  • { bar: baz, bil: bin }

And writes out a ZIP archive with the corresponding files of CSVs. For example in the above sample, 2 CSV files would be in the ZIP (foo.csv, and bar.csv) each with 2 rows.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL