Skip to content

Commit

Permalink
Fix setup
Browse files Browse the repository at this point in the history
  • Loading branch information
pnwpedro committed Nov 13, 2024
1 parent 7b53903 commit aff6df2
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 34 deletions.
26 changes: 12 additions & 14 deletions .github/workflows/pr_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,22 @@ jobs:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Install Fauna CLI
run: npm install -g fauna-shell
- name: Push schema
run: |
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Push Schema and Test
run: |
fauna create-database --url=http://localhost:8443 --secret=secret ECommerceDotnet
FAUNA_SECRET=$(fauna create-key --url=http://localhost:8443 --secret=secret ECommerceDotnet | grep secret: | awk '{print $2}')
cat << EOF > .fauna-project
schema_directory=schema
default=local
[environment.local]
endpoint=local
database=EcommerceDotnet
database=ECommerceDotnet
EOF
cat .fauna-project
fauna create-database --url=http://localhost:8443 --secret=secret ECommerceDotnet
fauna create-key --environment='' --url=http://localhost:8443 --secret=secret EcommerceDotnet server
fauna schema push -y --url=http://localhost:8443 --secret=secret
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
fauna schema push -y --url=http://localhost:8443 --secret=$FAUNA_SECRET
fauna schema commit -y --url=http://localhost:8443 --secret=$FAUNA_SECRET
FAUNA_SECRET=$FAUNA_SECRET dotnet test --no-build --verbosity normal
2 changes: 1 addition & 1 deletion DotNetSampleApp.Tests/CustomersTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CustomersTest
[OneTimeSetUp]
public void Setup()
{
_fauna = new Client(new Configuration("secret")
_fauna = new Client(new Configuration(TestSetup.Secret)
{
Endpoint = new Uri("http://localhost:8443"),
});
Expand Down
19 changes: 0 additions & 19 deletions DotNetSampleApp.Tests/Setup.cs

This file was deleted.

38 changes: 38 additions & 0 deletions DotNetSampleApp.Tests/TestSetup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using DotNetSampleApp.Services;
using Fauna;
using NUnit.Framework;

namespace DotNetSampleApp.Tests;

[SetUpFixture]
public class TestSetup
{
public static string Secret = "";

[OneTimeSetUp]
public void SetupOnce()
{
if (Environment.GetEnvironmentVariable("FAUNA_SECRET") == null)
{
var c = new Client(new Configuration("secret")
{
Endpoint = new Uri("http://localhost:8443"),
});
Secret = c.QueryAsync<string>(Query.FQL($$"""
let k = Key.create({role: 'admin', database: 'ECommerceDotnet'})
k.secret
""")).Result.Data;
}
else
{
Secret = Environment.GetEnvironmentVariable("FAUNA_SECRET")!;
}

var client = new Client(new Configuration(Secret)
{
Endpoint = new Uri("http://localhost:8443"),
});
SeedService.Init(client);
}

}

0 comments on commit aff6df2

Please sign in to comment.