(t *testing.T)
| 1042 | } |
| 1043 | |
| 1044 | func TestPrebuildScheduling(t *testing.T) { |
| 1045 | t.Parallel() |
| 1046 | |
| 1047 | // The test includes 2 presets, each with 2 schedules. |
| 1048 | // It checks that the calculated actions match expectations for various provided times, |
| 1049 | // based on the corresponding schedules. |
| 1050 | testCases := []struct { |
| 1051 | name string |
| 1052 | // now specifies the current time. |
| 1053 | now time.Time |
| 1054 | // expected instances for preset1 and preset2, respectively. |
| 1055 | expectedInstances []int32 |
| 1056 | }{ |
| 1057 | { |
| 1058 | name: "Before the 1st schedule", |
| 1059 | now: mustParseTime(t, time.RFC1123, "Mon, 02 Jun 2025 01:00:00 UTC"), |
| 1060 | expectedInstances: []int32{1, 1}, |
| 1061 | }, |
| 1062 | { |
| 1063 | name: "1st schedule", |
| 1064 | now: mustParseTime(t, time.RFC1123, "Mon, 02 Jun 2025 03:00:00 UTC"), |
| 1065 | expectedInstances: []int32{2, 1}, |
| 1066 | }, |
| 1067 | { |
| 1068 | name: "2nd schedule", |
| 1069 | now: mustParseTime(t, time.RFC1123, "Mon, 02 Jun 2025 07:00:00 UTC"), |
| 1070 | expectedInstances: []int32{3, 1}, |
| 1071 | }, |
| 1072 | { |
| 1073 | name: "3rd schedule", |
| 1074 | now: mustParseTime(t, time.RFC1123, "Mon, 02 Jun 2025 11:00:00 UTC"), |
| 1075 | expectedInstances: []int32{1, 4}, |
| 1076 | }, |
| 1077 | { |
| 1078 | name: "4th schedule", |
| 1079 | now: mustParseTime(t, time.RFC1123, "Mon, 02 Jun 2025 15:00:00 UTC"), |
| 1080 | expectedInstances: []int32{1, 5}, |
| 1081 | }, |
| 1082 | } |
| 1083 | |
| 1084 | for _, tc := range testCases { |
| 1085 | t.Run(tc.name, func(t *testing.T) { |
| 1086 | t.Parallel() |
| 1087 | |
| 1088 | templateID := uuid.New() |
| 1089 | templateVersionID := uuid.New() |
| 1090 | presetOpts1 := options{ |
| 1091 | templateID: templateID, |
| 1092 | templateVersionID: templateVersionID, |
| 1093 | presetID: uuid.New(), |
| 1094 | presetName: "my-preset-1", |
| 1095 | prebuiltWorkspaceID: uuid.New(), |
| 1096 | workspaceName: "prebuilds1", |
| 1097 | } |
| 1098 | presetOpts2 := options{ |
| 1099 | templateID: templateID, |
| 1100 | templateVersionID: templateVersionID, |
| 1101 | presetID: uuid.New(), |
nothing calls this directly
no test coverage detected