package restore

// 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/prometheus/client_golang/prometheus"
// 	"github.com/prometheus/client_golang/prometheus/testutil"
// )

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

// 	statRestore := func() map[entity.Tenant][]entity.Restore {
// 		return make(map[entity.Tenant][]entity.Restore)
// 	}
// 	collector := NewRestoreCollector(statRestore)
// 	collector.Collect(ch)

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

// func TestMetricsCollectedWhenRestoreCompleted(t *testing.T) {
// 	createAt := time.Now()
// 	completedAt := createAt.Add(5 * time.Second)
// 	success := util.SucceededState
// 	failed := util.FailedState
// 	fakeTenant := entity.Tenant{
// 		ID:   1,
// 		Name: "pingcap",
// 	}
// 	brs := []entity.Restore{
// 		{
// 			ClusterID: 1,
// 			Base: entity.Base{
// 				System: entity.System{
// 					ID:        1,
// 					CreatedAt: createAt,
// 				},
// 			},
// 			Name: "successful_restore",
// 			Operation: &entity.Operation{
// 				CompletedAt: &completedAt,
// 				Status:      &success,
// 			},
// 			Cluster: &entity.Cluster{
// 				Provider: config.Aws,
// 				Region:   "us-west-2",
// 				Name:     "aws-cluster",
// 			},
// 		},
// 		{
// 			ClusterID: 2,
// 			Base: entity.Base{
// 				System: entity.System{
// 					ID:        2,
// 					CreatedAt: createAt,
// 				},
// 			},
// 			Name: "failed_restore",
// 			Operation: &entity.Operation{
// 				CompletedAt: &completedAt,
// 				Status:      &failed,
// 			},
// 			Cluster: &entity.Cluster{
// 				Provider: config.Gcp,
// 				Region:   "us-west2",
// 				Name:     "gcp-cluster",
// 			},
// 		},
// 	}
// 	statRestore := func() map[entity.Tenant][]entity.Restore {
// 		return map[entity.Tenant][]entity.Restore{
// 			fakeTenant: brs,
// 		}
// 	}
// 	collector := NewRestoreCollector(statRestore)
// 	err := testutil.CollectAndCompare(collector, strings.NewReader(`
// 	# HELP dbaas_restore_execution_status_duration_seconds The time taken and status of restore job execution
//     # TYPE dbaas_restore_execution_status_duration_seconds gauge
//     dbaas_restore_execution_status_duration_seconds{cluster_id="1",cluster_name="aws-cluster",restore_id="1",restore_name="successful_restore",shoot="8fd6130c",status="succeeded",tenant_id="1",tenant_name="pingcap"} 5
//     dbaas_restore_execution_status_duration_seconds{cluster_id="2",cluster_name="gcp-cluster",restore_id="2",restore_name="failed_restore",shoot="a13df0be",status="failed",tenant_id="1",tenant_name="pingcap"} 5
// `))
// 	if err != nil {
// 		t.Fatal(err)
// 	}
// }

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