feat: 实现 Bell 联系人与值班排班 (#183)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package bell_contact_schedule_test
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"go-admin/app/bell/contact"
|
||||
)
|
||||
|
||||
func TestChannelKeyAndWriteOnlyRoundTrip(t *testing.T) {
|
||||
encoded := base64.StdEncoding.EncodeToString([]byte("0123456789abcdef0123456789abcdef"))
|
||||
key, err := contact.ParseChannelKey(encoded)
|
||||
if err != nil || len(key) != 32 {
|
||||
t.Fatalf("key parse failed: len=%d err=%v", len(key), err)
|
||||
}
|
||||
for _, value := range []string{"", "short", base64.StdEncoding.EncodeToString([]byte("0123456789abcdef"))} {
|
||||
if _, err = contact.ParseChannelKey(value); !errors.Is(err, contact.ErrChannelKeyUnavailable) {
|
||||
t.Fatalf("invalid key accepted: %q err=%v", value, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user