1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- package webmail
- import (
- "reflect"
- "testing"
- "time"
- )
- var (
- cli = NewClient("http://api.izene.org/winmail/mailalias.php", 60*time.Second)
- )
- func Test_client_CreateAlias(t *testing.T) {
- tests := []struct {
- alias string
- wantErr bool
- }{
- {
- alias: "gl0001",
- wantErr: false,
- },
- }
- for _, tt := range tests {
- t.Run("CreateAlias", func(t *testing.T) {
- if err := cli.CreateAlias(tt.alias); (err != nil) != tt.wantErr {
- t.Errorf("CreateAlias() error = %v, wantErr %v", err, tt.wantErr)
- }
- })
- }
- }
- func Test_client_ListAliases(t *testing.T) {
- tests := []struct {
- want []string
- wantErr bool
- }{
- {
- want: []string{
- "bf111", "bf123", "bfbfbf", "support002", "support003", "support004", "test", "test1",
- },
- wantErr: false,
- },
- }
- for _, tt := range tests {
- t.Run("ListAliases", func(t *testing.T) {
- got, err := cli.ListAliases()
- if (err != nil) != tt.wantErr {
- t.Errorf("ListAliases() error = %v, wantErr %v", err, tt.wantErr)
- return
- }
- if !reflect.DeepEqual(got, tt.want) {
- t.Errorf("ListAliases() got = %v, want %v", got, tt.want)
- }
- })
- }
- }
- func Test_client_RemoveAlias(t *testing.T) {
- tests := []struct {
- alias string
- wantErr bool
- }{
- {
- alias: "gl0001",
- wantErr: false,
- },
- }
- for _, tt := range tests {
- t.Run("RemoveAlias", func(t *testing.T) {
- if err := cli.RemoveAlias(tt.alias); (err != nil) != tt.wantErr {
- t.Errorf("RemoveAlias() error = %v, wantErr %v", err, tt.wantErr)
- }
- })
- }
- }
|