Migrate wrong datasource UIDs (#86598)

This commit is contained in:
Andres Martinez Gotor
2024-05-03 13:32:07 +02:00
committed by GitHub
parent b25f193be0
commit b6f899d953
11 changed files with 135 additions and 17 deletions

View File

@@ -143,3 +143,32 @@ func TestValidateUID(t *testing.T) {
})
}
}
func TestAutofixUID(t *testing.T) {
var tests = []struct {
name string
uid string
expected string
}{
{
name: "return input when input is valid",
uid: "f8cc010c-ee72-4681-89d2-d46e1bd47d33",
expected: "f8cc010c-ee72-4681-89d2-d46e1bd47d33",
},
{
name: "generate new uid when input is too long",
uid: strings.Repeat("1", MaxUIDLength+1),
expected: strings.Repeat("1", MaxUIDLength),
},
{
name: "generate new uid when input has invalid characters",
uid: "f8cc010c.ee72.4681;89d2+d46e1bd47d33",
expected: "f8cc010c-ee72-4681-89d2-d46e1bd47d33",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.expected, AutofixUID(tt.uid))
})
}
}