container/stub: export stub helpers
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 1m53s
Test / Hakurei (push) Successful in 3m18s
Test / Sandbox (race detector) (push) Successful in 3m40s
Test / Hpkg (push) Successful in 3m35s
Test / Hakurei (race detector) (push) Successful in 5m19s
Test / Flake checks (push) Successful in 1m39s
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 1m53s
Test / Hakurei (push) Successful in 3m18s
Test / Sandbox (race detector) (push) Successful in 3m40s
Test / Hpkg (push) Successful in 3m35s
Test / Hakurei (race detector) (push) Successful in 5m19s
Test / Flake checks (push) Successful in 1m39s
These are very useful in many packages containing relatively large amount of code making calls to difficult or impossible to stub functions. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
35
container/stub/errors_test.go
Normal file
35
container/stub/errors_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package stub_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"hakurei.app/container/stub"
|
||||
)
|
||||
|
||||
func TestUniqueError(t *testing.T) {
|
||||
t.Run("format", func(t *testing.T) {
|
||||
want := "unique error 2989 injected by the test suite"
|
||||
if got := stub.UniqueError(0xbad).Error(); got != want {
|
||||
t.Errorf("Error: %q, want %q", got, want)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("is", func(t *testing.T) {
|
||||
t.Run("type", func(t *testing.T) {
|
||||
if errors.Is(stub.UniqueError(0), syscall.ENOTRECOVERABLE) {
|
||||
t.Error("Is: unexpected true")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("val", func(t *testing.T) {
|
||||
if errors.Is(stub.UniqueError(0), stub.UniqueError(1)) {
|
||||
t.Error("Is: unexpected true")
|
||||
}
|
||||
if !errors.Is(stub.UniqueError(0xbad), stub.UniqueError(0xbad)) {
|
||||
t.Error("Is: unexpected false")
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user