Skip to content

Commit

Permalink
feat: implement unit test for station graph
Browse files Browse the repository at this point in the history
issue: #282
  • Loading branch information
CodeBear801 committed Apr 22, 2020
1 parent c518340 commit 4ab3d8d
Show file tree
Hide file tree
Showing 3 changed files with 585 additions and 8 deletions.
8 changes: 4 additions & 4 deletions integration/service/oasis/stationgraph/node_graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,22 +268,22 @@ func generateMockNodeGraph() Graph {
return graph
}

type mockQuerier struct {
type mockQuerier4NodeGraph struct {
}

func newMockQuerier() connectivitymap.Querier {
return &mockQuerier{}
return &mockQuerier4NodeGraph{}
}

func (querier *mockQuerier) NearByStationQuery(stationID string) []*connectivitymap.QueryResult {
func (querier *mockQuerier4NodeGraph) NearByStationQuery(stationID string) []*connectivitymap.QueryResult {
if stationID == testStationID1 {
return mockStationID2QueryResult[testStationID1]
}
glog.Fatal("Un-implemented mapping key for mockStationID2QueryResult.\n")
return nil
}

func (querier *mockQuerier) GetLocation(stationID string) *nav.Location {
func (querier *mockQuerier4NodeGraph) GetLocation(stationID string) *nav.Location {
if stationID == testStationID1 {
return mockStationID2Location[testStationID1]
}
Expand Down
4 changes: 2 additions & 2 deletions integration/service/oasis/stationgraph/station_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ func NewStationGraph(currEnergyLevel, maxEnergyLevel float64, strategy chargings
func (sg *stationGraph) setStartAndEndForGraph(currEnergyLevel, maxEnergyLevel float64) bool {
startLocation := sg.querier.GetLocation(stationfindertype.OrigLocationID)
if startLocation == nil {
glog.Errorf("Failed to find %#v from Querier's GetLocation()\n", stationfindertype.OrigLocationID)
glog.Errorf("Failed to find %#v from Querier GetLocation()\n", stationfindertype.OrigLocationID)
return false
}

endLocation := sg.querier.GetLocation(stationfindertype.DestLocationID)
if startLocation == nil {
glog.Errorf("Failed to find %#v from Querier's GetLocation()\n", stationfindertype.DestLocationID)
glog.Errorf("Failed to find %#v from Querier GetLocation()\n", stationfindertype.DestLocationID)
return false
}

Expand Down
Loading

0 comments on commit 4ab3d8d

Please sign in to comment.