-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: unit test for milestone solution link
- Loading branch information
1 parent
45bd047
commit 9edd27b
Showing
5 changed files
with
103 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package resolvers | ||
|
||
import ( | ||
"github.com/cms-enterprise/mint-app/pkg/models" | ||
"github.com/cms-enterprise/mint-app/pkg/storage" | ||
"github.com/samber/lo" | ||
) | ||
|
||
func (suite *ResolverSuite) TestCreateMilestoneSolutionLinks() { | ||
plan := suite.createModelPlan("plan for testing MTO create milestone solution links") | ||
commonMilestoneKey := models.MTOCommonMilestoneKeyAppSupportCon | ||
|
||
// create a milestone | ||
_ = suite.createMilestoneCommon(plan.ID, commonMilestoneKey, []models.MTOCommonSolutionKey{ | ||
models.MTOCSKCcw, | ||
models.MTOCSKApps, | ||
}) | ||
|
||
// validate the created solutions | ||
solutions, err := storage.MTOCommonSolutionGetByCommonMilestoneKeyLoader( | ||
suite.testConfigs.Store, | ||
suite.testConfigs.Logger, | ||
[]models.MTOCommonMilestoneKey{commonMilestoneKey}, | ||
) | ||
suite.NoError(err) | ||
|
||
// select the common solution keys from the common solutions using lo map | ||
commonSolutionKeys := lo.Map(solutions, func(s *models.MTOCommonSolution, index int) models.MTOCommonSolutionKey { | ||
return s.Key | ||
}) | ||
|
||
// validate that the common solution keys are created | ||
suite.Len(commonSolutionKeys, 2) | ||
suite.Contains(commonSolutionKeys, models.MTOCSKCcw) | ||
suite.Contains(commonSolutionKeys, models.MTOCSKApps) | ||
|
||
// validate that the milestone links are created | ||
milestoneSolutionLinks, err := storage.MTOMilestoneSolutionLinkGetByMilestoneID( | ||
suite.testConfigs.Store, | ||
suite.testConfigs.Logger, | ||
plan.ID, | ||
) | ||
|
||
suite.NoError(err) | ||
suite.Len(milestoneSolutionLinks, 2) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
pkg/sqlqueries/SQL/mto/milestone/get_milestone_solution_links_by_milestone_id.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
SELECT | ||
id, | ||
milestone_id, | ||
solution_id, | ||
created_by, | ||
created_dts, | ||
modified_by, | ||
modified_dts | ||
FROM mto_milestone_solution_link | ||
WHERE milestone_id = :milestone_id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters