github.com/tsuna/gohbase@v0.0.0-20250731002811-4ffcadfba63e/test/test.go (about) 1 // Copyright (C) 2015 The GoHBase Authors. All rights reserved. 2 // This file is part of GoHBase. 3 // Use of this source code is governed by the Apache License 2.0 4 // that can be found in the COPYING file. 5 6 package test 7 8 import ( 9 "fmt" 10 11 "go.uber.org/mock/gomock" 12 ) 13 14 type reporter struct { 15 gomock.TestReporter 16 } 17 18 func (r reporter) Errorf(format string, args ...interface{}) { 19 r.TestReporter.Errorf(format, args...) 20 } 21 22 func (r reporter) Fatalf(format string, args ...interface{}) { 23 panic(fmt.Sprintf(format, args...)) 24 } 25 26 // NewController returns a gomock controller that panics when there's no match 27 // to handle goroutines 28 func NewController(t gomock.TestReporter) *gomock.Controller { 29 return gomock.NewController(reporter{t}) 30 } 31 32 // ErrEqual returns true if errors messages are equal 33 func ErrEqual(a, b error) bool { 34 aMsg, bMsg := "", "" 35 if a != nil { 36 aMsg = a.Error() 37 } 38 if b != nil { 39 bMsg = b.Error() 40 } 41 return aMsg == bMsg 42 }