-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
__main__.py: Check docker image string
This PR tests that the docker image string provided to tern is of image:tag or image@digest_type:digest format Closes #519 Signed-off-by: PrajwalM2212 <[email protected]>
- Loading branch information
1 parent
0c1a7b0
commit d18c4e1
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
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,27 @@ | ||
import unittest | ||
from tern.utils.general import check_image_string | ||
|
||
|
||
class TestUtilGeneral(unittest.TestCase): | ||
|
||
def testImageString(self): | ||
correct_strings = [ | ||
'image@digest_type:digest', | ||
'image:tag', | ||
'debian:buster', | ||
'golang:1.12-alpine', | ||
'p12/test@sha256:737aaa0caf3b8f64baa41ebf78c6cd0c43f34fadccc1275a32b8ab5d5b75c344' | ||
] | ||
|
||
incorrect_strings = [ | ||
'debian', | ||
'image', | ||
'debian@sha', | ||
'test/v1.56' | ||
] | ||
|
||
for image_str in correct_strings: | ||
self.assertTrue(check_image_string(image_str)) | ||
|
||
for image_str in incorrect_strings: | ||
self.assertFalse(check_image_string(image_str)) |