MCPcopy Create free account
hub / github.com/conforma/cli / TestIsFilePath

Function TestIsFilePath

internal/validate/vsa/vsa_test.go:1315–1369  ·  view source on GitHub ↗

TestIsFilePath tests the isFilePath function

(t *testing.T)

Source from the content-addressed store, hash-verified

1313
1314// TestIsFilePath tests the isFilePath function
1315func TestIsFilePath(t *testing.T) {
1316 tests := []struct {
1317 name string
1318 identifier string
1319 expected bool
1320 }{
1321 {
1322 name: "absolute path",
1323 identifier: "/path/to/file",
1324 expected: true,
1325 },
1326 {
1327 name: "relative path with dot",
1328 identifier: "./file",
1329 expected: true,
1330 },
1331 {
1332 name: "relative path with parent",
1333 identifier: "../file",
1334 expected: true,
1335 },
1336 {
1337 name: "file with extension",
1338 identifier: "file.json",
1339 expected: true,
1340 },
1341 {
1342 name: "path with separators",
1343 identifier: "path/to/file",
1344 expected: true,
1345 },
1346 {
1347 name: "image reference with colon",
1348 identifier: "nginx:latest",
1349 expected: false,
1350 },
1351 {
1352 name: "image reference with at",
1353 identifier: "nginx@sha256:abc123",
1354 expected: false,
1355 },
1356 {
1357 name: "simple name without extension",
1358 identifier: "nginx",
1359 expected: false,
1360 },
1361 }
1362
1363 for _, tt := range tests {
1364 t.Run(tt.name, func(t *testing.T) {
1365 result := isFilePath(tt.identifier)
1366 assert.Equal(t, tt.expected, result)
1367 })
1368 }
1369}
1370
1371// TestExtractDigestFromImageRef tests the ExtractDigestFromImageRef function
1372func TestExtractDigestFromImageRef(t *testing.T) {

Callers

nothing calls this directly

Calls 2

isFilePathFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected