Fixes #96 ## Motivation and Context See #96 ## How Has This Been Tested? Has some unit and integration tests, still needs proper testing of the different registry types ## Breaking Changes Yes, new package uploads will need extra verification ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update
32 lines
No EOL
825 B
Go
32 lines
No EOL
825 B
Go
package registries_test
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/hex"
|
|
"fmt"
|
|
)
|
|
|
|
func generateRandomPackageName() string {
|
|
bytes := make([]byte, 16)
|
|
if _, err := rand.Read(bytes); err != nil {
|
|
// Fallback to a static name if crypto/rand fails
|
|
return "nonexistent-pkg-fallback"
|
|
}
|
|
return fmt.Sprintf("nonexistent-pkg-%s", hex.EncodeToString(bytes))
|
|
}
|
|
|
|
func generateRandomNuGetPackageName() string {
|
|
bytes := make([]byte, 16)
|
|
if _, err := rand.Read(bytes); err != nil {
|
|
return "NonExistent.Package.Fallback"
|
|
}
|
|
return fmt.Sprintf("NonExistent.Package.%s", hex.EncodeToString(bytes)[:16])
|
|
}
|
|
|
|
func generateRandomImageName() string {
|
|
bytes := make([]byte, 16)
|
|
if _, err := rand.Read(bytes); err != nil {
|
|
return "nonexistent-image-fallback"
|
|
}
|
|
return fmt.Sprintf("nonexistent-image-%s", hex.EncodeToString(bytes)[:16])
|
|
} |