(t *testing.T)
| 116 | } |
| 117 | |
| 118 | func 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 | |
| 145 | func TestReferenceNewImage(t *testing.T) { |
| 146 | ref, tmpFile := refToTempFile(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…