-
Notifications
You must be signed in to change notification settings - Fork 289
Generating Default Config using CLI #930
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
Changes from all commits
82145bf
1cdde36
328bf89
0ef4d69
d78b500
10921b4
7434b92
b21d9c0
fc9f67f
8b0839b
ad8e3a4
9e7b5ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This is what is meant, yes?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.")] | ||||||
|
|
@@ -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) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add parameter comments to the test summary?
|
||||||
| { | ||||||
| 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 | ||||||
| { | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
|
||
| { | ||
| get | ||
| { | ||
| return "dab-config.invalid.json"; | ||
| } | ||
|
Comment on lines
+11
to
+14
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
|
|
@@ -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 + "," + | ||
|
|
@@ -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"": { | ||
|
|
@@ -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"", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you use the const that you defined elsewhere in this PR: |
||
| ""data-source"": { | ||
| ""database-type"": ""mssql"", | ||
| ""connection-string"": ""localhost:5000"" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this variable necessary? could you use |
||
|
|
||
| #region Positive Cases | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.