1
# Copyright (C) 2008 Canonical Ltd
1
# Copyright (C) 2008, 2009, 2011 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
18
18
"""Tests for upgrades of various stacking situations."""
26
from bzrlib.upgrade import upgrade
26
from ..upgrade import upgrade
27
from .scenarios import load_tests_apply_scenarios
30
def upgrade_scenarios():
31
scenario_pairs = [ # old format, new format, model_change
32
# ('knit', 'rich-root', True),
33
('knit', '1.6', False),
34
# ('pack-0.92', '1.6', False),
35
('1.6', '1.6.1-rich-root', True),
38
for (old_name, new_name, model_change) in scenario_pairs:
39
name = old_name + ', ' + new_name
40
scenarios.append((name,
41
dict(scenario_old_format=old_name,
42
scenario_new_format=new_name,
43
scenario_model_change=model_change)))
47
load_tests = load_tests_apply_scenarios
29
50
class TestStackUpgrade(tests.TestCaseWithTransport):
30
51
# TODO: This should possibly be repeated for all stacking repositories,
31
52
# pairwise by rich/non-rich format; should possibly also try other kinds
32
53
# of upgrades like knit->pack. -- mbp 20080804
55
scenarios = upgrade_scenarios()
34
57
def test_stack_upgrade(self):
35
58
"""Correct checks when stacked-on repository is upgraded.
43
66
self.build_tree(['base/foo'])
44
67
base.commit('base commit')
45
68
# make another one stacked
46
stacked = base.bzrdir.sprout('stacked', stacked=True)
69
stacked = base.controldir.sprout('stacked', stacked=True)
47
70
# this must really be stacked (or get_stacked_on_url raises an error)
48
71
self.assertTrue(stacked.open_branch().get_stacked_on_url())
49
72
# now we'll upgrade the underlying branch, then upgrade the stacked
50
73
# branch, and this should still work.
51
new_format = bzrdir.format_registry.make_bzrdir(
74
new_format = controldir.format_registry.make_controldir(
52
75
self.scenario_new_format)
53
76
upgrade('base', new_format)
54
77
# in some cases you'll get an error if the underlying model has
58
81
stacked.open_branch)
60
83
check.check_dwim('stacked', False, True, True)
61
stacked = bzrdir.BzrDir.open('stacked')
84
stacked = controldir.ControlDir.open('stacked')
62
85
# but we can upgrade the stacked repository
63
86
upgrade('stacked', new_format)
64
87
# and now it opens ok
65
stacked = bzrdir.BzrDir.open('stacked')
88
stacked = controldir.ControlDir.open('stacked')
66
89
# And passes check.
67
90
check.check_dwim('stacked', False, True, True)
70
def load_tests(basic_tests, module, loader):
71
"""Generate dynamic scenario tests.
73
Called by the bzrlib test framework.
75
scenario_pairs = [ # old format, new format, model_change
76
# ('knit', 'rich-root', True),
77
('knit', '1.6', False),
78
# ('pack-0.92', '1.6', False),
79
('1.6', '1.6.1-rich-root', True),
82
for (old_name, new_name, model_change) in scenario_pairs:
83
name = old_name + ', ' + new_name
84
scenarios.append((name,
85
dict(scenario_old_format=old_name,
86
scenario_new_format=new_name,
87
scenario_model_change=model_change)))
88
suite = loader.suiteClass()
89
return tests.multiply_tests(basic_tests, scenarios, suite)