package k8supgrade

import (
	"context"
	"testing"
)

func TestNonProdClusters_Matches(t *testing.T) {
	tests := []struct {
		name string
		info *K8sInfo
		want bool
	}{
		{
			name: "upper case",
			info: &K8sInfo{TiDBClusters: []*TiDBClusterInfraInfo{
				{Name: "pressure-TEST"},
			}},
			want: true,
		},
		{
			name: "mix",
			info: &K8sInfo{TiDBClusters: []*TiDBClusterInfraInfo{
				{Name: "production-dev"},
			}},
			want: false,
		},
		{
			name: "more than one clusters and has prod",
			info: &K8sInfo{TiDBClusters: []*TiDBClusterInfraInfo{
				{Name: "prod"},
				{Name: "dev"},
				{Name: "staging"},
			}},
			want: false,
		},
		{
			name: "more than one clusters but does not have prod",
			info: &K8sInfo{TiDBClusters: []*TiDBClusterInfraInfo{
				{Name: "dev"},
				{Name: "staging"},
				{Name: "testing"},
			}},
			want: true,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			s := &NonProdClusters{}
			if got := s.Matches(context.TODO(), tt.info); got != tt.want {
				t.Errorf("Matches() = %v, want %v", got, tt.want)
			}
		})
	}
}
