Skip to content

Commit

Permalink
renamed freeze recurring schedule types to align with server
Browse files Browse the repository at this point in the history
added daily recurring schedule test
  • Loading branch information
benPearce1 committed Dec 11, 2024
1 parent 7bd692c commit a759600
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
16 changes: 8 additions & 8 deletions pkg/deploymentfreezes/deploymentfreeze.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ type TenantProjectEnvironment struct {
type RecurringScheduleType string

const (
OnceDaily RecurringScheduleType = "OnceDaily"
DaysPerWeek RecurringScheduleType = "DaysPerWeek"
DaysPerMonth RecurringScheduleType = "DaysPerMonth"
Annually RecurringScheduleType = "Annually"
Daily RecurringScheduleType = "Daily"
Weekly RecurringScheduleType = "Weekly"
Monthly RecurringScheduleType = "Monthly"
Annually RecurringScheduleType = "Annually"
)

type RecurringScheduleEndType string
Expand All @@ -40,12 +40,12 @@ type RecurringSchedule struct {
Unit int `json:"Unit"`
EndType RecurringScheduleEndType `json:"EndType"`
EndOnDate *time.Time `json:"EndOnDate,omitempty"`
EndAfterOccurrences *int `json:"EndAfterOccurrences,omitempty"`
EndAfterOccurrences int `json:"EndAfterOccurrences,omitempty"`
MonthlyScheduleType string `json:"MonthlyScheduleType,omitempty"`
DateOfMonth *string `json:"DateOfMonth,omitempty"`
DayNumberOfMonth *string `json:"DayNumberOfMonth,omitempty"`
DateOfMonth string `json:"DateOfMonth,omitempty"`
DayNumberOfMonth string `json:"DayNumberOfMonth,omitempty"`
DaysOfWeek []string `json:"DaysOfWeek,omitempty"`
DayOfWeek *string `json:"DayOfWeek,omitempty"`
DayOfWeek string `json:"DayOfWeek,omitempty"`
}

type DeploymentFreezes struct {
Expand Down
31 changes: 23 additions & 8 deletions test/e2e/deployment_freeze_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,34 +169,49 @@ func TestDeploymentFreezeRecurringSchedules(t *testing.T) {
schedule *deploymentfreezes.RecurringSchedule
validate func(*testing.T, *deploymentfreezes.DeploymentFreeze)
}{
{
name: "Daily Schedule",
schedule: &deploymentfreezes.RecurringSchedule{
Type: deploymentfreezes.Daily,
Unit: 2,
EndType: deploymentfreezes.AfterOccurrences,
EndAfterOccurrences: 5,
},
validate: func(t *testing.T, freeze *deploymentfreezes.DeploymentFreeze) {
require.Equal(t, deploymentfreezes.Daily, freeze.RecurringSchedule.Type)
require.Equal(t, deploymentfreezes.AfterOccurrences, freeze.RecurringSchedule.EndType)
require.Equal(t, 5, freeze.RecurringSchedule.EndAfterOccurrences)
require.Equal(t, 2, freeze.RecurringSchedule.Unit)
},
},
{
name: "Weekly Schedule",
schedule: &deploymentfreezes.RecurringSchedule{
Type: deploymentfreezes.DaysPerWeek,
Type: deploymentfreezes.Weekly,
Unit: 24,
EndType: deploymentfreezes.AfterOccurrences,
EndAfterOccurrences: ptr(5),
EndAfterOccurrences: 5,
DaysOfWeek: []string{"Monday", "Wednesday", "Friday"},
},
validate: func(t *testing.T, freeze *deploymentfreezes.DeploymentFreeze) {
require.Equal(t, deploymentfreezes.DaysPerWeek, freeze.RecurringSchedule.Type)
require.Equal(t, deploymentfreezes.Weekly, freeze.RecurringSchedule.Type)
require.Equal(t, []string{"Monday", "Wednesday", "Friday"}, freeze.RecurringSchedule.DaysOfWeek)
},
},
{
name: "Monthly Schedule",
schedule: &deploymentfreezes.RecurringSchedule{
Type: deploymentfreezes.DaysPerMonth,
Type: deploymentfreezes.Monthly,
Unit: 24,
EndType: deploymentfreezes.Never,
MonthlyScheduleType: "DayOfMonth",
DayOfWeek: ptr("Thursday"),
DayNumberOfMonth: ptr("1"),
DayOfWeek: "Thursday",
DayNumberOfMonth: "1",
},
validate: func(t *testing.T, freeze *deploymentfreezes.DeploymentFreeze) {
require.Equal(t, deploymentfreezes.DaysPerMonth, freeze.RecurringSchedule.Type)
require.Equal(t, deploymentfreezes.Monthly, freeze.RecurringSchedule.Type)
require.Equal(t, "DayOfMonth", freeze.RecurringSchedule.MonthlyScheduleType)
require.Equal(t, "Thursday", *freeze.RecurringSchedule.DayOfWeek)
require.Equal(t, "Thursday", freeze.RecurringSchedule.DayOfWeek)
},
},
{
Expand Down

0 comments on commit a759600

Please sign in to comment.