Beispiel #1
0
        public async Task GetImageThrowsWhenProjectCantBeFound()
        {
            var file = new FileInfo(Path.GetTempFileName());

            file.Delete();
            var imageSource = new DockerProjectImageProvider(file);
            await Assert.ThrowsAsync <FileNotFoundException>(async() => await imageSource.GetImage(null));
        }
Beispiel #2
0
        public async Task GetImageBuildsProjectFromFile()
        {
            var file = ProjectLocator.GetCurrentDir().Parent?.Parent?.Parent?.Parent
                       ?.GetFiles("ExampleProject.csproj", SearchOption.AllDirectories).Single();
            var imageSource = new DockerProjectImageProvider(file);

            string tag = await imageSource.GetImage(null);

            var image = await new DockerClientProvider().GetDockerClient().Images
                        .ListImagesAsync(new ImagesListParameters {
                MatchName = tag
            });

            Assert.Single(image);
        }
Beispiel #3
0
        public async Task GetImageBuildsProjectFromNames()
        {
            string name = "foo";
            var    file = ProjectLocator.GetCurrentDir().Parent?.Parent?.Parent?.Parent
                          ?.GetFiles("ExampleProject.csproj", SearchOption.AllDirectories).Single();
            var projectLocator = new Mock <IProjectLocator>();

            projectLocator.Setup(p => p.GetDockerProject(name)).Returns(file);

            var imageSource = new DockerProjectImageProvider(name, projectLocator.Object);

            string tag = await imageSource.GetImage(null);

            var image = await new DockerClientProvider().GetDockerClient().Images
                        .ListImagesAsync(new ImagesListParameters {
                MatchName = tag
            });

            Assert.Single(image);
        }
Beispiel #4
0
        public async Task GetImageThrowsWhenProjectFailsToBuild()
        {
            var file = new FileInfo(Path.GetTempFileName());

            try
            {
                var imageSource = new DockerProjectImageProvider(file);
                await Assert.ThrowsAsync <DockerBuildFailedException>(async() => await imageSource.GetImage(null));
            }
            finally
            {
                file.Delete();
            }
        }
Beispiel #5
0
 public async Task GetImageThrowsWhenProjectIsNull()
 {
     var imageSource = new DockerProjectImageProvider((string)null);
     await Assert.ThrowsAsync <ArgumentNullException>(async() => await imageSource.GetImage(null));
 }