Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddie4k-code committed Nov 11, 2024
1 parent ac17315 commit 702923d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions scripts/tests/changed_files_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import unittest
from scripts.changed_files import changed_files


class TestGetChangedFiles(unittest.TestCase):

def test_no_files(self):
self.assertCountEqual(changed_files.get_changed_files([]), [])

def test_no_matching_services(self):
files = ["other-service/file.txt", "another-service/anotherfile.txt"]
self.assertCountEqual(changed_files.get_changed_files(files), [])

def test_some_matching_services(self):
files = ["auth-service/file1.txt", "order-service/file2.txt", "unrelated/file3.txt"]
self.assertCountEqual(changed_files.get_changed_files(files), ["auth-service", "order-service"])

def test_all_matching_services(self):
files = ["auth-service/file1.txt", "sneaker-service/file2.txt", "order-service/file3.txt"]
self.assertCountEqual(changed_files.get_changed_files(files), ["auth-service", "sneaker-service", "order-service"])

def test_duplicate_services(self):
files = ["auth-service/file1.txt", "auth-service/file2.txt"]
self.assertCountEqual(changed_files.get_changed_files(files), ["auth-service"])

if __name__ == "__main__":
unittest.main()

0 comments on commit 702923d

Please sign in to comment.