(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestNormalizeReference(t *testing.T) { |
| 12 | testCases := []struct { |
| 13 | name string |
| 14 | reference string |
| 15 | pathSeparator rune |
| 16 | expectedResult string |
| 17 | expectedType artifactType |
| 18 | expectedError bool |
| 19 | }{ |
| 20 | { |
| 21 | name: "file reference without scheme", |
| 22 | reference: "/path/to/file", |
| 23 | pathSeparator: '/', |
| 24 | expectedResult: "/path/to/file", |
| 25 | expectedType: fileArtifactType, |
| 26 | expectedError: false, |
| 27 | }, |
| 28 | { |
| 29 | name: "file scheme uri with %20", |
| 30 | reference: "file:///path/to/file%20with%20spaces", |
| 31 | pathSeparator: '/', |
| 32 | expectedResult: "/path/to/file with spaces", |
| 33 | expectedType: fileArtifactType, |
| 34 | expectedError: false, |
| 35 | }, |
| 36 | { |
| 37 | name: "windows file reference without scheme", |
| 38 | reference: `c:\path\to\file`, |
| 39 | pathSeparator: '\\', |
| 40 | expectedResult: `c:\path\to\file`, |
| 41 | expectedType: fileArtifactType, |
| 42 | expectedError: false, |
| 43 | }, |
| 44 | { |
| 45 | name: "file reference with scheme", |
| 46 | reference: "file:///path/to/file", |
| 47 | pathSeparator: '/', |
| 48 | expectedResult: "/path/to/file", |
| 49 | expectedType: fileArtifactType, |
| 50 | expectedError: false, |
| 51 | }, |
| 52 | { |
| 53 | name: "windows path", |
| 54 | reference: "file:///C:/path/to/file", |
| 55 | pathSeparator: '\\', |
| 56 | expectedResult: `C:\path\to\file`, |
| 57 | expectedType: fileArtifactType, |
| 58 | expectedError: false, |
| 59 | }, |
| 60 | { |
| 61 | name: "windows path with backslashes", |
| 62 | reference: "file:///C:\\path\\to\\file", |
| 63 | pathSeparator: '\\', |
| 64 | expectedResult: `C:\path\to\file`, |
| 65 | expectedType: fileArtifactType, |
| 66 | expectedError: false, |
| 67 | }, |
| 68 | { |
nothing calls this directly
no test coverage detected