MCPcopy Index your code
hub / github.com/cli/cli / TestNormalizeReference

Function TestNormalizeReference

pkg/cmd/attestation/artifact/artifact_posix_test.go:11–98  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func 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 {

Callers

nothing calls this directly

Calls 4

normalizeReferenceFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected