testos_test.go 647 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright (C) 2019 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package model
  7. import (
  8. "github.com/syncthing/syncthing/lib/fs"
  9. )
  10. // fatal is the required common interface between *testing.B and *testing.T
  11. type fatal interface {
  12. Fatal(...interface{})
  13. Helper()
  14. }
  15. func must(f fatal, err error) {
  16. f.Helper()
  17. if err != nil {
  18. f.Fatal(err)
  19. }
  20. }
  21. func mustRemove(f fatal, err error) {
  22. f.Helper()
  23. if err != nil && !fs.IsNotExist(err) {
  24. f.Fatal(err)
  25. }
  26. }