Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit relationship tests prior to adding MSSQL support #3700

Merged
merged 6 commits into from
Apr 9, 2024

Conversation

Steve-Mcl
Copy link
Contributor

@Steve-Mcl Steve-Mcl commented Apr 8, 2024

Description

Explicit tests to ensure changes made to models for supporting MSSQL have no adverse affect.

Therefore it is important this PR is passing and merged before any introduction of MSSQL specific works derived from #3689

The tables that are affected by the MSSQL branch are:

  • ProjectStacks
  • ProjectTypes
  • Projects
  • DeviceGroups
  • Devices
  • ProjectSnapshots
  • PipelineStages

The tests added check every relation on these tables.

  Device model
    Relations
      ✔ should delete Device on Team delete
      ✔ should update Device.TeamId on Team.id update
      ✔ should set Device.targetSnapshotId to null when ProjectSnapshot is deleted
      ✔ should update Device.targetSnapshotId when ProjectSnapshot.id is updated
      ✔ should set Device.activeSnapshotId to null when ProjectSnapshot is deleted
      ✔ should update Device.activeSnapshotId when ProjectSnapshot.id is updated
      ✔ should set Device.ApplicationId to null when Application is deleted
      ✔ should update Device.ApplicationId on Application.id update
      ✔ should set Device.ProjectId to null when Project is deleted
      ✔ should update Device.ProjectId on Project.id update
      ✔ should set Device.DeviceGroupId to null when DeviceGroup is deleted
      ✔ should update Device.DeviceGroupId on DeviceGroup.id update

  DeviceGroup model
    Relations
      ✔ should delete DeviceGroup on Application delete
      ✔ should update DeviceGroup.ApplicationId on Application.id update
      ✔ should set DeviceGroup.targetSnapshotId to null when ProjectSnapshot is deleted
      ✔ should update DeviceGroup.targetSnapshotId when ProjectSnapshot.id is updated

  Project model
    Relations
      ✔ should delete Project on Application delete
      ✔ should update Project.ApplicationId on Application.id update
      ✔ should set Project.TeamId NULL on Team delete
      ✔ should update Project.TeamId on Team.id update
      ✔ should set Project.ProjectTypeId NULL on ProjectType delete
      ✔ should update Project.ProjectTypeId on ProjectType.id update
      ✔ should set Project.ProjectStackId NULL on ProjectStack delete
      ✔ should update Project.ProjectStackId on ProjectStack.id update
      ✔ should set Project.ProjectTemplateId NULL on ProjectTemplate delete
      ✔ should update Project.ProjectTemplateId on ProjectTemplate.id update

  ProjectSnapshot model
    Relations
      ✔ should delete ProjectSnapshot when Project is deleted
      ✔ should update ProjectSnapshot.ProjectId when Project.id is updated
      ✔ should set ProjectSnapshot.DeviceId to null when Device is deleted
      ✔ should update ProjectSnapshot.DeviceId when Device.id is updated
      ✔ should set ProjectSnapshot.UserId to null when User is deleted (100ms)
      ✔ should update ProjectSnapshot.UserId when User.id is updated (83ms)

  ProjectStack model
    Relations
      ✔ should set ProjectStack.ProjectTypeId to null when ProjectType is deleted
      ✔ should update ProjectStack.ProjectTypeId when ProjectType is updated
      ✔ should set ProjectStack.replacedBy to null when ProjectStack is deleted
      ✔ should update ProjectStack.replacedBy when ProjectStack is updated

  ProjectType model
    Relations
      ✔ should set ProjectType.defaultStackId to null when ProjectStack is deleted
      ✔ should update ProjectType.defaultStackId when ProjectStack.id is updated

  PipelineStage model
    Relations
      ✔ should set PipelineStage.NextStageId to null when PipelineStage is deleted (61ms)
      ✔ should update PipelineStage.NextStageId when PipelineStage.id is updated (82ms)
      ✔ should set PipelineStage.PipelineId to null when Pipeline is deleted
      ✔ should update PipelineStage.PipelineId when Pipeline.id is updated

Related Issue(s)

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on FlowFuse/helm to update ConfigMap Template
    • Issue/PR raised on FlowFuse/CloudProject to update values for Staging/Production

Labels

  • Backport needed? -> add the backport label
  • Includes a DB migration? -> add the area:migration label

This is ensure changes made to models for supporting MSSQL have no adverse affect
Copy link

codecov bot commented Apr 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 41.84%. Comparing base (72e7ee2) to head (7f66193).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3700      +/-   ##
==========================================
+ Coverage   41.80%   41.84%   +0.03%     
==========================================
  Files         630      630              
  Lines       24459    24459              
  Branches     5993     5993              
==========================================
+ Hits        10226    10235       +9     
+ Misses      14233    14224       -9     
Flag Coverage Δ
backend 78.64% <ø> (+0.07%) ⬆️
frontend 1.90% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Steve-Mcl Steve-Mcl linked an issue Apr 8, 2024 that may be closed by this pull request
@Steve-Mcl Steve-Mcl marked this pull request as ready for review April 8, 2024 19:17
@Steve-Mcl Steve-Mcl requested a review from hardillb April 8, 2024 19:17
Copy link
Contributor

@hardillb hardillb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just that one question

test/unit/forge/db/models/Device_spec.js Show resolved Hide resolved
@hardillb hardillb merged commit 87e37b1 into main Apr 9, 2024
10 checks passed
@hardillb hardillb deleted the 3671-db-releationship-tests branch April 9, 2024 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MS SQL Server Support preparation: targeted tests
2 participants