MCPcopy
hub / github.com/caddyserver/certmagic / TestFileStorageStoreLoadRace

Function TestFileStorageStoreLoadRace

filestorage_test.go:28–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26}
27
28func TestFileStorageStoreLoadRace(t *testing.T) {
29 ctx := context.Background()
30 tmpDir, err := os.MkdirTemp(os.TempDir(), "certmagic*")
31 testutil.RequireNoError(t, err, "allocating tmp dir")
32 defer os.RemoveAll(tmpDir)
33 s := &certmagic.FileStorage{
34 Path: tmpDir,
35 }
36 a := bytes.Repeat([]byte("a"), 4096*1024)
37 b := bytes.Repeat([]byte("b"), 4096*1024)
38 err = s.Store(ctx, "foo", a)
39 testutil.RequireNoError(t, err)
40 done := make(chan struct{})
41 go func() {
42 err := s.Store(ctx, "foo", b)
43 testutil.RequireNoError(t, err)
44 close(done)
45 }()
46 dat, err := s.Load(ctx, "foo")
47 <-done
48 testutil.RequireNoError(t, err)
49 testutil.RequireEqualValues(t, 4096*1024, len(dat))
50}
51
52func TestFileStorageWriteLock(t *testing.T) {
53 ctx := context.Background()

Callers

nothing calls this directly

Calls 4

StoreMethod · 0.95
LoadMethod · 0.95
RequireNoErrorFunction · 0.92
RequireEqualValuesFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…