mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
chore: support multi-org group sync with runtime configuration (#14578)
- Implement multi-org group sync - Implement runtime configuration to change sync behavior - Legacy group sync migrated to new package
This commit is contained in:
25
coderd/coderdtest/uuids.go
Normal file
25
coderd/coderdtest/uuids.go
Normal file
@ -0,0 +1,25 @@
|
||||
package coderdtest
|
||||
|
||||
import "github.com/google/uuid"
|
||||
|
||||
// DeterministicUUIDGenerator allows "naming" uuids for unit tests.
|
||||
// An example of where this is useful, is when a tabled test references
|
||||
// a UUID that is not yet known. An alternative to this would be to
|
||||
// hard code some UUID strings, but these strings are not human friendly.
|
||||
type DeterministicUUIDGenerator struct {
|
||||
Named map[string]uuid.UUID
|
||||
}
|
||||
|
||||
func NewDeterministicUUIDGenerator() *DeterministicUUIDGenerator {
|
||||
return &DeterministicUUIDGenerator{
|
||||
Named: make(map[string]uuid.UUID),
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DeterministicUUIDGenerator) ID(name string) uuid.UUID {
|
||||
if v, ok := d.Named[name]; ok {
|
||||
return v
|
||||
}
|
||||
d.Named[name] = uuid.New()
|
||||
return d.Named[name]
|
||||
}
|
Reference in New Issue
Block a user