f99010fae1
Desktop Artifacts / Desktop Build (Linux) (push) Waiting to run
Desktop Artifacts / Desktop Build (Windows) (push) Waiting to run
Desktop Artifacts / Desktop Build (Linux (arm64)) (push) Waiting to run
Desktop Artifacts (macOS) / Desktop Build (macOS (aarch64)) (push) Waiting to run
Desktop Artifacts (macOS) / Desktop Build (macOS (x86_64)) (push) Waiting to run
CI / lint (push) Failing after 1s
CI / frontend (push) Failing after 1s
CI / scripts (push) Failing after 1s
CI / Go Test (ubuntu-latest) (push) Failing after 0s
CI / frontend-node-25 (push) Failing after 1s
CI / docs (push) Failing after 0s
CI / coverage (push) Failing after 0s
CI / e2e (push) Failing after 0s
Docker / build-and-push (push) Failing after 1s
CI / integration (push) Failing after 4m43s
CI / Go Test (windows-latest) (push) Has been cancelled
CI / Desktop Unit Tests (Windows) (push) Has been cancelled
36 lines
996 B
Go
36 lines
996 B
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"go.kenn.io/agentsview/internal/config"
|
|
"go.kenn.io/agentsview/internal/dbtest"
|
|
)
|
|
|
|
// TestShutdownClosesOnDemandEngine guards the lifecycle of the
|
|
// server-owned lazily-created sync engine: Shutdown must close it so
|
|
// pending debounced signal recomputes flush before the owner closes
|
|
// the DB. Injected engines are closed by their owner, not here.
|
|
func TestShutdownClosesOnDemandEngine(t *testing.T) {
|
|
database := dbtest.OpenTestDB(t)
|
|
srv := New(config.Config{
|
|
Host: "127.0.0.1",
|
|
Port: 0,
|
|
WriteTimeout: 30 * time.Second,
|
|
}, database, nil)
|
|
|
|
require.NotNil(t, srv.syncEngineForLocal(database),
|
|
"on-demand engine should be created lazily")
|
|
|
|
require.NoError(t, srv.Shutdown(context.Background()))
|
|
|
|
srv.mu.RLock()
|
|
defer srv.mu.RUnlock()
|
|
assert.Nil(t, srv.onDemandEngine,
|
|
"shutdown must close and release the on-demand engine")
|
|
}
|