Skip to content
Closed
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
17 changes: 7 additions & 10 deletions src/Azure.DataApiBuilder.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.DataApiBuilder.Servic
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Configs", "Configs", "{EFA9C661-D8FD-469A-9372-284387C4BEFC}"
ProjectSection(SolutionItems) = preProject
Service\dab-config.Cosmos.json = Service\dab-config.Cosmos.json
Service\dab-config.Cosmos.overrides.example.json = Service\dab-config.Cosmos.overrides.example.json
Service\dab-config.json = Service\dab-config.json
Service\dab-config.MsSql.json = Service\dab-config.MsSql.json
Service\dab-config.MsSql.overrides.example.json = Service\dab-config.MsSql.overrides.example.json
Service\dab-config.MySql.json = Service\dab-config.MySql.json
Service\dab-config.MySql.overrides.example.json = Service\dab-config.MySql.overrides.example.json
Service\dab-config.PostgreSql.json = Service\dab-config.PostgreSql.json
Service\dab-config.PostgreSql.overrides.example.json = Service\dab-config.PostgreSql.overrides.example.json
schemas\dab.draft-01.schema.json = schemas\dab.draft-01.schema.json
..\ConfigGenerators\configGenerator.ps1 = ..\ConfigGenerators\configGenerator.ps1
..\ConfigGenerators\configGenerator.sh = ..\ConfigGenerators\configGenerator.sh
Comment on lines +11 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Visual Studio smart enough to know which of these to run per platform? or do both attempt to run?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, are these just file references for what is in the solution? I'm not recognizing why these lines are added to this file/what the significance is.

..\ConfigGenerators\CosmosCommands.txt = ..\ConfigGenerators\CosmosCommands.txt
..\schemas\dab.draft.schema.json = ..\schemas\dab.draft.schema.json
..\ConfigGenerators\MsSqlCommands.txt = ..\ConfigGenerators\MsSqlCommands.txt
..\ConfigGenerators\MySqlCommands.txt = ..\ConfigGenerators\MySqlCommands.txt
..\ConfigGenerators\PostgreSqlCommands.txt = ..\ConfigGenerators\PostgreSqlCommands.txt
Service\schema.gql = Service\schema.gql
EndProjectSection
EndProject
Expand Down
15 changes: 8 additions & 7 deletions src/Cli/test/EndToEndTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ public void TestUpdateEntity()
Assert.AreEqual("{\"id\":\"identity\",\"name\":\"Company Name\"}", JsonSerializer.Serialize(entity.Mappings));
}

// <summary>
// Test to verify the engine gets started using start command
// </summary>
/// <summary>
/// Test to verify the engine starts with the right log level using start command
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Test to verify the engine starts with the right log level using start command
/// Test to verify the engine starts with the log level specified in the start command

This is what is meant, yes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly! Will update

/// </summary>
[DataTestMethod]
[DataRow("", true, false, DisplayName = "No logging from command line.")]
[DataRow("--verbose", true, false, DisplayName = "Verbose logging from command line.")]
Expand All @@ -302,13 +302,14 @@ public void TestUpdateEntity()
[DataRow("--LogLevel eRROR", false, true, DisplayName = "Case sensitivity: LogLevel Error from command line.")]
[DataRow("--LogLevel CrItIcal", false, true, DisplayName = "Case sensitivity: LogLevel Critical from command line.")]
[DataRow("--LogLevel NONE", false, true, DisplayName = "Case sensitivity: LogLevel None from command line.")]
public void TestStartEngine(string logging, bool useDefaultConfig, bool expectSuccess)
public void TestStartEngine(string logging, bool useInvalidConfig, bool expectSuccess)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add parameter comments to the test summary?

  • Define how useInvalidConfig is relevant to testing the logging level detected during startup

{
string configFileName;
if (useDefaultConfig)
if (useInvalidConfig)
{
// default config contains empty connection-string
configFileName = RuntimeConfigPath.DefaultName;
// Invalid config with an empty connection string.
configFileName = InvalidConfigFileName;
WriteJsonContentToFile(configFileName, CONFIG_WTIH_INVALID_CONNECTION_STRING);
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions src/Cli/test/InitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void MssqlDatabase()

_basicRuntimeConfig =
@"{
""$schema"": ""dab.draft-01.schema.json"",
""$schema"": ""dab.draft.schema.json"",
""data-source"": {
""database-type"": ""mssql"",
""connection-string"": ""testconnectionstring""
Expand Down Expand Up @@ -67,7 +67,7 @@ public void TestInitializingConfigWithoutConnectionString()

_basicRuntimeConfig =
@"{
""$schema"": ""dab.draft-01.schema.json"",
""$schema"": ""dab.draft.schema.json"",
""data-source"": {
""database-type"": ""mssql"",
""connection-string"": """"
Expand Down Expand Up @@ -104,7 +104,7 @@ public void CosmosDatabase()
devModeDefaultAuth: null);

_basicRuntimeConfig = @"{
""$schema"": ""dab.draft-01.schema.json"",
""$schema"": ""dab.draft.schema.json"",
""data-source"": {
""database-type"": ""cosmos"",
""connection-string"": ""testconnectionstring""
Expand Down
53 changes: 51 additions & 2 deletions src/Cli/test/TestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ public static class TestHelper
// Config file name for tests
public static string _testRuntimeConfig = "dab-config-test.json";

// Name of an invalid config file that can be used for tests.
public static string InvalidConfigFileName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elaborate in comment what you are trying to achieve with an invalid config file name.

  • Are you trying to get the engine to start without a config file and if so, could the same behavior be achieved by using option --config with no value?

{
get
{
return "dab-config.invalid.json";
}
Comment on lines +11 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason you chose property/getter vs. constant?

SO discussion ( just for consideration, I'm not suggesting one implementation vs. another)

}

/// <summary>
/// Adds the entity properties to the configuration and returns the updated configuration json as a string.
/// </summary>
Expand Down Expand Up @@ -49,13 +58,25 @@ public static Process StartDabProcess(string command, string flags)
}

public const string SAMPLE_SCHEMA_DATA_SOURCE = @"
""$schema"": ""dab.draft-01.schema.json"",
""$schema"": ""dab.draft.schema.json"",
""data-source"": {
""database-type"": ""mssql"",
""connection-string"": ""testconnectionstring""
}
";

/// <summary>
/// Sample data source element with an empty connection string.
/// Used for generating an invalid config for tests.
/// </summary>
public const string SAMPLE_SCHEMA_DATA_SOURCE_WITH_EMPTY_CONNSTRING = @"
""$schema"": ""dab.draft.schema.json"",
""data-source"": {
""database-type"": ""mssql"",
""connection-string"": """"
}
";

public const string INITIAL_CONFIG =
"{" +
SAMPLE_SCHEMA_DATA_SOURCE + "," +
Expand Down Expand Up @@ -113,6 +134,34 @@ public static Process StartDabProcess(string command, string flags)
""entities"": {}" +
"}";

/// <summary>
/// Initial config with an empty connection string
/// </summary>
public const string CONFIG_WTIH_INVALID_CONNECTION_STRING = "{" +
SAMPLE_SCHEMA_DATA_SOURCE_WITH_EMPTY_CONNSTRING + "," +
@"
""runtime"": {
""rest"": {
""path"": ""/api""
},
""graphql"": {
""path"": ""/graphql"",
""allow-introspection"": true
},
""host"": {
""mode"": ""development"",
""cors"": {
""origins"": [],
""allow-credentials"": false
},
""authentication"": {
""provider"": ""StaticWebApps""
}
}
},
""entities"": {}" +
"}";

public const string SINGLE_ENTITY = @"
{
""entities"": {
Expand Down Expand Up @@ -318,7 +367,7 @@ public static Process StartDabProcess(string command, string flags)

public const string CONFIG_WITH_SINGLE_ENTITY = @"
{
""$schema"": ""dab.draft-01.schema.json"",
""$schema"": ""dab.draft.schema.json"",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use the const that you defined elsewhere in this PR: SCHEMA ?

""data-source"": {
""database-type"": ""mssql"",
""connection-string"": ""localhost:5000""
Expand Down
2 changes: 1 addition & 1 deletion src/Config/RuntimeConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public record RuntimeConfig(
Dictionary<string, Entity> Entities)
{
public const string SCHEMA_PROPERTY_NAME = "$schema";
public const string SCHEMA = "dab.draft-01.schema.json";
public const string SCHEMA = "dab.draft.schema.json";

// use camel case
// convert Enum to strings
Expand Down
2 changes: 1 addition & 1 deletion src/Service.Tests/Configuration/ConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ public void VerifyExceptionOnNullModelinFilterParser()
public void TestReadingRuntimeConfig()
{
Mock<ILogger> logger = new();
string jsonString = File.ReadAllText(RuntimeConfigPath.DefaultName);
string jsonString = File.ReadAllText($"{RuntimeConfigPath.CONFIGFILE_NAME}." + $"{COSMOS_ENVIRONMENT}{RuntimeConfigPath.CONFIG_EXTENSION}");
RuntimeConfig.TryGetDeserializedRuntimeConfig(jsonString, out RuntimeConfig runtimeConfig, logger.Object);
Assert.IsNotNull(runtimeConfig.Schema);
Assert.IsInstanceOfType(runtimeConfig.DataSource, typeof(DataSource));
Expand Down
2 changes: 1 addition & 1 deletion src/Service.Tests/Configuration/CorsUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class CorsUnitTests
public void TestCorsConfigReadCorrectly()
{
Mock<ILogger> logger = new();
string jsonString = File.ReadAllText(RuntimeConfigPath.DefaultName);
string jsonString = File.ReadAllText($"{RuntimeConfigPath.CONFIGFILE_NAME}." + $"{TestCategory.COSMOS}{RuntimeConfigPath.CONFIG_EXTENSION}");
RuntimeConfig.TryGetDeserializedRuntimeConfig(jsonString, out RuntimeConfig runtimeConfig, logger.Object);
HostGlobalSettings hostGlobalSettings =
JsonSerializer.Deserialize<HostGlobalSettings>(
Expand Down
2 changes: 1 addition & 1 deletion src/Service.Tests/Unittests/RestServiceUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Azure.DataApiBuilder.Service.Tests.UnitTests
public class RestServiceUnitTests
{
private static RestService _restService;
private static string _testCategory = "mssql";
private static string _testCategory = "MsSql";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this variable necessary? could you use TestCategory.MSSQL instead of _testCategory ?


#region Positive Cases

Expand Down
10 changes: 0 additions & 10 deletions src/Service/Azure.DataApiBuilder.Service.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@
<Watch Include="**\*.json;**\*.gql" Exclude="obj\**\*;bin\**\*" />
</ItemGroup>


<ItemGroup>
<Watch Remove="dab-config.Cosmos.json" />
<Watch Remove="dab-config.json" />
<Watch Remove="dab-config.MsSql.json" />
<Watch Remove="dab-config.MySql.json" />
<Watch Remove="dab-config.PostgreSql.json" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="HotChocolate" Version="$(HotChocolateVersion)" />
<PackageReference Include="HotChocolate.AspNetCore" Version="$(HotChocolateVersion)" />
Expand Down
Loading