Skip to content

Commit b9e0280

Browse files
committed
Handle ArangoDB 3.12 breaking change for error code assertions in GraphApiClientTest.
1 parent b3764df commit b9e0280

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

arangodb-net-standard.Test/GraphApi/GraphApiClientTest.cs

+25-6
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,17 @@ public async Task PostVertexAsync_ShouldThrow_WhenVertexCollectionIsNotFound()
436436

437437
Assert.True(ex.ApiError.Error);
438438
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
439-
if (_fixture.VersionMajor >= 3 && _fixture.VersionMinor >= 10)
439+
440+
bool isVersion310Or311 = _fixture.VersionMajor == 3 &&
441+
(_fixture.VersionMinor == 10 || _fixture.VersionMinor == 11);
442+
443+
if (isVersion310Or311)
440444
{
441445
Assert.Equal((int)ERROR_GRAPH_REFERENCED_VERTEX_COLLECTION_NOT_USED, ex.ApiError.ErrorNum);
442446
}
443447
else
444448
{
445-
Assert.Equal((int)ERROR_ARANGO_DATA_SOURCE_NOT_FOUND, ex.ApiError.ErrorNum);
449+
AssertVertexCollectionNotFound(ex.ApiError);
446450
}
447451
}
448452

@@ -946,7 +950,7 @@ public async Task GetVertexAsync_ShouldThrow_WhenVertexCollectionIsNotFound()
946950

947951
Assert.True(ex.ApiError.Error);
948952
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
949-
Assert.Equal((int)ERROR_ARANGO_DATA_SOURCE_NOT_FOUND, ex.ApiError.ErrorNum);
953+
AssertVertexCollectionNotFound(ex.ApiError);
950954
}
951955

952956
[Fact]
@@ -1103,7 +1107,7 @@ public async Task DeleteVertexAsync_ShouldThrow_WhenVertexCollectionIsNotFound()
11031107

11041108
Assert.True(ex.ApiError.Error);
11051109
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
1106-
Assert.Equal((int)ERROR_ARANGO_DATA_SOURCE_NOT_FOUND, ex.ApiError.ErrorNum);
1110+
AssertVertexCollectionNotFound(ex.ApiError);
11071111
}
11081112

11091113
[Fact]
@@ -1256,7 +1260,7 @@ public async Task PatchVertexAsync_ShouldThrow_WhenVertexCollectionIsNotFound()
12561260

12571261
Assert.True(ex.ApiError.Error);
12581262
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
1259-
Assert.Equal((int)ERROR_ARANGO_DATA_SOURCE_NOT_FOUND, ex.ApiError.ErrorNum);
1263+
AssertVertexCollectionNotFound(ex.ApiError);
12601264
}
12611265

12621266
[Fact]
@@ -1871,7 +1875,7 @@ public async Task PutVertexAsync_ShouldThrow_WhenVertexCollectionIsNotFound()
18711875
});
18721876
Assert.True(ex.ApiError.Error);
18731877
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
1874-
Assert.Equal((int)ERROR_ARANGO_DATA_SOURCE_NOT_FOUND, ex.ApiError.ErrorNum);
1878+
AssertVertexCollectionNotFound(ex.ApiError);
18751879
}
18761880

18771881
[Fact]
@@ -1899,5 +1903,20 @@ public async Task PutVertexAsync_ShouldThrow_WhenVertexIsNotFound()
18991903
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
19001904
Assert.Equal(1202, ex.ApiError.ErrorNum); // ARANGO_DOCUMENT_NOT_FOUND
19011905
}
1906+
1907+
private void AssertVertexCollectionNotFound(ApiErrorResponse error)
1908+
{
1909+
bool isVersion312OrLater = _fixture.VersionMajor > 3 ||
1910+
(_fixture.VersionMajor == 3 && _fixture.VersionMinor >= 12);
1911+
1912+
if (isVersion312OrLater)
1913+
{
1914+
Assert.Equal((int)ERROR_GRAPH_COLLECTION_NOT_PART_OF_THE_GRAPH, error.ErrorNum);
1915+
}
1916+
else
1917+
{
1918+
Assert.Equal((int)ERROR_ARANGO_DATA_SOURCE_NOT_FOUND, error.ErrorNum);
1919+
}
1920+
}
19021921
}
19031922
}

0 commit comments

Comments
 (0)