a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
34 lines
873 B
Go
34 lines
873 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
type fakeRebuildYes struct{}
|
|
|
|
func (fakeRebuildYes) NeedsRebuild() bool { return true }
|
|
|
|
type fakeRebuildNo struct{}
|
|
|
|
func (fakeRebuildNo) NeedsRebuild() bool { return false }
|
|
|
|
// storeNeedsRebuild must detect the optional NeedsRebuild capability and
|
|
// default to false for backends that don't implement it (the in-memory
|
|
// store), so the warm-restart fast path is bypassed only on an explicit
|
|
// rebuild signal.
|
|
func TestStoreNeedsRebuild(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
g any
|
|
want bool
|
|
}{
|
|
{"implements true", fakeRebuildYes{}, true},
|
|
{"implements false", fakeRebuildNo{}, false},
|
|
{"no capability", struct{}{}, false},
|
|
{"nil", nil, false},
|
|
}
|
|
for _, c := range cases {
|
|
if got := storeNeedsRebuild(c.g); got != c.want {
|
|
t.Errorf("%s: storeNeedsRebuild = %v, want %v", c.name, got, c.want)
|
|
}
|
|
}
|
|
}
|