(t *testing.T)
| 169 | } |
| 170 | |
| 171 | func TestManagers(t *testing.T) { |
| 172 | t.Parallel() |
| 173 | |
| 174 | dsns := map[string]string{ |
| 175 | "sqlite": dbal.NewSQLiteTestDatabase(t), |
| 176 | } |
| 177 | if !testing.Short() { |
| 178 | dsns["postgres"], dsns["mysql"], dsns["cockroach"] = testhelpers.ConnectDatabasesURLs(t) |
| 179 | } |
| 180 | network1NID, network2NID, invalidNID := uuid.Must(uuid.NewV4()), uuid.Must(uuid.NewV4()), uuid.Must(uuid.NewV4()) |
| 181 | |
| 182 | for db, dsn := range dsns { |
| 183 | t.Run(db, func(t *testing.T) { |
| 184 | t.Parallel() |
| 185 | t.Logf("Testing database %s: %q", db, dsn) |
| 186 | |
| 187 | r1 := testhelpers.NewRegistrySQLFromURL(t, dsn, true, true, driver.DisableValidation(), driver.WithServiceLocatorOptions(servicelocatorx.WithContextualizer(&contextx.Static{NID: network1NID}))) |
| 188 | r2 := testhelpers.NewRegistrySQLFromURL(t, dsn, false, true, driver.DisableValidation(), driver.WithServiceLocatorOptions(servicelocatorx.WithContextualizer(&contextx.Static{NID: network2NID}))) |
| 189 | rInv := testhelpers.NewRegistrySQLFromURL(t, dsn, false, true, driver.DisableValidation(), driver.SkipNetworkInit(), driver.WithServiceLocatorOptions(servicelocatorx.WithContextualizer(&contextx.Static{NID: invalidNID}))) |
| 190 | |
| 191 | require.NoError(t, r1.Persister().Connection(t.Context()).Create(&networkx.Network{ID: network1NID})) |
| 192 | require.NoError(t, r1.Persister().Connection(t.Context()).Create(&networkx.Network{ID: network2NID})) |
| 193 | |
| 194 | require.Equal(t, network1NID, r1.Persister().NetworkID(t.Context())) |
| 195 | require.Equal(t, network2NID, r2.Persister().NetworkID(t.Context())) |
| 196 | require.Equal(t, invalidNID, rInv.Persister().NetworkID(t.Context())) |
| 197 | |
| 198 | t.Run("parallel boundary", func(t *testing.T) { testRegistry(t, db, r1, r2) }) |
| 199 | |
| 200 | if db == "sqlite" { |
| 201 | // The following tests rely on foreign key constraints, which some of them are not correctly created in the SQLite schema. |
| 202 | return |
| 203 | } |
| 204 | |
| 205 | // if !r1.Config().HSMEnabled() { |
| 206 | t.Run("jwk nid", |
| 207 | jwk.TestHelperNID(r1.KeyManager(), rInv.KeyManager()), |
| 208 | ) |
| 209 | // } |
| 210 | t.Run("login nid", |
| 211 | test.LoginNIDTest(r1.Persister(), rInv.Persister()), |
| 212 | ) |
| 213 | }) |
| 214 | } |
| 215 | } |
nothing calls this directly
no test coverage detected