MCPcopy Create free account
hub / github.com/cloudflare/artifact-fs / createLocalTestRepo

Function createLocalTestRepo

e2e_test.go:28–70  ·  view source on GitHub ↗

createLocalTestRepo creates a bare git repo seeded with enough content to exercise all e2e test assertions. Returns a file:// URL suitable for blobless clone (file:// forces the smart transport which supports --filter).

(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28const repoName = "e2e-test"
29
30func TestFUSEMountSmoke(t *testing.T) {
31 repo := newMountedE2ERepo(t)
32 if got := readFileStr(t, filepath.Join(repo.mountPath, "README.md")); !strings.Contains(got, "Test Repo") {
33 t.Fatalf("mounted README.md = %q", got)
34 }
35}
36
37// createLocalTestRepo creates a bare git repo seeded with enough content
38// to exercise all e2e test assertions. Returns a file:// URL suitable for
39// blobless clone (file:// forces the smart transport which supports --filter).
40func createLocalTestRepo(t *testing.T) string {
41 t.Helper()
42
43 bareDir := filepath.Join(t.TempDir(), "test-repo.git")
44 workDir := filepath.Join(t.TempDir(), "work")
45
46 // Initialize bare repo.
47 run(t, "", "git", "init", "--bare", bareDir)
48
49 // Create a working tree and seed content across 4 commits.
50 run(t, "", "git", "clone", bareDir, workDir)
51 run(t, workDir, "git", "config", "user.name", "E2E Setup")
52 run(t, workDir, "git", "config", "user.email", "e2e@test")
53 // Some git versions default to "master"; force "main" for consistency.
54 run(t, workDir, "git", "checkout", "-b", "main")
55
56 // Commit 1: readme and license files.
57 writeTestFile(t, workDir, "README.md", "# Test Repo\n\nA test repository for ArtifactFS e2e tests.\n")
58 writeTestFile(t, workDir, "LICENSE-MIT", "MIT License\n\nCopyright 2024 Test\n\nPermission is hereby granted, free of charge.\n")
59 writeTestFile(t, workDir, "SECURITY.md", "# Security\n\nReport security issues responsibly.\n")
60 run(t, workDir, "git", "add", "-A")
61 run(t, workDir, "git", "commit", "-m", "add readme and license")
62
63 // Commit 2: root package manifest.
64 writeTestFile(t, workDir, "package.json", `{"name":"e2e-test-repo","version":"1.0.0"}`+"\n")
65 run(t, workDir, "git", "add", "-A")
66 run(t, workDir, "git", "commit", "-m", "add package manifests")
67
68 // Commit 3: packages directory with 4 subdirectories.
69 for _, pkg := range []string{"wrangler", "miniflare", "vitest-pool", "workers-shared"} {
70 dir := filepath.Join(workDir, "packages", pkg)
71 if err := os.MkdirAll(dir, 0o755); err != nil {
72 t.Fatal(err)
73 }

Callers 4

TestE2EFunction · 0.85
newMountedE2ERepoFunction · 0.85

Calls 3

writeTestFileFunction · 0.85
JoinMethod · 0.80
runFunction · 0.70

Tested by

no test coverage detected