MCPcopy Create free account
hub / github.com/containers/image / TestReferencePolicyConfigurationNamespaces

Function TestReferencePolicyConfigurationNamespaces

sif/transport_test.go:118–143  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

116}
117
118func TestReferencePolicyConfigurationNamespaces(t *testing.T) {
119 ref, tmpFile := refToTempFile(t)
120 defer os.Remove(tmpFile)
121 // We don't really know enough to make a full equality test here.
122 ns := ref.PolicyConfigurationNamespaces()
123 require.NotNil(t, ns)
124 assert.NotEmpty(t, ns)
125 assert.Equal(t, filepath.Dir(tmpFile), ns[0])
126
127 // Test with a known path where the directory should exist. Test just one non-canonical
128 // path, the various other cases are tested in explicitfilepath.ResolvePathToFullyExplicit.
129 for _, path := range []string{"/usr/share/probablydoesnotexist.sif", "/usr/share/././probablydoesnoexist.sif"} {
130 _, err := os.Lstat(filepath.Dir(path))
131 require.NoError(t, err)
132 ref, err := NewReference(path)
133 require.NoError(t, err)
134 ns := ref.PolicyConfigurationNamespaces()
135 require.NotNil(t, ns)
136 assert.Equal(t, []string{"/usr/share", "/usr"}, ns)
137 }
138
139 // "/" as a corner case.
140 ref, err := NewReference("/")
141 require.NoError(t, err)
142 assert.Equal(t, []string{}, ref.PolicyConfigurationNamespaces())
143}
144
145func TestReferenceNewImage(t *testing.T) {
146 ref, tmpFile := refToTempFile(t)

Callers

nothing calls this directly

Calls 4

refToTempFileFunction · 0.85
RemoveMethod · 0.80
NewReferenceFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…