Skip to content

Commit

Permalink
Add an acceptance test for bundle.
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Nephin <dnephin@docker.com>
  • Loading branch information
dnephin authored and aanand committed Jul 6, 2016
1 parent db02c9f commit a7fc3e2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compose/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def fetch_image_digest(service):
repo, _, _ = parse_repository_tag(service.options['image'])
identifier = '{repo}@{digest}'.format(repo=repo, digest=digest)

# only do this is RepoTags isn't already populated
# only do this if RepoDigests isn't already populated
image = service.image()
if not image['RepoDigests']:
# Pull by digest so that image['RepoDigests'] is populated for next time
Expand Down
27 changes: 27 additions & 0 deletions tests/acceptance/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from collections import namedtuple
from operator import attrgetter

import py
import yaml
from docker import errors

Expand Down Expand Up @@ -378,6 +379,32 @@ def test_build_failed_forcerm(self):
]
assert not containers

def test_bundle_with_digests(self):
self.base_dir = 'tests/fixtures/bundle-with-digests/'
tmpdir = py.test.ensuretemp('cli_test_bundle')
self.addCleanup(tmpdir.remove)
filename = str(tmpdir.join('example.dab'))

self.dispatch(['bundle', '--output', filename])
with open(filename, 'r') as fh:
bundle = json.load(fh)

assert bundle == {
'Version': '0.1',
'Services': {
'web': {
'Image': ('dockercloud/hello-world@sha256:fe79a2cfbd17eefc3'
'44fb8419420808df95a1e22d93b7f621a7399fd1e9dca1d'),
'Networks': ['default'],
},
'redis': {
'Image': ('redis@sha256:a84cb8f53a70e19f61ff2e1d5e73fb7ae62d'
'374b2b7392de1e7d77be26ef8f7b'),
'Networks': ['default'],
}
},
}

def test_create(self):
self.dispatch(['create'])
service = self.project.get_service('simple')
Expand Down
9 changes: 9 additions & 0 deletions tests/fixtures/bundle-with-digests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

version: '2.0'

services:
web:
image: dockercloud/hello-world@sha256:fe79a2cfbd17eefc344fb8419420808df95a1e22d93b7f621a7399fd1e9dca1d

redis:
image: redis@sha256:a84cb8f53a70e19f61ff2e1d5e73fb7ae62d374b2b7392de1e7d77be26ef8f7b

0 comments on commit a7fc3e2

Please sign in to comment.