Skip to content

Commit

Permalink
feat: unit tests for toggle ready for review
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenWadeOddball committed Nov 14, 2024
1 parent 106e2e1 commit f401cae
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/graph/resolvers/model_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func (suite *ResolverSuite) TestModelPlanCreate() {
suite.Nil(result.ModifiedBy)
suite.Nil(result.ModifiedDts)
suite.EqualValues(models.ModelStatusPlanDraft, result.Status)
suite.Nil(result.MTOReadyForReviewBy)
suite.Nil(result.MTOReadyForReviewDts)
}

func (suite *ResolverSuite) TestModelPlanUpdate() {
Expand Down
61 changes: 61 additions & 0 deletions pkg/graph/resolvers/mto_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package resolvers

func (suite *ResolverSuite) TestMTOToggleReadyForReview() {
plan := suite.createModelPlan("plan for testing MTO mark ready for review")

markedReadyPrinc := suite.getTestPrincipal(suite.testConfigs.Store, "tester")

// don't set it
mto1, err := MTOToggleReadyForReview(suite.testConfigs.Context, suite.testConfigs.Logger,
suite.testConfigs.Principal, suite.testConfigs.Store, plan.ID, false)
suite.NoError(err)
if suite.NotNil(mto1, "mto shouldn't be nil") {
suite.Nil(mto1.ModelPlan.MTOReadyForReviewBy)
suite.Nil(mto1.ModelPlan.MTOReadyForReviewDts)
}

// mark ready for review by the tester
mto2, err2 := MTOToggleReadyForReview(suite.testConfigs.Context, suite.testConfigs.Logger,
markedReadyPrinc, suite.testConfigs.Store, plan.ID, true)
suite.NoError(err2)
if suite.NotNil(mto2, "mto shouldn't be nil") {
if suite.NotNil(mto2.ModelPlan.MTOReadyForReviewBy) {
suite.EqualValues(markedReadyPrinc.UserAccount.ID, *mto2.ModelPlan.MTOReadyForReviewBy,
"the mto should have been marked ready for review by the tester principal")
}
suite.NotNil(mto2.ModelPlan.MTOReadyForReviewDts)
}

// try to mark ready for review by the default principal
mto3, err3 := MTOToggleReadyForReview(suite.testConfigs.Context, suite.testConfigs.Logger,
markedReadyPrinc, suite.testConfigs.Store, plan.ID, true)
suite.NoError(err3)
if suite.NotNil(mto3, "mto shouldn't be nil") {
if suite.NotNil(mto3.ModelPlan.MTOReadyForReviewBy) {
suite.EqualValues(markedReadyPrinc.UserAccount.ID, *mto3.ModelPlan.MTOReadyForReviewBy,
"the mto should have been marked ready for review by the tester principal")
}
suite.NotNil(mto3.ModelPlan.MTOReadyForReviewDts)
}

// try to mark not ready for review by the default principal
mto4, err4 := MTOToggleReadyForReview(suite.testConfigs.Context, suite.testConfigs.Logger,
markedReadyPrinc, suite.testConfigs.Store, plan.ID, false)
suite.NoError(err4)
if suite.NotNil(mto4, "mto shouldn't be nil") {
suite.Nil(mto4.ModelPlan.MTOReadyForReviewBy)
suite.Nil(mto4.ModelPlan.MTOReadyForReviewDts)
}

// try to mark ready for review by the default principal
mto5, err5 := MTOToggleReadyForReview(suite.testConfigs.Context, suite.testConfigs.Logger,
markedReadyPrinc, suite.testConfigs.Store, plan.ID, true)
suite.NoError(err5)
if suite.NotNil(mto5, "mto shouldn't be nil") {
if suite.NotNil(mto5.ModelPlan.MTOReadyForReviewBy) {
suite.EqualValues(markedReadyPrinc.UserAccount.ID, *mto5.ModelPlan.MTOReadyForReviewBy,
"the mto should have been marked ready for review by the default principal")
}
suite.NotNil(mto5.ModelPlan.MTOReadyForReviewDts)
}
}

0 comments on commit f401cae

Please sign in to comment.