mirror of
https://github.com/abiosoft/colima.git
synced 2026-05-17 12:10:34 +00:00
ccd5ddd03e
* chore: fix rare bug in terminal output. Signed-off-by: Abiola Ibrahim <git@abiosoft.com> * k3s: update version Signed-off-by: Abiola Ibrahim <git@abiosoft.com> * net: add ability to disable port forwarding Signed-off-by: Abiola Ibrahim <git@abiosoft.com> * vm: add ability to disable mounts Signed-off-by: Abiola Ibrahim <git@abiosoft.com> * net: fix regression when port-forwarding is disabled. Signed-off-by: Abiola Ibrahim <git@abiosoft.com> * chore: fix mount tests Signed-off-by: Abiola Ibrahim <git@abiosoft.com> --------- Signed-off-by: Abiola Ibrahim <git@abiosoft.com>
68 lines
1.3 KiB
Go
68 lines
1.3 KiB
Go
package cmd
|
|
|
|
import (
|
|
"reflect"
|
|
"strconv"
|
|
"testing"
|
|
|
|
"github.com/abiosoft/colima/config"
|
|
)
|
|
|
|
func Test_mountsFromFlag(t *testing.T) {
|
|
tests := []struct {
|
|
mounts []string
|
|
want []config.Mount
|
|
}{
|
|
{
|
|
mounts: []string{
|
|
"~:w",
|
|
},
|
|
want: []config.Mount{
|
|
{Location: "~", Writable: true},
|
|
},
|
|
},
|
|
{
|
|
mounts: []string{
|
|
"~",
|
|
},
|
|
want: []config.Mount{
|
|
{Location: "~"},
|
|
},
|
|
},
|
|
{
|
|
mounts: []string{
|
|
"/home/users", "/home/another:w", "/tmp",
|
|
},
|
|
want: []config.Mount{
|
|
{Location: "/home/users"},
|
|
{Location: "/home/another", Writable: true},
|
|
{Location: "/tmp"},
|
|
},
|
|
},
|
|
{
|
|
mounts: []string{
|
|
"/home/users:/home/users", "/home/another:w", "/tmp:/users/tmp", "/tmp:/users/tmp:w",
|
|
},
|
|
want: []config.Mount{
|
|
{Location: "/home/users", MountPoint: "/home/users"},
|
|
{Location: "/home/another", Writable: true},
|
|
{Location: "/tmp", MountPoint: "/users/tmp"},
|
|
{Location: "/tmp", MountPoint: "/users/tmp", Writable: true},
|
|
},
|
|
},
|
|
{
|
|
mounts: []string{
|
|
"none",
|
|
},
|
|
want: nil,
|
|
},
|
|
}
|
|
for i, tt := range tests {
|
|
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
|
if got := mountsFromFlag(tt.mounts); !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("mountsFromFlag() = %+v, want %+v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|