Skip to content

Commit

Permalink
fix: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Feb 6, 2024
1 parent 3ab78d8 commit 5ddb0e0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
8 changes: 6 additions & 2 deletions docker_mounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,13 @@ func mapToDockerMounts(containerMounts ContainerMounts) []mount.Mount {

if mountType == mount.TypeVolume {
if containerMount.VolumeOptions == nil {
containerMount.VolumeOptions = &mount.VolumeOptions{}
containerMount.VolumeOptions = &mount.VolumeOptions{
Labels: make(map[string]string),
}
}
for k, v := range GenericLabels() {
containerMount.VolumeOptions.Labels[k] = v
}
containerMount.VolumeOptions.Labels = GenericLabels()
}

mounts = append(mounts, containerMount)
Expand Down
20 changes: 9 additions & 11 deletions mounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ func TestContainerMounts_PrepareMounts(t *testing.T) {
Labels: GenericLabels(),
}

expectedLabels := GenericLabels()
expectedLabels["hello"] = "world"

t.Parallel()
tests := []struct {
name string
Expand Down Expand Up @@ -104,9 +107,7 @@ func TestContainerMounts_PrepareMounts(t *testing.T) {
Target: "/data",
VolumeOptions: &mount.VolumeOptions{
NoCopy: true,
Labels: map[string]string{
"hello": "world",
},
Labels: expectedLabels,
},
},
},
Expand All @@ -117,9 +118,8 @@ func TestContainerMounts_PrepareMounts(t *testing.T) {
mounts: ContainerMounts{{Source: GenericTmpfsMountSource{}, Target: "/data"}},
want: []mount.Mount{
{
Type: mount.TypeTmpfs,
Target: "/data",
VolumeOptions: volumeOptions,
Type: mount.TypeTmpfs,
Target: "/data",
},
},
},
Expand All @@ -128,10 +128,9 @@ func TestContainerMounts_PrepareMounts(t *testing.T) {
mounts: ContainerMounts{{Source: GenericTmpfsMountSource{}, Target: "/data", ReadOnly: true}},
want: []mount.Mount{
{
Type: mount.TypeTmpfs,
Target: "/data",
ReadOnly: true,
VolumeOptions: volumeOptions,
Type: mount.TypeTmpfs,
Target: "/data",
ReadOnly: true,
},
},
},
Expand All @@ -156,7 +155,6 @@ func TestContainerMounts_PrepareMounts(t *testing.T) {
SizeBytes: 50 * 1024 * 1024,
Mode: 0o644,
},
VolumeOptions: volumeOptions,
},
},
},
Expand Down

0 comments on commit 5ddb0e0

Please sign in to comment.