mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-10-31 22:38:49 +00:00
e34daae0cf
* Refactor: move cncd/pipeline/ to pipeline/ * Refactor: move pipeline/pipeline/ to pipeline/
74 lines
1.5 KiB
Go
74 lines
1.5 KiB
Go
package docker
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestSplitVolumeParts(t *testing.T) {
|
|
testdata := []struct {
|
|
from string
|
|
to []string
|
|
success bool
|
|
}{
|
|
{
|
|
from: `Z::Z::rw`,
|
|
to: []string{`Z:`, `Z:`, `rw`},
|
|
success: true,
|
|
},
|
|
{
|
|
from: `Z:\:Z:\:rw`,
|
|
to: []string{`Z:\`, `Z:\`, `rw`},
|
|
success: true,
|
|
},
|
|
{
|
|
from: `Z:\git\refs:Z:\git\refs:rw`,
|
|
to: []string{`Z:\git\refs`, `Z:\git\refs`, `rw`},
|
|
success: true,
|
|
},
|
|
{
|
|
from: `Z:\git\refs:Z:\git\refs`,
|
|
to: []string{`Z:\git\refs`, `Z:\git\refs`},
|
|
success: true,
|
|
},
|
|
{
|
|
from: `Z:/:Z:/:rw`,
|
|
to: []string{`Z:/`, `Z:/`, `rw`},
|
|
success: true,
|
|
},
|
|
{
|
|
from: `Z:/git/refs:Z:/git/refs:rw`,
|
|
to: []string{`Z:/git/refs`, `Z:/git/refs`, `rw`},
|
|
success: true,
|
|
},
|
|
{
|
|
from: `Z:/git/refs:Z:/git/refs`,
|
|
to: []string{`Z:/git/refs`, `Z:/git/refs`},
|
|
success: true,
|
|
},
|
|
{
|
|
from: `/test:/test`,
|
|
to: []string{`/test`, `/test`},
|
|
success: true,
|
|
},
|
|
{
|
|
from: `test:/test`,
|
|
to: []string{`test`, `/test`},
|
|
success: true,
|
|
},
|
|
{
|
|
from: `test:test`,
|
|
to: []string{`test`, `test`},
|
|
success: true,
|
|
},
|
|
}
|
|
for _, test := range testdata {
|
|
results, err := splitVolumeParts(test.from)
|
|
if test.success == (err != nil) {
|
|
} else {
|
|
if reflect.DeepEqual(results, test.to) != test.success {
|
|
t.Errorf("Expect %q matches %q is %v", test.from, results, test.to)
|
|
}
|
|
}
|
|
}
|
|
}
|