package backup

// import (
// 	"strings"
// 	"testing"
// 	"time"

// 	"github.com/pingcap/dbaas/central/config"
// 	"github.com/pingcap/dbaas/central/db/entity"
// 	"github.com/pingcap/dbaas/central/model/util"
// 	"github.com/tidbcloud/idl/pbgen/proto/central"
// 	"github.com/prometheus/client_golang/prometheus"
// 	"github.com/prometheus/client_golang/prometheus/testutil"
// )

// func TestNoBackupMetricsCollected(t *testing.T) {
// 	ch := make(chan prometheus.Metric)

// 	statBackup := func() map[entity.Tenant][]entity.Backup {
// 		return make(map[entity.Tenant][]entity.Backup)
// 	}
// 	collector := NewBackupCollector(statBackup)
// 	collector.Collect(ch)

// 	num := len(ch)
// 	if num != 0 {
// 		t.Fatalf("Expect empty, but received %d", num)
// 	}
// }

// func TestMetricsCollectedWhenBackupCompleted(t *testing.T) {
// 	createAt := time.Now()
// 	completedAt := createAt.Add(5 * time.Second)
// 	success := util.SucceededState
// 	failed := util.FailedState
// 	deleteID := uint32(1)
// 	fakeTenant := entity.Tenant{
// 		ID:   1,
// 		Name: "pingcap",
// 	}
// 	brs := []entity.Backup{
// 		{
// 			ClusterID: 1,
// 			Base: entity.Base{
// 				System: entity.System{
// 					ID:        1,
// 					CreatedAt: createAt,
// 				},
// 			},
// 			Name: "successful_backup",
// 			Type: central.BackupType_MANUAL,
// 			Operation: &entity.Operation{
// 				CompletedAt: &completedAt,
// 				Status:      &success,
// 			},
// 			Cluster: &entity.Cluster{
// 				Provider: config.Aws,
// 				Region:   "us-west-2",
// 			},
// 		},
// 		{
// 			ClusterID: 2,
// 			Base: entity.Base{
// 				System: entity.System{
// 					ID:        2,
// 					CreatedAt: createAt,
// 				},
// 			},
// 			Name: "failed_backup",
// 			Type: central.BackupType_MANUAL,
// 			Operation: &entity.Operation{
// 				CompletedAt: &completedAt,
// 				Status:      &failed,
// 			},
// 			Cluster: &entity.Cluster{
// 				Provider: config.Gcp,
// 				Region:   "us-west2",
// 			},
// 		},
// 		{
// 			ClusterID: 3,
// 			Base: entity.Base{
// 				System: entity.System{
// 					ID:        3,
// 					CreatedAt: createAt,
// 				},
// 			},
// 			Name: "deleting_backup",
// 			Type: central.BackupType_MANUAL,
// 			Operation: &entity.Operation{
// 				CompletedAt: &completedAt,
// 				Status:      &success,
// 			},
// 			Cluster: &entity.Cluster{
// 				Provider: config.Aws,
// 				Region:   "us-west-2",
// 			},
// 			DeletedID: &deleteID,
// 		},
// 	}
// 	statBackup := func() map[entity.Tenant][]entity.Backup {
// 		return map[entity.Tenant][]entity.Backup{
// 			fakeTenant: brs,
// 		}
// 	}
// 	collector := NewBackupCollector(statBackup)
// 	err := testutil.CollectAndCompare(collector, strings.NewReader(`
// 	# HELP dbaas_backup_execution_status_duration_seconds The time taken and status of backup job execution
//     # TYPE dbaas_backup_execution_status_duration_seconds gauge
//     dbaas_backup_execution_status_duration_seconds{backup_id="1",backup_name="successful_backup",backup_type="MANUAL",cluster_id="1",cluster_name="",shoot="8fd6130c",status="succeeded",tenant_id="1",tenant_name="pingcap"} 5
//     dbaas_backup_execution_status_duration_seconds{backup_id="2",backup_name="failed_backup",backup_type="MANUAL",cluster_id="2",cluster_name="",shoot="a13df0be",status="failed",tenant_id="1",tenant_name="pingcap"} 5
//     dbaas_backup_execution_status_duration_seconds{backup_id="3",backup_name="deleting_backup",backup_type="MANUAL",cluster_id="3",cluster_name="",shoot="8fd6130c",status="deleting",tenant_id="1",tenant_name="pingcap"} 5
// `))
// 	if err != nil {
// 		t.Fatal(err)
// 	}
// }

// func TestMetricsCollectedWhenBackupStillRunning(t *testing.T) {
// 	createAt := time.Now()
// 	running := util.RunningState
// 	fakeTenant := entity.Tenant{
// 		ID:   1,
// 		Name: "pingcap",
// 	}
// 	brs := []entity.Backup{
// 		{
// 			ClusterID: 3,
// 			Base: entity.Base{
// 				System: entity.System{
// 					ID:        3,
// 					CreatedAt: createAt,
// 				},
// 			},
// 			Name: "running_backup",
// 			Type: central.BackupType_MANUAL,
// 			Operation: &entity.Operation{
// 				Status: &running,
// 			},
// 			Cluster: &entity.Cluster{
// 				Provider: config.Aws,
// 				Region:   "us-west-2",
// 			},
// 		},
// 	}
// 	statBackup := func() map[entity.Tenant][]entity.Backup {
// 		return map[entity.Tenant][]entity.Backup{
// 			fakeTenant: brs,
// 		}
// 	}
// 	collector := NewBackupCollector(statBackup)
// 	values := testutil.ToFloat64(collector)
// 	if values <= 0 {
// 		t.Fatal("expected backup job timel taken more than 0")
// 	}
// }
