Skip to content
Merged
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
4 changes: 4 additions & 0 deletions app/cdash/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ add_feature_test(/Feature/GraphQL/BuildCommandTypeTest)

add_feature_test(/Feature/GraphQL/BuildCommandOutputTypeTest)

add_feature_test(/Feature/GraphQL/UpdateTypeTest)

add_feature_test(/Feature/GraphQL/UpdateFileTypeTest)

add_feature_test(/Feature/Submission/Instrumentation/BuildInstrumentationTest)
add_feature_test(/Feature/Submission/Tests/TestXMLTest)

Expand Down
50 changes: 50 additions & 0 deletions graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,10 @@ type Build {
dynamicAnalyses(
filters: _ @filter
): [DynamicAnalysis!]! @hasMany(type: CONNECTION) @orderBy(column: "id", direction: ASC)

updates(
filters: _ @filter
): [Update!]! @belongsToMany(type: CONNECTION) @orderBy(column: "id", direction: DESC)
}


Expand Down Expand Up @@ -964,3 +968,49 @@ type DynamicAnalysisDefect {

value: Int!
}


type Update @model(class: "App\\Models\\BuildUpdate") {
"Unique primary key."
id: ID!

command: String!

type: String @filterable

status: String! @filterable

revision: String @filterable

priorRevision: String @rename(attribute: "priorrevision") @filterable

path: String @filterable

updateFiles(
filters: _ @filter
): [UpdateFile!]! @hasMany(type: CONNECTION) @orderBy(column: "id", direction: DESC)
}


type UpdateFile @model(class: "App\\Models\\BuildUpdateFile") {
"Unique primary key."
id: ID!

fileName: String @rename(attribute: "filename") @filterable

authorName: String @rename(attribute: "author") @filterable

authorEmail: String @rename(attribute: "email") @filterable

committerName: String @rename(attribute: "committer") @filterable

committerEmail: String @rename(attribute: "committeremail") @filterable

log: String

revision: String @filterable

priorRevision: String @rename(attribute: "priorrevision") @filterable

status: String! @filterable
}
12 changes: 12 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -27216,6 +27216,18 @@ parameters:
count: 1
path: tests/Feature/GraphQL/SiteTypeTest.php

-
rawMessage: 'PHPDoc tag @var with type App\Models\BuildUpdate is not subtype of type App\Models\BuildUpdate&object{pivot: Illuminate\Database\Eloquent\Relations\Pivot}.'
identifier: varTag.type
count: 1
path: tests/Feature/GraphQL/UpdateFileTypeTest.php

-
rawMessage: 'PHPDoc tag @var with type App\Models\BuildUpdate is not subtype of type App\Models\BuildUpdate&object{pivot: Illuminate\Database\Eloquent\Relations\Pivot}.'
identifier: varTag.type
count: 1
path: tests/Feature/GraphQL/UpdateTypeTest.php

-
rawMessage: Cannot access offset 0 on mixed.
identifier: offsetAccess.nonOffsetAccessible
Expand Down
136 changes: 136 additions & 0 deletions tests/Feature/GraphQL/UpdateFileTypeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?php

namespace Tests\Feature\GraphQL;

use App\Models\Build;
use App\Models\BuildUpdate;
use App\Models\BuildUpdateFile;
use App\Models\Project;
use Illuminate\Support\Str;
use Tests\TestCase;
use Tests\Traits\CreatesProjects;
use Tests\Traits\CreatesUsers;

class UpdateFileTypeTest extends TestCase
{
use CreatesProjects;
use CreatesUsers;

private Project $project;

/** @var BuildUpdate[] */
private array $updates = [];

protected function setUp(): void
{
parent::setUp();

$this->project = $this->makePublicProject();
}

protected function tearDown(): void
{
$this->project->delete();

foreach ($this->updates as $update) {
$update->delete();
}

parent::tearDown();
}

/**
* A basic test to ensure that each of the fields works
*/
public function testBasicFieldAccess(): void
{
/** @var Build $build */
$build = $this->project->builds()->create([
'name' => 'build1',
'uuid' => Str::uuid()->toString(),
]);

/** @var BuildUpdate $update */
$update = $build->updates()->create([
'command' => Str::uuid()->toString(),
'type' => 'GIT',
'status' => Str::uuid()->toString(),
'revision' => Str::uuid()->toString(),
'priorrevision' => Str::uuid()->toString(),
'path' => Str::uuid()->toString(),
]);

/** @var BuildUpdateFile $updateFile */
$updateFile = $update->updateFiles()->create([
'filename' => Str::uuid()->toString(),
'author' => Str::uuid()->toString(),
'email' => Str::uuid()->toString(),
'committer' => Str::uuid()->toString(),
'committeremail' => Str::uuid()->toString(),
'log' => Str::uuid()->toString(),
'revision' => Str::uuid()->toString(),
'priorrevision' => Str::uuid()->toString(),
'status' => 'UPDATED',
]);

$this->graphQL('
query build($id: ID) {
build(id: $id) {
updates {
edges {
node {
updateFiles {
edges {
node {
fileName
authorName
authorEmail
committerName
committerEmail
log
revision
priorRevision
status
}
}
}
}
}
}
}
}
', [
'id' => $build->id,
])->assertExactJson([
'data' => [
'build' => [
'updates' => [
'edges' => [
[
'node' => [
'updateFiles' => [
'edges' => [
[
'node' => [
'fileName' => $updateFile->filename,
'authorName' => $updateFile->author,
'authorEmail' => $updateFile->email,
'committerName' => $updateFile->committer,
'committerEmail' => $updateFile->committeremail,
'log' => $updateFile->log,
'revision' => $updateFile->revision,
'priorRevision' => $updateFile->priorrevision,
'status' => $updateFile->status,
],
],
],
],
],
],
],
],
],
],
]);
}
}
104 changes: 104 additions & 0 deletions tests/Feature/GraphQL/UpdateTypeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

namespace Tests\Feature\GraphQL;

use App\Models\Build;
use App\Models\BuildUpdate;
use App\Models\Project;
use Illuminate\Support\Str;
use Tests\TestCase;
use Tests\Traits\CreatesProjects;
use Tests\Traits\CreatesUsers;

class UpdateTypeTest extends TestCase
{
use CreatesProjects;
use CreatesUsers;

private Project $project;

/** @var BuildUpdate[] */
private array $updates = [];

protected function setUp(): void
{
parent::setUp();

$this->project = $this->makePublicProject();
}

protected function tearDown(): void
{
$this->project->delete();

foreach ($this->updates as $update) {
$update->delete();
}

parent::tearDown();
}

/**
* A basic test to ensure that each of the fields works
*/
public function testBasicFieldAccess(): void
{
/** @var Build $build */
$build = $this->project->builds()->create([
'name' => 'build1',
'uuid' => Str::uuid()->toString(),
]);

/** @var BuildUpdate $update */
$update = $build->updates()->create([
'command' => Str::uuid()->toString(),
'type' => 'GIT',
'status' => Str::uuid()->toString(),
'revision' => Str::uuid()->toString(),
'priorrevision' => Str::uuid()->toString(),
'path' => Str::uuid()->toString(),
]);

$this->graphQL('
query build($id: ID) {
build(id: $id) {
updates {
edges {
node {
id
command
type
status
revision
priorRevision
path
}
}
}
}
}
', [
'id' => $build->id,
])->assertExactJson([
'data' => [
'build' => [
'updates' => [
'edges' => [
[
'node' => [
'id' => (string) $update->id,
'command' => $update->command,
'type' => $update->type,
'status' => $update->status,
'revision' => $update->revision,
'priorRevision' => $update->priorrevision,
'path' => $update->path,
],
],
],
],
],
],
]);
}
}