Skip to content

Commit

Permalink
Fixes docker project unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wbreza committed Feb 1, 2024
1 parent e112b5a commit 7d1d111
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cli/azd/pkg/project/framework_service_docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,19 +261,25 @@ func Test_DockerProject_Build(t *testing.T) {
env := environment.New("test")
dockerCli := docker.NewDocker(mockContext.CommandRunner)
serviceConfig := createTestServiceConfig("./src/api", ContainerAppTarget, ServiceLanguageTypeScript)

temp := t.TempDir()

serviceConfig.Docker.Registry = NewExpandableString("contoso.azurecr.io")
serviceConfig.Project.Path = temp
serviceConfig.RelativePath = ""
err := os.WriteFile(filepath.Join(temp, "Dockerfile"), []byte("FROM node:14"), 0600)
require.NoError(t, err)

npmProject := NewNpmProject(npm.NewNpmCli(mockContext.CommandRunner), env)
dockerProject := NewDockerProject(
env,
dockerCli,
NewContainerHelper(env, envManager, clock.NewMock(), nil, dockerCli),
mockinput.NewMockConsole(),
mockContext.AlphaFeaturesManager,
mockContext.CommandRunner)
dockerProject.SetSource(npmProject)

buildTask := dockerProject.Build(*mockContext.Context, serviceConfig, nil)
logProgress(buildTask)

Expand Down Expand Up @@ -319,14 +325,18 @@ func Test_DockerProject_Package(t *testing.T) {
env := environment.NewWithValues("test", map[string]string{})
dockerCli := docker.NewDocker(mockContext.CommandRunner)
serviceConfig := createTestServiceConfig("./src/api", ContainerAppTarget, ServiceLanguageTypeScript)
serviceConfig.Docker.Registry = NewExpandableString("contoso.azurecr.io")

npmProject := NewNpmProject(npm.NewNpmCli(mockContext.CommandRunner), env)
dockerProject := NewDockerProject(
env,
dockerCli,
NewContainerHelper(env, envManager, clock.NewMock(), nil, dockerCli),
mockinput.NewMockConsole(),
mockContext.AlphaFeaturesManager,
mockContext.CommandRunner)
dockerProject.SetSource(npmProject)

packageTask := dockerProject.Package(
*mockContext.Context,
serviceConfig,
Expand Down

0 comments on commit 7d1d111

Please sign in to comment.