diff --git a/.github/workflows/1-pr.yaml b/.github/workflows/1-pr.yaml
index c6d8f9f44..6160390bf 100644
--- a/.github/workflows/1-pr.yaml
+++ b/.github/workflows/1-pr.yaml
@@ -122,6 +122,9 @@ jobs:
directory: ${{ env.DOTNET_SRC_DIR }}
- name: Generate Open API
+ env:
+ DataSources__EmissionsDataSource: Json
+ DataSources__Configurations__Json__Type: JSON
run: dotnet tool run swagger tofile --output ./wwwroot/api/v1/swagger.yaml --yaml ${{ env.DLL_FILE_PATH }} v1
working-directory: ./src/CarbonAware.WebApi/src
@@ -144,7 +147,7 @@ jobs:
- name: Docker Run Container
run: |
- docker run -d --name runnable-container -p 8080:80 ca-api
+ docker run -d --name runnable-container -e DataSources__EmissionsDataSource=Json -e DataSources__Configurations__Json__Type=JSON -p 8080:80 ca-api
docker container ls
- name: Docker WGET Health Endpoint
@@ -244,4 +247,4 @@ jobs:
command: config
globs: |
./custom.markdownlint.jsonc
- {"*[^.github]/**,*"}.md
\ No newline at end of file
+ {"*[^.github]/**,*"}.md
diff --git a/src/CarbonAware.CLI/test/integrationTests/CarbonAware.CLI.IntegrationTests.csproj b/src/CarbonAware.CLI/test/integrationTests/CarbonAware.CLI.IntegrationTests.csproj
index 9b0dd0efe..b391e0cab 100644
--- a/src/CarbonAware.CLI/test/integrationTests/CarbonAware.CLI.IntegrationTests.csproj
+++ b/src/CarbonAware.CLI/test/integrationTests/CarbonAware.CLI.IntegrationTests.csproj
@@ -25,4 +25,12 @@
Include="..\..\..\CarbonAware.DataSources\CarbonAware.DataSources.ElectricityMapsFree\mock\CarbonAware.DataSources.ElectricityMapsFree.Mocks.csproj" />
-
\ No newline at end of file
+
+
+
+
+
+
+
diff --git a/src/CarbonAware.CLI/test/integrationTests/IntegrationTestingBase.cs b/src/CarbonAware.CLI/test/integrationTests/IntegrationTestingBase.cs
index 1ab6b9d40..120ce2f80 100644
--- a/src/CarbonAware.CLI/test/integrationTests/IntegrationTestingBase.cs
+++ b/src/CarbonAware.CLI/test/integrationTests/IntegrationTestingBase.cs
@@ -100,6 +100,7 @@ public void Setup()
{
Environment.SetEnvironmentVariable("DataSources__EmissionsDataSource", "Json");
Environment.SetEnvironmentVariable("DataSources__Configurations__Json__Type", "JSON");
+ Environment.SetEnvironmentVariable("DataSources__Configurations__Json__DataFileLocation", "test-data-azure-emissions.json");
_dataSourceMocker = new JsonDataSourceMocker();
break;
}
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/mock/JsonDataSourceMocker.cs b/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/mock/JsonDataSourceMocker.cs
index ee7bf4ba5..fb78a9ee2 100644
--- a/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/mock/JsonDataSourceMocker.cs
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/mock/JsonDataSourceMocker.cs
@@ -10,7 +10,9 @@ public JsonDataSourceMocker() { }
public void SetupDataMock(DateTimeOffset start, DateTimeOffset end, string location)
{
- string path = new JsonDataSourceConfiguration().DataFileLocation;
+ var config = new JsonDataSourceConfiguration();
+ config.DataFileLocation = "test-data-azure-emissions.json";
+ string path = config.DataFileLocation;
var data = new List();
DateTimeOffset pointTime = start;
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/src/CarbonAware.DataSources.Json.csproj b/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/src/CarbonAware.DataSources.Json.csproj
index 7c9905d41..5c9ff6c04 100644
--- a/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/src/CarbonAware.DataSources.Json.csproj
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/src/CarbonAware.DataSources.Json.csproj
@@ -7,13 +7,6 @@
false
-
-
- Always
-
-
-
@@ -24,4 +17,8 @@
-
\ No newline at end of file
+
+
+
+
+
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/src/Configuration/JsonDataSourceConfiguration.cs b/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/src/Configuration/JsonDataSourceConfiguration.cs
index 2c69e6be8..1805342b5 100644
--- a/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/src/Configuration/JsonDataSourceConfiguration.cs
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/src/Configuration/JsonDataSourceConfiguration.cs
@@ -9,7 +9,6 @@ namespace CarbonAware.DataSources.Json.Configuration;
internal class JsonDataSourceConfiguration
{
private const string BaseDirectory = "data-sources/json";
- private const string DefaultDataFile = "test-data-azure-emissions.json";
private const string DirectoryRegExPattern = @"^(?!\.{2})[-\\/a-zA-Z_\d\.: ]*$";
private string assemblyDirectory;
private string? dataFileLocation;
@@ -34,7 +33,6 @@ public JsonDataSourceConfiguration()
{
var assemblyPath = Assembly.GetExecutingAssembly().Location;
assemblyDirectory = Path.GetDirectoryName(assemblyPath)!;
- DataFileLocation = DefaultDataFile;
}
private static bool IsValidDirPath(string fileName)
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/test/JsonDataSourceConfigurationTests.cs b/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/test/JsonDataSourceConfigurationTests.cs
index f63565a73..e8d0f0cc7 100644
--- a/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/test/JsonDataSourceConfigurationTests.cs
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/test/JsonDataSourceConfigurationTests.cs
@@ -24,14 +24,6 @@ public void Setup()
AssemblyPath = Assembly.GetExecutingAssembly().Location;
}
- [Test]
- public void GetDefaultDataFileLocation_IsNotNull_ExpectedBaseDir()
- {
- Assert.That(_configuration.DataFileLocation, Is.Not.Null);
- var expectedDir = Path.Combine(Path.GetDirectoryName(AssemblyPath)!, BaseDir);
- Assert.That(_configuration.DataFileLocation, Contains.Substring(expectedDir));
- }
-
[TestCase("../newfile.json", TestName = "setting parent's dir")]
[TestCase("~/newfile.json", TestName = "setting user's home dir")]
[TestCase(null, TestName = "setting null filepath")]
diff --git a/src/CarbonAware.LocationSources/src/CarbonAware.LocationSources.csproj b/src/CarbonAware.LocationSources/src/CarbonAware.LocationSources.csproj
index d05da871e..9f7e2e214 100644
--- a/src/CarbonAware.LocationSources/src/CarbonAware.LocationSources.csproj
+++ b/src/CarbonAware.LocationSources/src/CarbonAware.LocationSources.csproj
@@ -12,16 +12,13 @@
false
-
-
- Always
-
-
-
-
\ No newline at end of file
+
+
+
+
+
diff --git a/src/CarbonAware.LocationSources/test/CarbonAware.LocationSources.Test.csproj b/src/CarbonAware.LocationSources/test/CarbonAware.LocationSources.Test.csproj
index 498ef5124..99955e0f3 100644
--- a/src/CarbonAware.LocationSources/test/CarbonAware.LocationSources.Test.csproj
+++ b/src/CarbonAware.LocationSources/test/CarbonAware.LocationSources.Test.csproj
@@ -24,4 +24,8 @@
+
+
+
+
diff --git a/src/CarbonAware.WebApi/src/Dockerfile b/src/CarbonAware.WebApi/src/Dockerfile
index bc46714fe..937227a09 100644
--- a/src/CarbonAware.WebApi/src/Dockerfile
+++ b/src/CarbonAware.WebApi/src/Dockerfile
@@ -7,6 +7,9 @@ COPY . ./
RUN dotnet publish CarbonAware.WebApi/src/CarbonAware.WebApi.csproj -c Release -o publish
# Generate OpenAPI spec
WORKDIR /app/CarbonAware.WebApi/src
+# Set environment variables for dummy datasource to start "dotnet tool run"
+ENV DataSources__EmissionsDataSource=Json
+ENV DataSources__Configurations__Json__Type=JSON
RUN dotnet tool restore && \
mkdir -p /app/publish/wwwroot/api/v1 && \
dotnet tool run swagger tofile --output /app/publish/wwwroot/api/v1/swagger.yaml --yaml /app/publish/CarbonAware.WebApi.dll v1
diff --git a/src/CarbonAware.WebApi/src/appsettings.json b/src/CarbonAware.WebApi/src/appsettings.json
index 8208b3d19..10f68b8c8 100644
--- a/src/CarbonAware.WebApi/src/appsettings.json
+++ b/src/CarbonAware.WebApi/src/appsettings.json
@@ -1,14 +1,4 @@
{
- "DataSources": {
- "EmissionsDataSource": "test-json",
- "ForecastDataSource": "", // We don't currently publish a sample test data source for forecasts.
- "Configurations": {
- "test-json": {
- "Type": "JSON",
- "DataFileLocation": "test-data-azure-emissions.json"
- }
- }
- },
"Logging": {
"LogLevel": {
"Default": "Information",
diff --git a/src/CarbonAware.WebApi/test/integrationTests/CarbonAware.WebApi.IntegrationTests.csproj b/src/CarbonAware.WebApi/test/integrationTests/CarbonAware.WebApi.IntegrationTests.csproj
index df1ed5ada..d1d7c47ad 100644
--- a/src/CarbonAware.WebApi/test/integrationTests/CarbonAware.WebApi.IntegrationTests.csproj
+++ b/src/CarbonAware.WebApi/test/integrationTests/CarbonAware.WebApi.IntegrationTests.csproj
@@ -36,6 +36,8 @@
+
-
\ No newline at end of file
+
diff --git a/src/CarbonAware.WebApi/test/integrationTests/CarbonAwareControllerTests.cs b/src/CarbonAware.WebApi/test/integrationTests/CarbonAwareControllerTests.cs
index d4954bbd6..86bf21531 100644
--- a/src/CarbonAware.WebApi/test/integrationTests/CarbonAwareControllerTests.cs
+++ b/src/CarbonAware.WebApi/test/integrationTests/CarbonAwareControllerTests.cs
@@ -15,7 +15,7 @@ namespace CarbonAware.WepApi.IntegrationTests;
[TestFixture(DataSourceType.JSON)]
[TestFixture(DataSourceType.WattTime)]
[TestFixture(DataSourceType.ElectricityMaps)]
-[TestFixture(DataSourceType.ElectricityMapsFree)]
+//[TestFixture(DataSourceType.ElectricityMapsFree)] // TODO: need to implement data source into IntegrationTestingBase.cs
class CarbonAwareControllerTests : IntegrationTestingBase
{
private readonly string healthURI = "/health";
diff --git a/src/CarbonAware.WebApi/test/integrationTests/LocationsControllerTests.cs b/src/CarbonAware.WebApi/test/integrationTests/LocationsControllerTests.cs
index 1a1fd79c1..301ab8d6c 100644
--- a/src/CarbonAware.WebApi/test/integrationTests/LocationsControllerTests.cs
+++ b/src/CarbonAware.WebApi/test/integrationTests/LocationsControllerTests.cs
@@ -12,7 +12,7 @@ namespace CarbonAware.WepApi.IntegrationTests;
[TestFixture(DataSourceType.JSON)]
[TestFixture(DataSourceType.WattTime)]
[TestFixture(DataSourceType.ElectricityMaps)]
-[TestFixture(DataSourceType.ElectricityMapsFree)]
+//[TestFixture(DataSourceType.ElectricityMapsFree)] // TODO: need to implement data source into IntegrationTestingBase.cs
class LocationsControllerTests : IntegrationTestingBase
{
private readonly string locationsURI = "/locations";
diff --git a/src/CarbonAware.WebApi/test/integrationTests/UnconfiguredWebApiTests.cs b/src/CarbonAware.WebApi/test/integrationTests/WebApiEndpointTests.cs
similarity index 77%
rename from src/CarbonAware.WebApi/test/integrationTests/UnconfiguredWebApiTests.cs
rename to src/CarbonAware.WebApi/test/integrationTests/WebApiEndpointTests.cs
index 665b3884a..6bb55dd74 100644
--- a/src/CarbonAware.WebApi/test/integrationTests/UnconfiguredWebApiTests.cs
+++ b/src/CarbonAware.WebApi/test/integrationTests/WebApiEndpointTests.cs
@@ -5,15 +5,15 @@
namespace CarbonAware.WebApi.IntegrationTests;
///
-/// Tests that the Web API starts without configuration.
+/// Tests that static Web API endpoints.
///
-[TestFixture(DataSourceType.None)]
-class UnconfiguredWebApiTests : IntegrationTestingBase
+[TestFixture(DataSourceType.JSON)]
+class WebApiEndpointTests : IntegrationTestingBase
{
private readonly string healthURI = "/health";
private readonly string fakeURI = "/fake-endpoint";
- public UnconfiguredWebApiTests(DataSourceType dataSource) : base(dataSource) { }
+ public WebApiEndpointTests(DataSourceType dataSource) : base(dataSource) { }
[Test]
public async Task HealthCheck_ReturnsOK()
diff --git a/src/GSF.CarbonAware/src/GSF.CarbonAware.csproj b/src/GSF.CarbonAware/src/GSF.CarbonAware.csproj
index f113e0b98..6d762d025 100644
--- a/src/GSF.CarbonAware/src/GSF.CarbonAware.csproj
+++ b/src/GSF.CarbonAware/src/GSF.CarbonAware.csproj
@@ -49,12 +49,13 @@
-
-
-
\ No newline at end of file
+
+
+
+
+
diff --git a/src/GSF.CarbonAware/src/GSF.CarbonAware.targets b/src/GSF.CarbonAware/src/GSF.CarbonAware.targets
index 0e9a1ace2..b0a0e8e83 100644
--- a/src/GSF.CarbonAware/src/GSF.CarbonAware.targets
+++ b/src/GSF.CarbonAware/src/GSF.CarbonAware.targets
@@ -1,24 +1,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+