Added tests which guard the JSON of providers, the runtime, and services before source generation

This commit is contained in:
Thorsten Sommer committed 2026-11-02 18:42:28 +01:00
1 parent e954881fda
commit 9e5aee766c
31 files changed
+577 -93

No files matched your search

@@ -17,7 +17,7 @@ public sealed partial class RustService : ITokenizerStorage
{
var result = await this.http.PostAsJsonAsync("/tokenizer/validate", new {
file_path = filePath,
}, this.jsonRustSerializerOptions);
}, JSON_OPTIONS);
if (!result.IsSuccessStatusCode)
{
@@ -25,7 +25,7 @@ public sealed partial class RustService : ITokenizerStorage
return CreateUnavailableTokenizerResponse("An error occured while sending the path to the Rust framework for validation: "+result.StatusCode);
}
var response = await result.Content.ReadFromJsonAsync<TokenizerResponse>(this.jsonRustSerializerOptions);
var response = await result.Content.ReadFromJsonAsync<TokenizerResponse>(JSON_OPTIONS);
return response;
}
@@ -36,7 +36,7 @@ public sealed partial class RustService : ITokenizerStorage
var result = await this.http.PostAsJsonAsync("/tokenizer/store", new {
model_id = modelId,
file_path = filePath,
}, this.jsonRustSerializerOptions);
}, JSON_OPTIONS);
if (!result.IsSuccessStatusCode)
{
@@ -44,7 +44,7 @@ public sealed partial class RustService : ITokenizerStorage
return CreateUnavailableTokenizerResponse("An error occured while sending the path to the Rust framework for storing: "+result.StatusCode);
}
return await result.Content.ReadFromJsonAsync<TokenizerResponse>(this.jsonRustSerializerOptions);
return await result.Content.ReadFromJsonAsync<TokenizerResponse>(JSON_OPTIONS);
}
public async Task<TokenizerResponse> DeleteTokenizer(string modelId)
@@ -52,7 +52,7 @@ public sealed partial class RustService : ITokenizerStorage
this.logger!.LogInformation($"Deleting tokenizer for model '{modelId}'");
var result = await this.http.PostAsJsonAsync("/tokenizer/delete", new {
model_id = modelId,
}, this.jsonRustSerializerOptions);
}, JSON_OPTIONS);
if (!result.IsSuccessStatusCode)
{
@@ -60,7 +60,7 @@ public sealed partial class RustService : ITokenizerStorage
return CreateUnavailableTokenizerResponse("An error occured while sending the tokenizer delete request to the Rust framework: "+result.StatusCode);
}
return await result.Content.ReadFromJsonAsync<TokenizerResponse>(this.jsonRustSerializerOptions);
return await result.Content.ReadFromJsonAsync<TokenizerResponse>(JSON_OPTIONS);
}
public Task<TokenizerResponse?> GetTokenCount(AIStudio.Settings.Provider provider, string text, CancellationToken cancellationToken = default) =>
@@ -74,7 +74,7 @@ public sealed partial class RustService : ITokenizerStorage
var result = await this.http.PostAsJsonAsync("/tokenizer/count", new {
text,
tokenizer_path = tokenizerPath,
}, this.jsonRustSerializerOptions, cancellationToken);
}, JSON_OPTIONS, cancellationToken);
if (!result.IsSuccessStatusCode)
{
@@ -82,6 +82,6 @@ public sealed partial class RustService : ITokenizerStorage
return CreateUnavailableTokenizerResponse("Error while getting token count from Rust service: "+result.StatusCode);
}
return await result.Content.ReadFromJsonAsync<TokenizerResponse>(this.jsonRustSerializerOptions, cancellationToken);
return await result.Content.ReadFromJsonAsync<TokenizerResponse>(JSON_OPTIONS, cancellationToken);
}
}