def test_semver_make_valid(self): tests = [('simple-1.0.0', SemanticVersion('simple', 1, 0, 0)), ('another-10.11.12', SemanticVersion('another', 10, 11, 12))] for tag, expect in tests: semver = SemanticVersion.make(tag) self.assertEquals(semver, expect) self.assertEquals(tag, semver.to_tag()) self.assertEquals(tag[tag.rfind('-') + 1:], semver.to_version())
def test_maybe_pull_repository_branch(self): test_root = os.path.join(self.base_temp_dir, 'pulled_test') git = self.git scm = SpinnakerSourceCodeManager(git, test_root, self.TEST_SOURCE_REPOSITORIES) for repository in self.TEST_SOURCE_REPOSITORIES.values(): scm.maybe_pull_repository_source(repository, git_branch=UNTAGGED_BRANCH) git_dir = scm.get_local_repository_path(repository.name) remote_git = git.determine_remote_git_repository(git_dir) self.assertEquals(repository, remote_git) in_branch = git.query_local_repository_branch(git_dir) self.assertEquals(UNTAGGED_BRANCH, in_branch) summary = git.collect_repository_summary(git_dir) semver = SemanticVersion.make(BASE_VERSION) expect_version = semver.next( SemanticVersion.MINOR_INDEX).to_version() self.assertEquals(expect_version, summary.version)
def test_semver_next(self): semver = SemanticVersion('A', 1, 2, 3) tests = [ (SemanticVersion.TAG_INDEX, SemanticVersion('B', 1, 2, 3), None), (None, SemanticVersion('A', 1, 2, 3), None), (SemanticVersion.MAJOR_INDEX, SemanticVersion('A', 2, 2, 3), SemanticVersion('A', 2, 0, 0)), # next major index to semver (SemanticVersion.MINOR_INDEX, SemanticVersion('A', 1, 3, 3), SemanticVersion('A', 1, 3, 0)), # next minor index to semver (SemanticVersion.PATCH_INDEX, SemanticVersion('A', 1, 2, 4), SemanticVersion('A', 1, 2, 4)), # next patch index to semver ] for expect_index, test, next_semver in tests: self.assertEquals(expect_index, semver.most_significant_diff_index(test)) self.assertEquals(expect_index, test.most_significant_diff_index(semver)) if expect_index is not None and expect_index > SemanticVersion.TAG_INDEX: self.assertEquals(next_semver, semver.next(expect_index))