Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions cli/azd/pkg/project/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,35 @@ func Test_Save(t *testing.T) {
assert.Equal(t, dir, prjConfig.Path)
}

func Test_Save_OmitsEmptyServiceSourceFields(t *testing.T) {
dir := t.TempDir()
filePath := filepath.Join(dir, "azure.yaml")

prjConfig := &ProjectConfig{
Name: "test-save",
Services: map[string]*ServiceConfig{
"foundry": {
Host: ServiceTargetKind("azure.ai.project"),
AdditionalProperties: map[string]any{
"endpoint": "https://account.services.ai.azure.com/api/projects/project",
},
},
},
}

err := Save(t.Context(), prjConfig, filePath)
require.NoError(t, err)

data, err := os.ReadFile(filePath)
require.NoError(t, err)

content := string(data)
assert.Contains(t, content, "host: azure.ai.project")
assert.Contains(t, content, "endpoint: https://account.services.ai.azure.com/api/projects/project")
assert.NotContains(t, content, "project: \"\"")
assert.NotContains(t, content, "language: \"\"")
}

func Test_Save_CustomSchemaVersion(t *testing.T) {
dir := t.TempDir()
filePath := filepath.Join(dir, "azure.yaml")
Expand Down
4 changes: 2 additions & 2 deletions cli/azd/pkg/project/service_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ type ServiceConfig struct {
// The ARM api version to use for the service. If not specified, the latest version is used.
ApiVersion string `yaml:"apiVersion,omitempty"`
// The relative path to the project folder from the project root
RelativePath string `yaml:"project"`
RelativePath string `yaml:"project,omitempty"`
// The azure hosting model to use, ex) appservice, function, containerapp
Host ServiceTargetKind `yaml:"host"`
// The programming language of the project
Language ServiceLanguageKind `yaml:"language"`
Language ServiceLanguageKind `yaml:"language,omitempty"`
// The output path for build artifacts
OutputPath string `yaml:"dist,omitempty"`
// The source image to use for container based applications
Expand Down
Loading