34 lines
574 B
Go
34 lines
574 B
Go
package ids
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestRepository(t *testing.T) {
|
|
first, err := Repository()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
second, err := Repository()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !strings.HasPrefix(first, "RP_") || len(first) != 29 {
|
|
t.Fatalf("unexpected repository ID %q", first)
|
|
}
|
|
if first == second {
|
|
t.Fatal("generated duplicate IDs")
|
|
}
|
|
}
|
|
|
|
func TestPrompt(t *testing.T) {
|
|
id, err := Prompt()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !strings.HasPrefix(id, "PM_") || len(id) != 29 {
|
|
t.Fatalf("unexpected prompt ID %q", id)
|
|
}
|
|
}
|