ostree: add test for VerifyRef()

This commit is contained in:
Achilleas Koutsou 2021-06-08 14:55:47 +02:00 committed by Tom Gundersen
parent 5556137daf
commit 14a74cf173

View file

@ -60,3 +60,25 @@ func TestOstreeResolveRef(t *testing.T) {
assert.EqualError(t, err, expMsg)
}
}
func TestVerifyRef(t *testing.T) {
cases := map[string]bool{
"a_perfectly_valid_ref": true,
"another/valid/ref": true,
"this-one-has/all.the/_valid-/characters/even/_numbers_42": true,
"rhel/8/aarch64/edge": true,
"1337": true,
"1337/but/also/more": true,
"_good_start/ref": true,
"/bad/ref": false,
"invalid)characters": false,
"this/was/doing/fine/until/the/very/end/": false,
"-bad_start/ref": false,
".another/bad/start": false,
"how/about/now?": false,
}
for in, expOut := range cases {
assert.Equal(t, expOut, VerifyRef(in), in)
}
}