snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
This commit is contained in:
141
server/pkg/scheduler/helpers_test.go
Normal file
141
server/pkg/scheduler/helpers_test.go
Normal file
@@ -0,0 +1,141 @@
|
||||
package scheduler
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestOnInterval(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
now string
|
||||
ii []string
|
||||
match bool
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
"empty",
|
||||
time.Now().Format(time.RFC3339),
|
||||
[]string{},
|
||||
false,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"nil",
|
||||
time.Now().Format(time.RFC3339),
|
||||
nil,
|
||||
false,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"next minute",
|
||||
"2019-10-10T10:11:00Z",
|
||||
[]string{"* * * * *"},
|
||||
true,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"every 5 minutes",
|
||||
"2019-10-10T10:15:00Z",
|
||||
[]string{"*/5 * * * *"},
|
||||
true,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"not full minute",
|
||||
"2019-10-10T10:15:50Z",
|
||||
[]string{"* * * * *"},
|
||||
false,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid format",
|
||||
"2019-10-10T10:15:50Z",
|
||||
[]string{":P"},
|
||||
false,
|
||||
true,
|
||||
},
|
||||
}
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
now, err := time.Parse(time.RFC3339, c.now)
|
||||
assert.NoError(t, err)
|
||||
|
||||
match, err := onInterval(now, c.ii...)
|
||||
if !c.err {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
assert.Equal(t, c.match, match)
|
||||
})
|
||||
}
|
||||
|
||||
// touch exported func
|
||||
OnInterval("* * * * *")
|
||||
OnInterval(":P")
|
||||
}
|
||||
|
||||
func TestOnTimestamp(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
now string
|
||||
ii []string
|
||||
match bool
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
"empty",
|
||||
time.Now().Format(time.RFC3339),
|
||||
[]string{},
|
||||
false,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"nil",
|
||||
time.Now().Format(time.RFC3339),
|
||||
nil,
|
||||
false,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"must match",
|
||||
"2019-10-10T10:11:00Z",
|
||||
[]string{"2019-10-10T10:11:00Z"},
|
||||
true,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"must not match",
|
||||
"2019-10-10T10:15:00Z",
|
||||
[]string{"2020-10-10T10:15:00Z"},
|
||||
false,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid format",
|
||||
"2019-10-10T10:15:00Z",
|
||||
[]string{":P"},
|
||||
false,
|
||||
true,
|
||||
},
|
||||
}
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
now, err := time.Parse(time.RFC3339, c.now)
|
||||
assert.NoError(t, err)
|
||||
|
||||
match, err := onTimestamp(now, c.ii...)
|
||||
if !c.err {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
assert.Equal(t, c.match, match)
|
||||
})
|
||||
}
|
||||
|
||||
// touch exported func
|
||||
OnTimestamp("2019-10-10T10:15:00Z")
|
||||
OnTimestamp(":P")
|
||||
}
|
||||
Reference in New Issue
Block a user