Skip to content

Commit

Permalink
test: update database tests to match new schema
Browse files Browse the repository at this point in the history
  • Loading branch information
jhrozek authored and rdimitrov committed Oct 6, 2023
1 parent bdb545e commit 9ff6fc0
Show file tree
Hide file tree
Showing 7 changed files with 539 additions and 200 deletions.
30 changes: 0 additions & 30 deletions database/mock/store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 25 additions & 34 deletions database/query/profile_status.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@

-- name: InsertRuleEvaluations :one
INSERT INTO rule_evaluations (
profile_id, repository_id, artifact_id, rule_type_id, entity
) VALUES ($1, $2, $3, $4, $5)
RETURNING id;

-- name: GetRuleEvaluationID :one
SELECT id FROM rule_evaluations
WHERE profile_id = $1;

-- name: UpsertRuleEvaluations :one
INSERT INTO rule_evaluations (
profile_id, repository_id, artifact_id, rule_type_id, entity
Expand Down Expand Up @@ -81,30 +71,31 @@ INNER JOIN profiles p ON p.id = ps.profile_id
WHERE p.project_id = $1;

-- name: ListRuleEvaluationsByProfileId :many
WITH eval_details AS (
SELECT
rule_eval_id,
status AS eval_status,
details AS eval_details,
last_updated AS eval_last_updated
FROM rule_details_eval
),
remediation_details AS (
SELECT
rule_eval_id,
status AS rem_status,
details AS rem_details,
last_updated AS rem_last_updated
FROM rule_details_remediate
),
alert_details AS (
SELECT
rule_eval_id,
status AS alert_status,
details AS alert_details,
last_updated AS alert_last_updated
FROM rule_details_alert
)
WITH
eval_details AS (
SELECT
rule_eval_id,
status AS eval_status,
details AS eval_details,
last_updated AS eval_last_updated
FROM rule_details_eval
),
remediation_details AS (
SELECT
rule_eval_id,
status AS rem_status,
details AS rem_details,
last_updated AS rem_last_updated
FROM rule_details_remediate
),
alert_details AS (
SELECT
rule_eval_id,
status AS alert_status,
details AS alert_details,
last_updated AS alert_last_updated
FROM rule_details_alert
)

SELECT
ed.eval_status,
Expand Down
89 changes: 25 additions & 64 deletions internal/db/profile_status.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9ff6fc0

Please sign in to comment.