Add unit tests for `PrepareVolumes`

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
This commit is contained in:
Laura Brehm 2022-09-15 09:53:14 -04:00
parent c4d79e60b6
commit 43c444e890
No known key found for this signature in database
GPG Key ID: 526E3FC49260D47A
1 changed files with 38 additions and 0 deletions

View File

@ -96,6 +96,44 @@ func TestPrepareNetworkLabels(t *testing.T) {
}))
}
func TestPrepareVolumes(t *testing.T) {
t.Run("adds dependency condition if service depends on volume from another service", func(t *testing.T) {
project := composetypes.Project{
Name: "myProject",
Services: []composetypes.ServiceConfig{
{
Name: "aService",
VolumesFrom: []string{"anotherService"},
},
{
Name: "anotherService",
},
},
}
prepareVolumes(&project)
assert.Equal(t, project.Services[0].DependsOn["anotherService"].Condition, composetypes.ServiceConditionStarted)
})
t.Run("doesn't overwrite existing dependency condition", func(t *testing.T) {
project := composetypes.Project{
Name: "myProject",
Services: []composetypes.ServiceConfig{
{
Name: "aService",
VolumesFrom: []string{"anotherService"},
DependsOn: map[string]composetypes.ServiceDependency{
"anotherService": {Condition: composetypes.ServiceConditionHealthy},
},
},
{
Name: "anotherService",
},
},
}
prepareVolumes(&project)
assert.Equal(t, project.Services[0].DependsOn["anotherService"].Condition, composetypes.ServiceConditionHealthy)
})
}
func TestBuildContainerMountOptions(t *testing.T) {
project := composetypes.Project{
Name: "myProject",