github.com/bkosm/gompose/v2@v2.3.1/testing.go (about)

     1  package gompose
     2  
     3  type tt interface {
     4  	Helper()
     5  	Fatal(args ...any)
     6  }
     7  
     8  // MustT is a helper function that returns a value factory which will eliminate the
     9  // need to check for errors when spawning stubs and fixtures for testing.
    10  // Pass it the instance of *testing.T.
    11  func MustT[T any](t interface{}) func(v T, err error) T {
    12  	tt := t.(tt)
    13  	tt.Helper()
    14  
    15  	return func(v T, err error) T {
    16  		if err != nil {
    17  			tt.Fatal(err)
    18  		}
    19  		return v
    20  	}
    21  }