mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
chore: add more tests for MatchesDockerVolume and update error message when volume spec doesn't match
This commit is contained in:
@@ -9,6 +9,8 @@ import (
|
||||
)
|
||||
|
||||
func TestVolumeSpec_MatchesDockerVolume(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
spec VolumeSpec
|
||||
@@ -57,6 +59,78 @@ func TestVolumeSpec_MatchesDockerVolume(t *testing.T) {
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "non-match with different driver options",
|
||||
spec: VolumeSpec{
|
||||
Type: VolumeTypeVolume,
|
||||
VolumeOptions: &VolumeOptions{
|
||||
Driver: &mount.Driver{
|
||||
Name: "local",
|
||||
Options: map[string]string{
|
||||
"foo": "baz",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
vol: volume.Volume{
|
||||
Driver: "local",
|
||||
Options: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "non-match with different driver name",
|
||||
spec: VolumeSpec{
|
||||
Type: VolumeTypeVolume,
|
||||
VolumeOptions: &VolumeOptions{
|
||||
Driver: &mount.Driver{
|
||||
Name: "custom",
|
||||
Options: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
vol: volume.Volume{
|
||||
Driver: "local",
|
||||
Options: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "match external volume without driver by name only",
|
||||
spec: VolumeSpec{
|
||||
Name: "external",
|
||||
Type: VolumeTypeVolume,
|
||||
},
|
||||
vol: volume.Volume{
|
||||
Name: "external",
|
||||
Driver: "local",
|
||||
Options: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "non-match external volume by name",
|
||||
spec: VolumeSpec{
|
||||
Name: "unknown",
|
||||
Type: VolumeTypeVolume,
|
||||
},
|
||||
vol: volume.Volume{
|
||||
Name: "external",
|
||||
Driver: "local",
|
||||
Options: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user