github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/engine/virt/helper_test.go (about) 1 package virt 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 ) 8 9 func TestCombineUserImage(t *testing.T) { 10 user := "user" 11 image := "image" 12 13 combine := combineUserImage(user, image) 14 require.Equal(t, "user@image", combine) 15 u, i, err := splitUserImage(combine) 16 require.NoError(t, err) 17 require.Equal(t, user, u) 18 require.Equal(t, image, i) 19 20 combine = combineUserImage("", image) 21 require.Equal(t, image, combine) 22 u, i, err = splitUserImage(combine) 23 require.NoError(t, err) 24 require.Equal(t, "", u) 25 require.Equal(t, image, i) 26 27 combine = combineUserImage(user, "") 28 require.Equal(t, "", combine) 29 u, i, err = splitUserImage(combine) 30 require.Error(t, err) 31 32 combine = combineUserImage("", "") 33 require.Equal(t, "", combine) 34 35 u, i, err = splitUserImage("@") 36 require.Error(t, err) 37 38 u, i, err = splitUserImage("hello@") 39 require.Error(t, err) 40 }