Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit c89f684

Browse files
rguthriemsftDavid Tesar
authored andcommitted
Final code coverage fixes (#91)
* Fixed sec vulnerability * Fixing Trips Unit Test and POI package dependencies
1 parent fe70e23 commit c89f684

6 files changed

Lines changed: 39 additions & 38 deletions

File tree

apis/poi/tests/IntegrationTests/IntegrationTests.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="2.1.1" />
10+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="2.1.3" />
1111
<PackageReference Include="Microsoft.AspNetCore.Rewrite" Version="2.1.1" />
1212
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.2" />
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
1414
<PackageReference Include="xunit" Version="2.4.0" />
15-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0">
16-
<PrivateAssets>all</PrivateAssets>
17-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
15+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0">
16+
<PrivateAssets>all</PrivateAssets>
17+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1818
</PackageReference>
1919
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
2020
</ItemGroup>

apis/poi/tests/UnitTests/UnitTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
1111
<PackageReference Include="xunit" Version="2.4.0" />
1212
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0">
1313
<PrivateAssets>all</PrivateAssets>

apis/poi/web/poi.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
<ItemGroup>
1212
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.2" />
13-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.1" />
14-
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.1.1" />
15-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.1" />
13+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.4" />
14+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.1.4" />
15+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.4" />
1616
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
1717
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
1818
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="3.0.0" />

apis/trips/tripsgo/queries.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ func updateTripPointQuery(tripPoint TripPoint) string {
349349
var formattedQuery = fmt.Sprintf(
350350
query,
351351
tripPoint.TripID,
352-
tripPoint.TripID,
353352
tripPoint.Latitude,
354353
tripPoint.Longitude,
355354
tripPoint.Speed,

apis/trips/tripsgo/test_util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func RunAPITests(t *testing.T, router *mux.Router, tests []APITestCase) {
4040
for i := 0; i < len(tests); i++ {
4141
res := testAPI(router, tests[i].Method, tests[i].URL, tests[i].Body)
4242
tests[i].ActualResponse = res.Body.String()
43-
Debug.Println(tests[i].ActualResponse)
43+
Debug.Println(tests[i].Tag + " - " + tests[i].ActualResponse)
4444
assert.Equal(t, tests[i].Status, res.Code, tests[i].Tag)
4545
Info.Println(tests[i].Tag + "- Response Code:" + strconv.Itoa(res.Code))
4646
if tests[i].ExpectedResponse != "" {

apis/trips/tripsgo/tripService_test.go

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io/ioutil"
66
"log"
77
"os"
8+
"strings"
89
"testing"
910
)
1011

@@ -145,7 +146,7 @@ var apiTestList = []APITestCase{
145146
},
146147
}
147148

148-
func TestTrip(t *testing.T) {
149+
func TestTripApis(t *testing.T) {
149150
router := NewRouter()
150151
var debug, present = os.LookupEnv("DEBUG_LOGGING")
151152

@@ -155,41 +156,40 @@ func TestTrip(t *testing.T) {
155156
// if debug env is not present or false, do not log debug output to console
156157
InitLogging(os.Stdout, ioutil.Discard, os.Stdout)
157158
}
158-
RunAPITests(t, router, apiTestList[0:4])
159+
RunAPITests(t, router, apiTestList[0:3])
159160

160-
// // setup update trip test (URL, Body, expected Response)
161-
// apiTestList[4].URL = strings.Replace(apiTestList[4].URL, "{tripID}", TripFromStr(apiTestList[3].ActualResponse).ID, 1)
162-
// apiTestList[4].Body = GetUpdateTrip(apiTestList[3].ActualResponse, apiTestList[4].Body)
163-
// apiTestList[4].ExpectedResponse = apiTestList[4].Body
161+
// setup update trip test (URL, Body, expected Response)
162+
apiTestList[3].URL = strings.Replace(apiTestList[3].URL, "{tripID}", TripFromStr(apiTestList[2].ActualResponse).ID, 1)
163+
apiTestList[3].Body = GetUpdateTrip(apiTestList[2].ActualResponse, apiTestList[3].Body)
164+
apiTestList[3].ExpectedResponse = apiTestList[3].Body
164165

165-
// // setup create trip point test
166-
// apiTestList[5].URL = strings.Replace(apiTestList[5].URL, "{tripID}", TripFromStr(apiTestList[3].ActualResponse).ID, 1)
167-
// apiTestList[5].Body = strings.Replace(apiTestList[5].Body, "{tripID}", TripFromStr(apiTestList[3].ActualResponse).ID, 1)
166+
// setup create trip point test
167+
apiTestList[4].URL = strings.Replace(apiTestList[4].URL, "{tripID}", TripFromStr(apiTestList[2].ActualResponse).ID, 1)
168+
apiTestList[4].Body = strings.Replace(apiTestList[4].Body, "{tripID}", TripFromStr(apiTestList[2].ActualResponse).ID, 1)
168169

169-
// // run update trip and create trip point tests
170-
// RunAPITests(t, router, apiTestList[4:6])
170+
// run update trip and create trip point tests
171+
RunAPITests(t, router, apiTestList[3:5])
171172

172-
// // setup update trip point test
173-
// apiTestList[6].URL = strings.Replace(apiTestList[6].URL, "{tripID}", TripFromStr(apiTestList[3].ActualResponse).ID, 1)
174-
// apiTestList[6].URL = strings.Replace(apiTestList[6].URL, "{tripPointID}", TripPointFromStr(apiTestList[5].ActualResponse).ID, 1)
175-
// apiTestList[6].Body = GetUpdateTripPoint(apiTestList[5].ActualResponse, apiTestList[6].Body)
176-
// //apiTestList[6].ExpectedResponse = apiTestList[6].Body
173+
// setup update trip point test
174+
apiTestList[5].URL = strings.Replace(apiTestList[5].URL, "{tripID}", TripFromStr(apiTestList[2].ActualResponse).ID, 1)
175+
apiTestList[5].URL = strings.Replace(apiTestList[5].URL, "{tripPointID}", TripPointFromStr(apiTestList[4].ActualResponse).ID, 1)
176+
apiTestList[5].Body = GetUpdateTripPoint(apiTestList[4].ActualResponse, apiTestList[5].Body)
177177

178-
// // setup read trip points for trip test
179-
// apiTestList[7].URL = strings.Replace(apiTestList[7].URL, "{tripID}", TripFromStr(apiTestList[3].ActualResponse).ID, 1)
178+
// setup read trip points for trip test
179+
apiTestList[6].URL = strings.Replace(apiTestList[6].URL, "{tripID}", TripFromStr(apiTestList[2].ActualResponse).ID, 1)
180180

181181
// // setup ready trip points by trip point id test
182-
// apiTestList[8].URL = strings.Replace(apiTestList[8].URL, "{tripID}", TripFromStr(apiTestList[3].ActualResponse).ID, 1)
183-
// apiTestList[8].URL = strings.Replace(apiTestList[8].URL, "{tripPointID}", TripPointFromStr(apiTestList[5].ActualResponse).ID, 1)
182+
apiTestList[7].URL = strings.Replace(apiTestList[7].URL, "{tripID}", TripFromStr(apiTestList[2].ActualResponse).ID, 1)
183+
apiTestList[7].URL = strings.Replace(apiTestList[7].URL, "{tripPointID}", TripPointFromStr(apiTestList[4].ActualResponse).ID, 1)
184184

185185
// //setup delete trip point test
186-
// apiTestList[9].URL = strings.Replace(apiTestList[9].URL, "{tripID}", TripFromStr(apiTestList[3].ActualResponse).ID, 1)
187-
// apiTestList[9].URL = strings.Replace(apiTestList[9].URL, "{tripPointID}", TripPointFromStr(apiTestList[5].ActualResponse).ID, 1)
186+
apiTestList[8].URL = strings.Replace(apiTestList[8].URL, "{tripID}", TripFromStr(apiTestList[2].ActualResponse).ID, 1)
187+
apiTestList[8].URL = strings.Replace(apiTestList[8].URL, "{tripPointID}", TripPointFromStr(apiTestList[4].ActualResponse).ID, 1)
188188

189-
// // setup delete test (URL)
190-
// apiTestList[10].URL = strings.Replace(apiTestList[10].URL, "{tripID}", TripFromStr(apiTestList[3].ActualResponse).ID, 1)
191-
// // run update test
192-
// RunAPITests(t, router, apiTestList[6:10])
189+
// setup delete test (URL)
190+
apiTestList[9].URL = strings.Replace(apiTestList[9].URL, "{tripID}", TripFromStr(apiTestList[2].ActualResponse).ID, 1)
191+
// run update test
192+
RunAPITests(t, router, apiTestList[5:10])
193193
}
194194

195195
func GetUpdateTrip(tripCreate string, tripUpdate string) string {
@@ -218,7 +218,7 @@ func GetUpdateTripPoint(tripPointCreate string, tripPointUpdate string) string {
218218
func TripFromStr(tripStr string) Trip {
219219
trip := Trip{}
220220

221-
Debug.Println(tripStr)
221+
Debug.Println("DEBUG: TripFromStr - " + tripStr)
222222

223223
errCreate := json.Unmarshal([]byte(tripStr), &trip)
224224
if errCreate != nil {
@@ -232,6 +232,8 @@ func TripFromStr(tripStr string) Trip {
232232
func TripPointFromStr(tripPointStr string) TripPoint {
233233
tripPoint := TripPoint{}
234234

235+
Debug.Println("DEBUG: TripPointFromStr - " + tripPointStr)
236+
235237
errCreate := json.Unmarshal([]byte(tripPointStr), &tripPoint)
236238
if errCreate != nil {
237239
log.Println("TripPointFromStr - Invalid trip point string")

0 commit comments

Comments
 (0)