Skip to content

Support for additional AQL/Query endpoints #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,83 @@ await _fixture.AqlFunctionClient.GetAqlFunctionsAsync(
Assert.Equal("function (celsius) { return celsius * 1.8 + 32; }", firstResult.Code);
Assert.True(firstResult.IsDeterministic);
}


[Fact]
public async Task GetSlowAqlQueriesAsync_ShouldSucceed()
{
var getResponse =
await _fixture.AqlFunctionClient.GetSlowAqlQueriesAsync();

//Assert.False(getResponse.Error);
//Assert.Equal(HttpStatusCode.OK, getResponse.Code);
}

[Fact]
public async Task DeleteClearSlowAqlQueriesAsync_ShouldSucceed()
{
ResponseBase deleteResponse =
await _fixture.AqlFunctionClient.DeleteClearSlowAqlQueriesAsync();

Assert.False(deleteResponse.Error);
Assert.Equal(HttpStatusCode.OK, deleteResponse.Code);
}


[Fact]
public async Task PostExplainAqlQueryAsync_ShouldSucceed()
{
PostExplainAqlQueryResponse response =
await _fixture.AqlFunctionClient.PostExplainAqlQueryAsync(
new PostExplainAqlQueryBody()
{
Query = _fixture.TestAqlQuery
});
Assert.False(response.Error);
Assert.Equal(HttpStatusCode.OK, response.Code);
}


[Fact]
public async Task PostParseAqlQueryAsync_ShouldSucceed()
{
PostParseAqlQueryResponse response =
await _fixture.AqlFunctionClient.PostParseAqlQueryAsync(
new PostParseAqlQueryBody()
{
Query = _fixture.TestAqlQuery
});
Assert.False(response.Error);
Assert.Equal(HttpStatusCode.OK, response.Code);
}

[Fact]
public async Task GetQueryTrackingConfigurationAsync_ShouldSucceed()
{
QueryTrackingConfiguration getResponse =
await _fixture.AqlFunctionClient.GetQueryTrackingConfigurationAsync();

Assert.False(getResponse.Error);
Assert.Equal(HttpStatusCode.OK, getResponse.Code);
}


[Fact]
public async Task PutChangeQueryTrackingConfigurationAsync_ShouldSucceed()
{
var getResponse =
await _fixture.AqlFunctionClient.GetQueryTrackingConfigurationAsync();

QueryTrackingConfiguration putResponse =
await _fixture.AqlFunctionClient.PutChangeQueryTrackingConfigurationAsync(
new PutChangeQueryTrackingConfigurationBody()
{
Properties = getResponse
}
);

Assert.False(putResponse.Error);
Assert.Equal(HttpStatusCode.OK, putResponse.Code);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using ArangoDBNetStandard.AqlFunctionApi;
using ArangoDBNetStandard;
using ArangoDBNetStandard.CollectionApi.Models;
using ArangoDBNetStandard.AqlFunctionApi;
using System;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace ArangoDBNetStandardTest.AqlFunctionApi
{
Expand All @@ -9,16 +13,61 @@ namespace ArangoDBNetStandardTest.AqlFunctionApi
public class AqlFunctionApiClientTestFixture : ApiClientTestFixtureBase
{
public AqlFunctionApiClient AqlFunctionClient { get; set; }
public string TestCollectionName { get; internal set; } = "Pets";
public string TestAqlQuery { get; internal set; }

public override async Task InitializeAsync()
{
await base.InitializeAsync();

string dbName = nameof(AqlFunctionApiClientTestFixture);

await CreateDatabase(dbName);
var arangoClient = GetArangoDBClient(dbName);
AqlFunctionClient = arangoClient.AqlFunction;

try
{
//create one collection for our tests...
var collectionRes = await arangoClient.Collection.PostCollectionAsync(
new PostCollectionBody()
{
Name = TestCollectionName
});
if (collectionRes == null)
{
throw new Exception("PostCollectionAsync failed.");
}
else if (collectionRes.Error)
{
throw new Exception("PostCollectionAsync failed. Details: " + collectionRes.Code.ToString());
}
else
{
var docRes = await arangoClient.Document.PostDocumentsAsync(
TestCollectionName,
new List<object>()
{
new { Name = "Kiko", PetType = "Dog", Breed = "German Shepherd" },
new { Name = "Bibi", PetType = "Dog", Breed = "English Cocker Spaniel" },
new { Name = "Bruno", PetType = "Dog", Breed = "Rottweiler" }
});
if (docRes == null || docRes.Count == 0)
{
throw new Exception($"PostDocumentsAsync failed. Doc count: {docRes?.Count ?? 0}");
}
else
{
TestAqlQuery = $@"FOR doc IN {TestCollectionName}
RETURN doc";

AqlFunctionClient = GetArangoDBClient(dbName).AqlFunction;
Console.WriteLine($"TestAqlQuery is: {TestAqlQuery}");
}
}
}
catch (ApiErrorException ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
}
}
}
}
Loading