normalized collections export sidebar padding and reduced the waiting time for the cron test

This commit is contained in:
Gani Georgiev
2024-02-24 21:35:03 +02:00
parent 6132fb4a03
commit a8b363ed76
34 changed files with 75 additions and 69 deletions
+33 -27
View File
@@ -211,13 +211,13 @@ func TestCronTotal(t *testing.T) {
func TestCronStartStop(t *testing.T) {
t.Parallel()
c := New()
c.SetInterval(1 * time.Second)
test1 := 0
test2 := 0
c := New()
c.SetInterval(500 * time.Millisecond)
c.Add("test1", "* * * * *", func() {
test1++
})
@@ -226,36 +226,42 @@ func TestCronStartStop(t *testing.T) {
test2++
})
expectedCalls := 3
expectedCalls := 2
// call twice Start to check if the previous ticker will be reseted
c.Start()
c.Start()
{
// call twice Start to check if the previous ticker will be reseted
c.Start()
c.Start()
time.Sleep(3250 * time.Millisecond)
time.Sleep(1 * time.Second)
// call twice Stop to ensure that the second stop is no-op
c.Stop()
c.Stop()
// call twice Stop to ensure that the second stop is no-op
c.Stop()
c.Stop()
if test1 != expectedCalls {
t.Fatalf("Expected %d test1, got %d", expectedCalls, test1)
}
if test2 != expectedCalls {
t.Fatalf("Expected %d test2, got %d", expectedCalls, test2)
if test1 != expectedCalls {
t.Fatalf("Expected %d test1, got %d", expectedCalls, test1)
}
if test2 != expectedCalls {
t.Fatalf("Expected %d test2, got %d", expectedCalls, test2)
}
}
// resume for ~5 seconds
c.Start()
time.Sleep(5250 * time.Millisecond)
c.Stop()
{
// resume for 2 seconds
c.Start()
expectedCalls += 5
time.Sleep(2 * time.Second)
if test1 != expectedCalls {
t.Fatalf("Expected %d test1, got %d", expectedCalls, test1)
}
if test2 != expectedCalls {
t.Fatalf("Expected %d test2, got %d", expectedCalls, test2)
c.Stop()
expectedCalls += 4
if test1 != expectedCalls {
t.Fatalf("Expected %d test1, got %d", expectedCalls, test1)
}
if test2 != expectedCalls {
t.Fatalf("Expected %d test2, got %d", expectedCalls, test2)
}
}
}