add integration test setup for parking data

This commit is contained in:
2025-04-16 17:27:13 -07:00
parent 02e440773a
commit 7e74748139
4 changed files with 51 additions and 10 deletions

View File

@@ -3,9 +3,11 @@ import { ApolloServer } from "@apollo/server";
import { startStandaloneServer } from "@apollo/server/standalone"; import { startStandaloneServer } from "@apollo/server/standalone";
import { MergedResolvers } from "./MergedResolvers"; import { MergedResolvers } from "./MergedResolvers";
import { ServerContext } from "./ServerContext"; import { ServerContext } from "./ServerContext";
import { loadShuttleTestData, supportedIntegrationTestSystems } from "./loaders/shuttle/loadShuttleTestData"; import { loadShuttleTestData } from "./loaders/shuttle/loadShuttleTestData";
import { InterchangeSystem, InterchangeSystemBuilderArguments } from "./entities/InterchangeSystem"; import { InterchangeSystem, InterchangeSystemBuilderArguments } from "./entities/InterchangeSystem";
import { ChapmanApiBasedParkingRepositoryLoader } from "./loaders/parking/ChapmanApiBasedParkingRepositoryLoader"; import { ChapmanApiBasedParkingRepositoryLoader } from "./loaders/parking/ChapmanApiBasedParkingRepositoryLoader";
import { supportedIntegrationTestSystems } from "./loaders/supportedIntegrationTestSystems";
import { loadParkingTestData } from "./loaders/parking/loadParkingTestData";
const typeDefs = readFileSync("./schema.graphqls", "utf8"); const typeDefs = readFileSync("./schema.graphqls", "utf8");
@@ -37,6 +39,9 @@ async function main() {
// TODO: Have loading of different data for different systems in the future // TODO: Have loading of different data for different systems in the future
await loadShuttleTestData(system.shuttleRepository); await loadShuttleTestData(system.shuttleRepository);
if (system.parkingRepository) {
await loadParkingTestData(system.parkingRepository);
}
return system; return system;
} }

View File

@@ -0,0 +1,33 @@
import { ParkingGetterSetterRepository } from "../../repositories/ParkingGetterSetterRepository";
import { IParkingStructure } from "../../entities/ParkingRepositoryEntities";
const parkingStructures: IParkingStructure[] = [
{
address: "300 E Walnut, Orange, CA 92867",
capacity: 871,
spotsAvailable: 211,
coordinates: {
latitude: 33.7945513,
longitude: -117.8518707,
},
name: "Anderson Structure",
id: "1",
},
{
address: "200 W Sycamore Ave, Orange, CA 92866-1053",
capacity: 692,
spotsAvailable: 282,
coordinates: {
latitude: 33.792937,
longitude: -117.854782
},
name: "Barrera",
id: "2",
}
];
export async function loadParkingTestData(repository: ParkingGetterSetterRepository) {
await Promise.all(parkingStructures.map(async structure => {
await repository.addOrUpdateParkingStructure(structure);
}))
}

View File

@@ -1,15 +1,7 @@
// Mock data // Mock data
import { IEta, IOrderedStop, IRoute, IShuttle, IStop } from "../../entities/ShuttleRepositoryEntities"; import { IEta, IOrderedStop, IRoute, IShuttle, IStop } from "../../entities/ShuttleRepositoryEntities";
import { ShuttleGetterSetterRepository } from "../../repositories/ShuttleGetterSetterRepository"; import { ShuttleGetterSetterRepository } from "../../repositories/ShuttleGetterSetterRepository";
import { InterchangeSystemBuilderArguments } from "../../entities/InterchangeSystem"; import { supportedIntegrationTestSystems } from "../supportedIntegrationTestSystems";
export const supportedIntegrationTestSystems: InterchangeSystemBuilderArguments[] = [
{
id: "1",
name: "Chapman University",
passioSystemId: "263",
},
];
const redRoutePolylineCoordinates = [ const redRoutePolylineCoordinates = [
{ {

View File

@@ -0,0 +1,11 @@
import { InterchangeSystemBuilderArguments } from "../entities/InterchangeSystem";
import { ChapmanApiBasedParkingRepositoryLoader } from "./parking/ChapmanApiBasedParkingRepositoryLoader";
export const supportedIntegrationTestSystems: InterchangeSystemBuilderArguments[] = [
{
id: "1",
name: "Chapman University",
passioSystemId: "263",
parkingSystemId: ChapmanApiBasedParkingRepositoryLoader.id,
},
];