mirror of
				https://github.com/woodpecker-ci/woodpecker.git
				synced 2025-10-31 07:11:43 +00:00 
			
		
		
		
	* Refactor: move cncd/pipeline/ to pipeline/ * Refactor: move pipeline/pipeline/ to pipeline/
		
			
				
	
	
		
			75 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			75 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)
 | |
| 			}
 | |
| 		}
 | |
| 	}
 | |
| }
 |