fix failing tests

This commit is contained in:
Hayden 2023-03-06 21:06:18 -09:00
parent e71146df3d
commit 3cfd274212
No known key found for this signature in database
GPG key ID: 17CF79474E257545
3 changed files with 9 additions and 5 deletions

View file

@ -43,7 +43,7 @@ type (
NotifierUpdate struct { NotifierUpdate struct {
Name string `json:"name" validate:"required,min=1,max=255"` Name string `json:"name" validate:"required,min=1,max=255"`
IsActive bool `json:"isActive"` IsActive bool `json:"isActive"`
URL *string `json:"url" extensions:"x-nullable" validate:"omitempty,shoutrrr"` URL *string `json:"url" validate:"omitempty,shoutrrr" extensions:"x-nullable" `
} }
NotifierOut struct { NotifierOut struct {

View file

@ -11,7 +11,7 @@ var validate *validator.Validate
func init() { func init() {
validate = validator.New() validate = validator.New()
validate.RegisterValidation("shoutrrr", func(fl validator.FieldLevel) bool { err := validate.RegisterValidation("shoutrrr", func(fl validator.FieldLevel) bool {
prefixes := [...]string{ prefixes := [...]string{
"discord://", "discord://",
"smtp://", "smtp://",
@ -45,6 +45,10 @@ func init() {
return false return false
}) })
if err != nil {
panic(err)
}
} }
// Checks a struct for validation errors and returns any errors the occur. This // Checks a struct for validation errors and returns any errors the occur. This

View file

@ -9,7 +9,7 @@ describe("basic notifier workflows", () => {
// Create Notifier // Create Notifier
const result = await client.notifiers.create({ const result = await client.notifiers.create({
name: faker.name.firstName(), name: faker.name.firstName(),
url: faker.internet.url(), url: "discord://" + faker.random.alphaNumeric(10),
isActive: true, isActive: true,
}); });
@ -23,7 +23,7 @@ describe("basic notifier workflows", () => {
{ {
const updateData = { const updateData = {
name: faker.name.firstName(), name: faker.name.firstName(),
url: faker.internet.url(), url: "discord://" + faker.random.alphaNumeric(10),
isActive: true, isActive: true,
}; };
@ -38,7 +38,7 @@ describe("basic notifier workflows", () => {
{ {
const updateData = { const updateData = {
name: faker.name.firstName(), name: faker.name.firstName(),
url: "", url: null,
isActive: true, isActive: true,
}; };