mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-07-16 09:38:49 +02:00
51 lines
915 B
Go
51 lines
915 B
Go
package db
|
|
|
|
import "testing"
|
|
|
|
func TestIsSafeIdentifier(t *testing.T) {
|
|
type args struct {
|
|
uuid string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want bool
|
|
}{
|
|
{
|
|
name: "Test safe identifier",
|
|
args: args{
|
|
uuid: "1234567890-1234567890-1234567890-1234567890",
|
|
},
|
|
want: true,
|
|
},
|
|
{
|
|
name: "Test safe identifier",
|
|
args: args{
|
|
uuid: "1234567890-1234567890-1234567890-1234567890",
|
|
},
|
|
want: true,
|
|
},
|
|
{
|
|
name: "Test safe identifier",
|
|
args: args{
|
|
uuid: "77eddc32-c49d-5d0a-8c36-17b266396641",
|
|
},
|
|
want: true,
|
|
},
|
|
{
|
|
name: "Test unsafe identifier",
|
|
args: args{
|
|
uuid: "77eddc32-c49d-5d0a-8c36-17/1!!b266396641-",
|
|
},
|
|
want: false,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := IsSafeIdentifier(tt.args.uuid); got != tt.want {
|
|
t.Errorf("IsSafeIdentifier() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|