Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
562f3d76
Commit
562f3d76
authored
5 years ago
by
Rhys Arkins
Browse files
Options
Downloads
Patches
Plain Diff
fix(schedule): use consistent error messages
parent
6a6d646d
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/workers/branch/schedule.ts
+4
-4
4 additions, 4 deletions
lib/workers/branch/schedule.ts
test/config/__snapshots__/validation.spec.ts.snap
+3
-3
3 additions, 3 deletions
test/config/__snapshots__/validation.spec.ts.snap
with
7 additions
and
7 deletions
lib/workers/branch/schedule.ts
+
4
−
4
View file @
562f3d76
...
@@ -16,7 +16,7 @@ export function hasValidTimezone(
...
@@ -16,7 +16,7 @@ export function hasValidTimezone(
timezone
:
string
timezone
:
string
):
[
boolean
]
|
[
boolean
,
string
]
{
):
[
boolean
]
|
[
boolean
,
string
]
{
if
(
!
moment
.
tz
.
zone
(
timezone
))
{
if
(
!
moment
.
tz
.
zone
(
timezone
))
{
return
[
false
,
`Invalid timezone
:
${
timezone
}
`
];
return
[
false
,
`Invalid
schedule: Unsupported
timezone
${
timezone
}
`
];
}
}
return
[
true
];
return
[
true
];
}
}
...
@@ -39,12 +39,12 @@ export function hasValidSchedule(
...
@@ -39,12 +39,12 @@ export function hasValidSchedule(
);
);
const
parsedSchedule
=
later
.
parse
.
text
(
massagedText
);
const
parsedSchedule
=
later
.
parse
.
text
(
massagedText
);
if
(
parsedSchedule
.
error
!==
-
1
)
{
if
(
parsedSchedule
.
error
!==
-
1
)
{
message
=
`Failed to parse
schedule
"
${
scheduleText
}
"`
;
message
=
`
Invalid schedule:
Failed to parse "
${
scheduleText
}
"`
;
// It failed to parse
// It failed to parse
return
true
;
return
true
;
}
}
if
(
parsedSchedule
.
schedules
.
some
(
s
=>
s
.
m
))
{
if
(
parsedSchedule
.
schedules
.
some
(
s
=>
s
.
m
))
{
message
=
`
S
chedule "
${
scheduleText
}
" should not specify minutes`
;
message
=
`
Invalid s
chedule
:
"
${
scheduleText
}
" should not specify minutes`
;
return
true
;
return
true
;
}
}
if
(
if
(
...
@@ -52,7 +52,7 @@ export function hasValidSchedule(
...
@@ -52,7 +52,7 @@ export function hasValidSchedule(
s
=>
s
.
M
||
s
.
d
!==
undefined
||
s
.
D
||
s
.
t_a
!==
undefined
||
s
.
t_b
s
=>
s
.
M
||
s
.
d
!==
undefined
||
s
.
D
||
s
.
t_a
!==
undefined
||
s
.
t_b
)
)
)
{
)
{
message
=
`
S
chedule "
${
scheduleText
}
" has no months, days of week or time of day`
;
message
=
`
Invalid s
chedule
:
"
${
scheduleText
}
" has no months, days of week or time of day`
;
return
true
;
return
true
;
}
}
// It must be OK
// It must be OK
...
...
This diff is collapsed.
Click to expand it.
test/config/__snapshots__/validation.spec.ts.snap
+
3
−
3
View file @
562f3d76
...
@@ -41,11 +41,11 @@ Array [
...
@@ -41,11 +41,11 @@ Array [
},
},
Object {
Object {
"depName": "Configuration Error",
"depName": "Configuration Error",
"message": "Invalid schedule: \`
S
chedule \\"every 15 mins every weekday\\" should not specify minutes\`",
"message": "Invalid schedule: \`
Invalid s
chedule
:
\\"every 15 mins every weekday\\" should not specify minutes\`",
},
},
Object {
Object {
"depName": "Configuration Error",
"depName": "Configuration Error",
"message": "extends: Invalid timezone
:
Europe/Brussel",
"message": "extends: Invalid
schedule: Unsupported
timezone Europe/Brussel",
},
},
Object {
Object {
"depName": "Configuration Error",
"depName": "Configuration Error",
...
@@ -57,7 +57,7 @@ Array [
...
@@ -57,7 +57,7 @@ Array [
},
},
Object {
Object {
"depName": "Configuration Error",
"depName": "Configuration Error",
"message": "timezone: Invalid timezone
:
Asia",
"message": "timezone: Invalid
schedule: Unsupported
timezone Asia",
},
},
]
]
`;
`;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment