Skip to content

Commit

Permalink
Add tests code
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalSenn committed May 21, 2024
1 parent 9f8a1ee commit 467c019
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,17 @@ protected override JsonNode Rewrite(JsonObject obj, DefaultValueVisitorContext c
}

// when the field is null and we have a required field, initialize it
if (obj.ContainsKey(field) && obj[field] is null)
if (obj.ContainsKey(field) &&
obj[field] is null &&
requiredProperties?.Contains(field) is true)
{
var hasSchemaOrDefaults = possiblePropertySchemas
.Where(x => x.GetRequired() is { Count: > 0 })
.SingleOrNone() is not null;

if (hasSchemaOrDefaults)
{
obj[field] = new JsonObject();
}
obj[field] = propertySchema.IsArray()
? new JsonArray()
: possiblePropertySchemas
.Where(x => x.GetRequired() is { Count: > 0 })
.SingleOrNone() is not null
? new JsonObject()
: null;
}

if (obj[field] is { } elm)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private static async Task InitializeProjectAndReload(IMiddlewareContext context)

// restart the pipeline after the project is created. This way we guarantee that the
// context is fresh. We could also just reload the configuration, but this is more
// future proof.
// future-proof.
var pipeline = new ProjectInitPipeline();
var projectContext = context
.WithFeatureCollection()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
Component inputs loaded
Start loading components from project '.'
Found .NET project:'<</tmp>>/content/Confix.csproj' <</tmp>>/content/Confix.csproj
Found assembly: Confix.dll
Found assembly: Confix
Scanning assembly: Confix
Found assembly file: <</tmp>>/content/bin/Debug/net8.0/Confix.dll
Start loading components from project '.'
Loaded 0 components
No components found
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@
Component inputs loaded
Start loading components from project '.'
Found .NET project:'<</tmp>>/content/Confix.csproj' <</tmp>>/content/Confix.csproj
Found assembly: Confix.dll
Found assembly: Confix
Scanning assembly: Confix
Found assembly file: <</tmp>>/content/bin/Debug/net8.0/Confix.dll
Found manifest resource in assembly 'Confix.confix.components.test..confix.component': Confix
Found manifest resource in assembly 'Confix.confix.components.test.schema.graphql': Confix
Found manifest resource in assembly 'Confix.confix.components.test.schema.json': Confix
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--------------------------------------------------
### CLI Output
--------------------------------------------------
Configuration files of type .confixrc located at <</tmp>>/home/.confixrc
Configuration files of type .confix.solution located at <</tmp>>/content/.confix.solution
Configuration files of type .confix.solution located at <</tmp>>/content/.confix.project
Merged .confix.solution from .confixrc
Merged .confix.project from .confix.solution
Merged .confix.component from .confix.solution
Running in scope Project
Configuration loaded
Active Environment is prod
Component provider 'dotnet-package' loaded
Component inputs loaded
Start loading components from project '.'
Found .NET project:'<</tmp>>/content/Confix.csproj' <</tmp>>/content/Confix.csproj
Found assembly: Confix
Scanning assembly: Confix
Start loading components from project '.'
Loaded 0 components
No components found
Skipping IntelliJ IDEA settings file as there is no .idea folder in the solution root. Expected location: <</tmp>>/content/.idea

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
--------------------------------------------------
### CLI Output
--------------------------------------------------
Configuration files of type .confixrc located at <</tmp>>/home/.confixrc
Configuration files of type .confix.solution located at <</tmp>>/content/.confix.solution
Configuration files of type .confix.solution located at <</tmp>>/content/.confix.project
Merged .confix.solution from .confixrc
Merged .confix.project from .confix.solution
Merged .confix.component from .confix.solution
Running in scope Project
Configuration loaded
Active Environment is prod
Component detected:test <</tmp>>/content/confix/components/test/.confix.component
Configuration files of type .confixrc located at <</tmp>>/home/.confixrc
Configuration files of type .confix.solution located at <</tmp>>/content/.confix.solution
Configuration files of type .confix.solution located at <</tmp>>/content/.confix.project
Configuration files of type .confix.component located at <</tmp>>/content/confix/components/test/.confix.component
Merged .confix.solution from .confixrc
Merged .confix.project from .confix.solution
Merged .confix.component from .confix.solution
Running in scope Component
Configuration loaded
Component input 'graphql' loaded
Component input 'dotnet' loaded
Component inputs loaded
Building component...
Searching in '<</tmp>>/content/confix/components/test/schema.graphql' for GraphQL Schema
-> <</tmp>>/content/confix/components/test/schema.graphql
GraphQL Schema was found: '<</tmp>>/content/confix/components/test/schema.graphql' <</tmp>>/content/confix/components/test/schema.graphql
Replacing existing schema.json file: '<</tmp>>/content/confix/components/test/schema.json' <</tmp>>/content/confix/components/test/schema.json
Generated schema based on GraphQL Schema:'<</tmp>>/content/confix/components/test/schema.json' <</tmp>>/content/confix/components/test/schema.json
Found .NET project:'<</tmp>>/content/Confix.csproj' <</tmp>>/content/Confix.csproj
Ensuring embedded is in the csproj file '<</tmp>>/content/Confix.csproj'
EmbeddedResource '$(MSBuildProjectDirectory)/confix/components/**/*.*' already exists in the csproj file
Building component completed
Component provider 'dotnet-package' loaded
Component inputs loaded
Start loading components from project '.'
Found .NET project:'<</tmp>>/content/Confix.csproj' <</tmp>>/content/Confix.csproj
Found assembly: Confix
Scanning assembly: Confix
Found manifest resource in assembly 'Confix.confix.components.test..confix.component': Confix
Found manifest resource in assembly 'Confix.confix.components.test.schema.graphql': Confix
Found manifest resource in assembly 'Confix.confix.components.test.schema.json': Confix
Found component test in provider __LOCAL
Skipped component test because it was already discovered by dotnet-package
Start loading components from project '.'
Loaded 1 components
- @dotnet-package/test
Skipping IntelliJ IDEA settings file as there is no .idea folder in the solution root. Expected location: <</tmp>>/content/.idea

Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ type Nested {
},
"wrongType": null,
"required": null,
"array": null
"array": []
}
""");
}
Expand Down

0 comments on commit 467c019

Please sign in to comment.