mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Chore: Run integration tests without grabpl * Add new step for integration tests in lib.star * Remove old integration test step from lib.star * Change drone signature * Fix: Edit starlark integration step to not affect enterprise * Remove all build tags & rename starlark integration test step * Resync .drone.yml with .drone.star * Fix lint errors * Fix lint errors * Fix lint errors * Fix more lint errors * Fix another lint error * Rename integration test step * Fix last lint error * Recomment enterprise step * Remove comment from Makefile Co-authored-by: Ida Furjesova <ida.furjesova@grafana.com>
35 lines
837 B
Go
35 lines
837 B
Go
package serverlock
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestIntegrationServerLok(t *testing.T) {
|
|
sl := createTestableServerLock(t)
|
|
|
|
counter := 0
|
|
fn := func(context.Context) { counter++ }
|
|
atInterval := time.Hour
|
|
ctx := context.Background()
|
|
|
|
//this time `fn` should be executed
|
|
require.Nil(t, sl.LockAndExecute(ctx, "test-operation", atInterval, fn))
|
|
require.Equal(t, 1, counter)
|
|
|
|
//this should not execute `fn`
|
|
require.Nil(t, sl.LockAndExecute(ctx, "test-operation", atInterval, fn))
|
|
require.Nil(t, sl.LockAndExecute(ctx, "test-operation", atInterval, fn))
|
|
require.Equal(t, 1, counter)
|
|
|
|
atInterval = time.Millisecond
|
|
|
|
// now `fn` should be executed again
|
|
err := sl.LockAndExecute(ctx, "test-operation", atInterval, fn)
|
|
require.Nil(t, err)
|
|
require.Equal(t, 2, counter)
|
|
}
|