// Package service add by blacknc <blacknc@163.com> at 2023/03/17 18:31:46
package service

import (
	"context"
	"dataservices/commons/eventbus"
	dto "dataservices/internal/dto/dataapi"
	"testing"
	"time"

	"github.com/pingcap/errors"
	"github.com/tidbcloud/tiinf/monitor/tilog"
)

func Test_handleLinkClusterEvent(t *testing.T) {
	type args struct {
		event *eventbus.Event
	}
	tests := []struct {
		name string
		args args
		err  error
	}{
		{
			"OK",
			args{
				&eventbus.Event{
					Data: &dto.DataAppBindClusterEvent{
						EventType:  dto.DataAppBindClusterActionAddCluster,
						DataAppID:  1140011,
						ClusterIDs: []uint64{270001, 2578984, 2939315},
						Operator:   "fangdong.jia@pingcap.com",
						Optime:     time.Now().UnixMilli(),
					},
				},
			},
			nil,
		},
	}
	ctx := context.Background()
	logger := tilog.WithContextL(ctx)
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if err := handleLinkClusterEvent(ctx, logger, tt.args.event); errors.ErrorNotEqual(err, tt.err) {
				t.Errorf("handleLinkClusterEvent() error = %v, wantErr %v", err, tt.err)
			}
		})
	}
}
