Repository navigation
Expand file tree
/
Copy pathE2ETestBackendTests.cs
More file actions
80 lines (69 loc) · 2.86 KB
/
Copy pathE2ETestBackendTests.cs
File metadata and controls
80 lines (69 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
using GitHub.Copilot.Test.Harness;
using Xunit;
namespace GitHub.Copilot.Test.Unit;
public class E2ETestBackendTests
{
[Theory]
[InlineData(null, "capi")]
[InlineData("", "capi")]
[InlineData("capi", "capi")]
[InlineData("ANTHROPIC-MESSAGES", "anthropic-messages")]
[InlineData("openai-responses", "openai-responses")]
[InlineData("openai-completions", "openai-completions")]
public void ParsesBackend(string? value, string expected)
=> Assert.Equal(expected, E2ETestBackendConfiguration.Parse(value).ToWireName());
[Fact]
public void RejectsUnknownBackend()
=> Assert.Throws<ArgumentOutOfRangeException>(
() => E2ETestBackendConfiguration.Parse("unknown"));
[Theory]
[InlineData("anthropic-messages", "anthropic", null, "claude-sonnet-5")]
[InlineData("openai-responses", "openai", "responses", "gpt-4.1")]
[InlineData("openai-completions", "openai", "completions", "gpt-4.1")]
public void AppliesProvider(
string backendValue,
string expectedType,
string? expectedWireApi,
string expectedModel)
{
var backend = E2ETestBackendConfiguration.Parse(backendValue);
var config = new SessionConfig();
backend.ApplyProvider(config, "http://localhost:1234");
Assert.Equal(expectedModel, config.Model);
Assert.Equal("http://localhost:1234", config.Provider!.BaseUrl);
Assert.Equal(expectedType, config.Provider.Type);
Assert.Equal(expectedWireApi, config.Provider.WireApi);
Assert.Equal(expectedModel, config.Provider.ModelId);
Assert.Equal(expectedModel, config.Provider.WireModel);
Assert.False(string.IsNullOrEmpty(config.Provider.BearerToken));
}
[Fact]
public void PreservesExplicitModel()
{
var config = new SessionConfig { Model = "test-model" };
E2ETestBackend.OpenAIResponses.ApplyProvider(config, "http://localhost:1234");
Assert.Equal("test-model", config.Model);
Assert.Equal("test-model", config.Provider!.ModelId);
Assert.Equal("test-model", config.Provider.WireModel);
}
[Fact]
public void PreservesExplicitProvider()
{
var provider = new ProviderConfig
{
Type = "custom",
ModelId = "provider-model",
};
var config = new SessionConfig
{
Model = "session-model",
Provider = provider,
};
E2ETestBackend.OpenAIResponses.ApplyProvider(config, "http://localhost:1234");
Assert.Equal("session-model", config.Model);
Assert.Same(provider, config.Provider);
}
}