All checks were successful
Test / Sandbox (push) Successful in 3m13s
Test / Create distribution (push) Successful in 1m1s
Test / ShareFS (push) Successful in 2m42s
Test / Hakurei (push) Successful in 2m49s
Test / Sandbox (race detector) (push) Successful in 5m6s
Test / Hakurei (race detector) (push) Successful in 6m35s
Test / Flake checks (push) Successful in 1m27s
Some commands do not require the cache. This change also makes acquisition of locked cache cancelable. Signed-off-by: Ophestra <cat@gensokyo.uk>
39 lines
651 B
Go
39 lines
651 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"os"
|
|
"testing"
|
|
|
|
"hakurei.app/internal/pkg"
|
|
"hakurei.app/message"
|
|
)
|
|
|
|
func TestCache(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
cm := cache{
|
|
ctx: context.Background(),
|
|
msg: message.New(log.New(os.Stderr, "check: ", 0)),
|
|
base: t.TempDir(),
|
|
|
|
hostAbstract: true, idle: true,
|
|
}
|
|
defer cm.Close()
|
|
cm.Close()
|
|
|
|
if err := cm.open(); err != nil {
|
|
t.Fatalf("open: error = %v", err)
|
|
}
|
|
if err := cm.open(); err != os.ErrInvalid {
|
|
t.Errorf("(duplicate) open: error = %v", err)
|
|
}
|
|
|
|
if err := cm.Do(func(cache *pkg.Cache) error {
|
|
return cache.Scrub(0)
|
|
}); err != nil {
|
|
t.Errorf("Scrub: error = %v", err)
|
|
}
|
|
}
|