From 025fcbb3f052e8ab6aa055a8974088839c12d5d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20W=C3=A5reus?= Date: Fri, 16 Feb 2024 13:36:48 +0100 Subject: [PATCH] add test to make sure new directory is created --- internal/fingerprint/fingerprint_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/fingerprint/fingerprint_test.go b/internal/fingerprint/fingerprint_test.go index 2456f57d..428cf03a 100644 --- a/internal/fingerprint/fingerprint_test.go +++ b/internal/fingerprint/fingerprint_test.go @@ -241,6 +241,12 @@ func TestFingerprintsToFile(t *testing.T) { outputFile: "/invalid/path/fingerprints.wfp", expectedError: true, }, + { + name: "Create non-existent directory", + setupMock: func() {}, + outputFile: "test/newfile/debricked.fingerprints.txt", + expectedError: false, + }, } for _, tt := range tests { @@ -268,6 +274,10 @@ func TestFingerprintsToFile(t *testing.T) { assert.Error(t, err) } else { assert.NoError(t, err) + + // Check if the file exists + _, err := os.Stat(filepath.Join(dir, tt.outputFile)) + assert.NoError(t, err) } }) }