-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
read and check for job already done from disk
- Loading branch information
1 parent
423c255
commit 5f0afc5
Showing
6 changed files
with
131 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package internal | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/DIMO-Network/edge-network/internal/models" | ||
) | ||
|
||
func TestDetermineJobDone(t *testing.T) { | ||
now := time.Now() | ||
|
||
testCases := []struct { | ||
desc string | ||
input *models.CANDumpInfo | ||
want bool | ||
}{ | ||
{ | ||
desc: "nil CANDumpInfo", | ||
input: nil, | ||
want: false, | ||
}, | ||
{ | ||
desc: "DateExecuted is older than 30 days", | ||
input: &models.CANDumpInfo{DateExecuted: now.Add(-31 * 24 * time.Hour)}, | ||
want: false, | ||
}, | ||
{ | ||
desc: "DateExecuted is equal to 30 days", | ||
input: &models.CANDumpInfo{DateExecuted: now.Add(-30 * 24 * time.Hour)}, | ||
want: true, | ||
}, | ||
{ | ||
desc: "DateExecuted is less than 30 days", | ||
input: &models.CANDumpInfo{DateExecuted: now.Add(-29 * 24 * time.Hour)}, | ||
want: true, | ||
}, | ||
} | ||
|
||
for _, tC := range testCases { | ||
t.Run(tC.desc, func(t *testing.T) { | ||
if got := determineJobDone(tC.input); got != tC.want { | ||
t.Errorf("determineJobDone() = %v, want %v for input %v", got, tC.want, tC.input) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters