mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2026-11-09 17:43:08 -10:00
* fix(monitor): stop busy-spinning hang monitor * test(integration): serialize dsl matcher variable case * drop serial --------- Co-authored-by: Mzack9999 <[email protected]>
41 lines
882 B
Go
41 lines
882 B
Go
package monitor
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestMonitorCompareStringSliceEqual(t *testing.T) {
|
|
value := compareStringSliceEqual([]string{"a", "b"}, []string{"b", "a"})
|
|
require.True(t, value, "could not get correct value")
|
|
|
|
value = compareStringSliceEqual([]string{"a", "c"}, []string{"b", "a"})
|
|
require.False(t, value, "could get incorrect value")
|
|
}
|
|
|
|
func TestAgentRunExitsWhenCancelled(t *testing.T) {
|
|
// Given
|
|
monitor := NewStackMonitor()
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
ticker := time.NewTicker(time.Hour)
|
|
t.Cleanup(cancel)
|
|
done := make(chan struct{})
|
|
|
|
// When
|
|
go func() {
|
|
monitor.run(ctx, ticker, func() {})
|
|
close(done)
|
|
}()
|
|
cancel()
|
|
|
|
// Then
|
|
select {
|
|
case <-done:
|
|
case <-time.After(time.Second):
|
|
require.Fail(t, "monitor goroutine did not exit after cancellation")
|
|
}
|
|
}
|