Gets a "friendly package name" from a fully qualified function name. Most effectively demonstrated by example: - `github.com/riverqueue/river.Test_Client.func1` -> `river` - `github.com/riverqueue/river/internal/jobcompleter.testCompleterWait` -> `jobcompleter` This is then used as a root for con
(funcName string)
| 427 | // because it's not too long (schemas have a max length of 64 characters), human |
| 428 | // friendly, and won't have any special characters. |
| 429 | func packageFromFunc(funcName string) string { |
| 430 | var ( |
| 431 | packagePathLastSlashIndex = strings.LastIndex(funcName, "/") // index of last slash in path, so starting at `/river.Test_Client.func1` |
| 432 | funcNameFromLastSlash = funcName[packagePathLastSlashIndex+1:] // like: `/river.Test_Client.func1` |
| 433 | packageName, _, _ = strings.Cut(funcNameFromLastSlash, ".") // cut around first dot to extract `river` |
| 434 | ) |
| 435 | |
| 436 | return packageName |
| 437 | } |
| 438 | |
| 439 | // TestTxPgx starts a test transaction that's rolled back automatically as the |
| 440 | // test case is cleaning itself up. |
no outgoing calls
searching dependent graphs…