// Package service add by blacknc <blacknc@163.com> at 2023/04/04 14:46:35
package service

import (
	"context"
	"dataservices/commons/config"
	"dataservices/commons/metrics"
	"fmt"
	"testing"
)

func TestCreateDynamoDBGlobalTable(t *testing.T) {
	type args struct {
		region         string
		replicaRegions []string
	}
	tests := []struct {
		name    string
		args    args
		wantErr bool
	}{
		{
			name: "OK",
			args: args{
				region:         "us-west-2",
				replicaRegions: []string{"ap-northeast-1"},
			},
			wantErr: false,
		},
	}
	ctx := context.Background()
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if err := CreateDynamoDBGlobalTable(ctx, tt.args.region, tt.args.replicaRegions, true); (err != nil) != tt.wantErr {
				t.Errorf("CreateDynamoDBGlobalTable() error = %v, wantErr %v", err, tt.wantErr)
			}
		})
	}
}

func TestDeleteDynamoDBGlobalTable(t *testing.T) {
	type args struct {
		region         string
		replicaRegions []string
	}
	tests := []struct {
		name    string
		args    args
		wantErr bool
	}{
		{
			name: "OK",
			args: args{
				region:         "us-west-2",
				replicaRegions: []string{"us-east-1"},
			},
			wantErr: false,
		},
	}
	ctx := context.Background()
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if err := DeleteDynamoDBGlobalTable(ctx, tt.args.region, tt.args.replicaRegions, true); (err != nil) != tt.wantErr {
				t.Errorf("DeleteDynamoDBGlobalTable() error = %v, wantErr %v", err, tt.wantErr)
			}
		})
	}
}

func Test_getAllServerlessClusterIDs(t *testing.T) {
	config.Global().GrpcConf.CoreSvcAddr = "localhost:10006"
	metrics.RegisterCentralMetrics()
	tests := []struct {
		name    string
		wantErr bool
	}{
		{
			"ok",
			false,
		},
	}
	ctx := context.Background()
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			clusterIDs, err := getAllServerlessClusterIDs(ctx)
			if (err != nil) != tt.wantErr {
				t.Errorf("getAllServerlessClusterIDs() error = %v, wantErr %v", err, tt.wantErr)
				return
			}
			fmt.Println(clusterIDs)
		})
	}
}
