| 88 | } |
| 89 | |
| 90 | func ConnectDatabasesURLs(t *testing.T) (pgURL, mysqlURL, crdbURL string) { |
| 91 | wg := sync.WaitGroup{} |
| 92 | |
| 93 | wg.Add(3) |
| 94 | go func() { |
| 95 | pgURL = ConnectToPG(t) |
| 96 | t.Log("Pg done") |
| 97 | |
| 98 | require.EventuallyWithT(t, func(t *assert.CollectT) { |
| 99 | c, err := pop.NewConnection(&pop.ConnectionDetails{URL: pgURL}) |
| 100 | require.NoError(t, err) |
| 101 | require.NoError(t, c.Open()) |
| 102 | dbName := "testdb" + strings.ReplaceAll(uuid.Must(uuid.NewV4()).String(), "-", "") |
| 103 | require.NoError(t, c.RawQuery("CREATE DATABASE "+dbName).Exec()) |
| 104 | pgURL = regexp.MustCompile(`/[a-z0-9]+\?`).ReplaceAllString(pgURL, "/"+dbName+"?") |
| 105 | }, 20*time.Second, 100*time.Millisecond) |
| 106 | |
| 107 | wg.Done() |
| 108 | }() |
| 109 | go func() { |
| 110 | mysqlURL = ConnectToMySQL(t) |
| 111 | t.Log("myssql done") |
| 112 | |
| 113 | require.EventuallyWithT(t, func(t *assert.CollectT) { |
| 114 | c, err := pop.NewConnection(&pop.ConnectionDetails{URL: mysqlURL}) |
| 115 | require.NoError(t, err) |
| 116 | require.NoError(t, c.Open()) |
| 117 | dbName := "testdb" + strings.ReplaceAll(uuid.Must(uuid.NewV4()).String(), "-", "") |
| 118 | require.NoError(t, c.RawQuery("CREATE DATABASE "+dbName).Exec()) |
| 119 | mysqlURL = regexp.MustCompile(`/[a-z0-9]+\?`).ReplaceAllString(mysqlURL, "/"+dbName+"?") |
| 120 | }, 20*time.Second, 100*time.Millisecond) |
| 121 | |
| 122 | wg.Done() |
| 123 | }() |
| 124 | go func() { |
| 125 | crdbURL = ConnectToCRDB(t) |
| 126 | t.Log("crdb done") |
| 127 | |
| 128 | require.EventuallyWithT(t, func(t *assert.CollectT) { |
| 129 | c, err := pop.NewConnection(&pop.ConnectionDetails{URL: crdbURL}) |
| 130 | require.NoError(t, err) |
| 131 | require.NoError(t, c.Open()) |
| 132 | dbName := "testdb" + strings.ReplaceAll(uuid.Must(uuid.NewV4()).String(), "-", "") |
| 133 | require.NoError(t, c.RawQuery("CREATE DATABASE "+dbName).Exec()) |
| 134 | crdbURL = regexp.MustCompile(`/[a-z0-9]+\?`).ReplaceAllString(crdbURL, "/"+dbName+"?") |
| 135 | }, 20*time.Second, 100*time.Millisecond) |
| 136 | |
| 137 | wg.Done() |
| 138 | }() |
| 139 | t.Log("beginning to wait") |
| 140 | wg.Wait() |
| 141 | t.Log("done waiting") |
| 142 | |
| 143 | return |
| 144 | } |
| 145 | |
| 146 | func ConnectDatabases(t *testing.T, migrate bool, opts ...driver.OptionsModifier) map[string]*driver.RegistrySQL { |
| 147 | regs := make(map[string]*driver.RegistrySQL) |