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

Function TestNormalizeReference

pkg/cmd/attestation/artifact/artifact_windows_test.go:11–58  ·  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: "windows file reference without scheme",
22 reference: `c:\path\to\file`,
23 pathSeparator: '\\',
24 expectedResult: `c:\path\to\file`,
25 expectedType: fileArtifactType,
26 expectedError: false,
27 },
28 {
29 name: "windows path",
30 reference: "file:///C:/path/to/file",
31 pathSeparator: '\\',
32 expectedResult: `C:\path\to\file`,
33 expectedType: fileArtifactType,
34 expectedError: false,
35 },
36 {
37 name: "windows path with backslashes",
38 reference: "file:///C:\\path\\to\\file",
39 pathSeparator: '\\',
40 expectedResult: `C:\path\to\file`,
41 expectedType: fileArtifactType,
42 expectedError: false,
43 },
44 }
45
46 for _, tc := range testCases {
47 t.Run(tc.name, func(t *testing.T) {
48 result, artifactType, err := normalizeReference(tc.reference, tc.pathSeparator)
49 if tc.expectedError {
50 require.Error(t, err)
51 } else {
52 require.NoError(t, err)
53 require.Equal(t, tc.expectedResult, result)
54 require.Equal(t, tc.expectedType, artifactType)
55 }
56 })
57 }
58}

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