Browse Source
feat: add send group (#3)
feat: add send group (#3)
* feat: add send to group * chore: update docs * feat: remove modal indonesian phone number label * chore: update readmepull/4/head v2.1.0
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 176 additions and 57 deletions
-
15controllers/send_controller.go
-
4go.mod
-
3go.sum
-
15readme.md
-
6services/send_service_impl.go
-
8structs/send_struct.go
-
19validations/send_validation.go
-
61validations/send_validation_test.go
-
76views/index.html
@ -0,0 +1,61 @@ |
|||
package validations |
|||
|
|||
import ( |
|||
"github.com/aldinokemal/go-whatsapp-web-multidevice/structs" |
|||
"github.com/aldinokemal/go-whatsapp-web-multidevice/utils" |
|||
"github.com/stretchr/testify/assert" |
|||
"testing" |
|||
) |
|||
|
|||
func TestValidateSendMessage(t *testing.T) { |
|||
type args struct { |
|||
request structs.SendMessageRequest |
|||
} |
|||
tests := []struct { |
|||
name string |
|||
args args |
|||
err interface{} |
|||
}{ |
|||
{ |
|||
name: "success phone & message normal", |
|||
args: args{request: structs.SendMessageRequest{ |
|||
Phone: "6289685024091", |
|||
Message: "Hello this is testing", |
|||
}}, |
|||
err: nil, |
|||
}, |
|||
{ |
|||
name: "error invalid phone", |
|||
args: args{request: structs.SendMessageRequest{ |
|||
Phone: "some-random-phone", |
|||
Message: "Hello this is testing", |
|||
}}, |
|||
err: utils.ValidationError{ |
|||
Message: "phone: must contain digits only.", |
|||
}, |
|||
}, |
|||
{ |
|||
name: "error invalid phone contains dash (-)", |
|||
args: args{request: structs.SendMessageRequest{ |
|||
Phone: "6289-748-291", |
|||
Message: "Hello this is testing", |
|||
}}, |
|||
err: utils.ValidationError{ |
|||
Message: "phone: must contain digits only.", |
|||
}, |
|||
}, |
|||
} |
|||
|
|||
for _, tt := range tests { |
|||
t.Run(tt.name, func(t *testing.T) { |
|||
if tt.err == nil { |
|||
ValidateSendMessage(tt.args.request) |
|||
} else { |
|||
assert.PanicsWithValue(t, tt.err, func() { |
|||
ValidateSendMessage(tt.args.request) |
|||
}) |
|||
} |
|||
|
|||
}) |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue