def test_build_plan(): images = [{ 'name': 'ubuntu-dev-base', 'full_name': 'aghost7/ubuntu-dev-base', 'dependency': 'ubuntu' }, { 'name': 'power-tmux', 'full_name': 'aghost7/power-tmux', 'dependency': 'ubuntu-dev-base' }, { 'name': 'nvim', 'full_name': 'aghost7/nvim', 'dependency': 'power-tmux' }, { 'name': 'nodejs-dev', 'full_name': 'aghost7/nodejs-dev:boron', 'dependency': 'nvim' }, { 'name': 'py-dev', 'full_name': 'aghost7/py-dev', 'dependency': 'nvim' }] changes = [{'name': 'power-tmux'}, {'name': 'nodejs-dev'}] plan = build.build_plan(images, changes) assert plan[0]['name'] == 'power-tmux' assert plan[1]['name'] == 'nvim' assert plan[2]['name'] == 'nodejs-dev' or plan[2]['name'] == 'py-dev' assert plan[3]['name'] == 'nodejs-dev' or plan[3]['name'] == 'py-dev' assert len(plan) == 4
def test_build_plan_dependents(): images = [{ 'name': 'ubuntu-dev-base', 'full_name': 'aghost7/ubuntu-dev-base', 'dependency': 'ubuntu' }, { 'name': 'ubuntu-dev-base', 'tag': 'bionic', 'full_name': 'aghost7/ubuntu-dev-base:bionic', 'dependency': 'ubuntu', 'args': { 'UBUNTU_RELEASE': 'bionic' } }, { 'name': 'power-tmux', 'full_name': 'aghost7/power-tmux', 'dependency': 'ubuntu-dev-base' }, { 'name': 'nvim', 'full_name': 'aghost7/nvim', 'dependency': 'power-tmux' }] changes = [{'name': 'ubuntu-dev-base'}] plan = build.build_plan(images, changes) assert len(plan) == 4
def test_build_multiple_parents(): images = [{ 'name': 'nvim', 'full_name': 'aghost7/nvim', 'dependency': 'power-tmux' }, { 'name': 'nvim', 'tag': 'bionic', 'full_name': 'aghost7/nvim:bionic', 'dependency': 'power-tmux' }, { 'name': 'nodejs-dev-base', 'full_name': 'aghost7/nodejs-dev-base', 'dependency': 'nvim' }, { 'name': 'nodejs-dev-base', 'tag': 'bionic', 'full_name': 'aghost7/nodejs-dev-base:bionic', 'dependency': 'nvim' }, { 'name': 'nodejs-dev', 'tag': 'bionic-carbon', 'full_name': 'aghost7/nodejs-dev:bionic-carbon', 'dependency': 'nodejs-dev-base' }] changes = [{'name': 'nvim'}] plan_names = [ image['full_name'] for image in build.build_plan(images, changes) ] expected_plan_names = [ 'aghost7/nvim', 'aghost7/nvim:bionic', 'aghost7/nodejs-dev-base', 'aghost7/nodejs-dev-base:bionic', 'aghost7/nodejs-dev:bionic-carbon' ] for i in range(len(expected_plan_names)): assert expected_plan_names[i] == plan_names[i]