MCPcopy Create free account
hub / github.com/github/gh-aw / TestImportCacheSetIdempotent

Function TestImportCacheSetIdempotent

pkg/parser/import_cache_test.go:375–392  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

373}
374
375func TestImportCacheSetIdempotent(t *testing.T) {
376 tempDir := t.TempDir()
377 cache := NewImportCache(tempDir)
378
379 firstContent := []byte("first content")
380 secondContent := []byte("second content")
381
382 path1, err := cache.Set("owner", "repo", "test.md", "sha1", firstContent)
383 require.NoError(t, err, "first Set should succeed")
384
385 path2, err := cache.Set("owner", "repo", "test.md", "sha1", secondContent)
386 require.NoError(t, err, "second Set with same key should succeed (overwrite)")
387 assert.Equal(t, path1, path2, "both Set calls should return the same cache path")
388
389 content, err := os.ReadFile(path2)
390 require.NoError(t, err, "reading overwritten file should succeed")
391 assert.Equal(t, string(secondContent), string(content), "file should contain second (latest) content")
392}
393
394func TestImportCacheGetDoesNotValidateComponents(t *testing.T) {
395 // Document that Get does not validate components (unlike Set).

Callers

nothing calls this directly

Calls 2

SetMethod · 0.95
NewImportCacheFunction · 0.85

Tested by

no test coverage detected