mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
- Implement multi-org group sync - Implement runtime configuration to change sync behavior - Legacy group sync migrated to new package
26 lines
718 B
Go
26 lines
718 B
Go
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]
|
|
}
|