From 52a84e9ec896a2bdf0081bd6a68282504b34b5fc Mon Sep 17 00:00:00 2001 From: Michael Bell Date: Fri, 22 Nov 2024 15:52:43 +0000 Subject: [PATCH] add isprocessing --- utils/types/scan_status.go | 7 +++++++ utils/types/scan_status_test.go | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/utils/types/scan_status.go b/utils/types/scan_status.go index 1c5a2f3..2b8686c 100644 --- a/utils/types/scan_status.go +++ b/utils/types/scan_status.go @@ -64,6 +64,13 @@ func (ss ScanStatus) IsWaiting() bool { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// IsProcessing returns true is the status is process +func (ss ScanStatus) IsProcessing() bool { + return ss.s == ScanStatusProcessing +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // String implements the `Stringer` interface func (ss ScanStatus) String() string { return fmt.Sprint(ss.s) diff --git a/utils/types/scan_status_test.go b/utils/types/scan_status_test.go index 937d1dd..3b394d4 100644 --- a/utils/types/scan_status_test.go +++ b/utils/types/scan_status_test.go @@ -39,6 +39,15 @@ func TestScanStatus_SetProcessing(t *testing.T) { func TestScanStatus_IsWaiting(t *testing.T) { require.True(t, NewScanStatusWaiting().IsWaiting()) require.False(t, NewScanStatusProcessing().IsWaiting()) + require.False(t, ScanStatus{}.IsWaiting()) +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +func TestScanStatus_IsProcess(t *testing.T) { + require.False(t, NewScanStatusWaiting().IsProcessing()) + require.True(t, NewScanStatusProcessing().IsProcessing()) + require.False(t, ScanStatus{}.IsProcessing()) } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~