package k8s

import (
	"testing"

	"github.com/google/go-cmp/cmp"
	"github.com/stretchr/testify/require"
)

func TestTiDBClusterClient_normalizeRawSpec(t1 *testing.T) {
	type args struct {
		spec map[string]interface{}
	}
	tests := []struct {
		name   string
		args   args
		expect args
	}{
		{
			name: "tiflash with config",
			args: args{spec: map[string]interface{}{
				"tiflash": map[string]interface{}{
					"config": `log-level = "info"`,
				},
			}},
			expect: args{spec: map[string]interface{}{
				"tiflash": map[string]interface{}{
					"config": map[string]interface{}{
						"config": `log-level = "info"`,
					},
				},
			}},
		},
	}
	for _, tt := range tests {
		t1.Run(tt.name, func(t1 *testing.T) {
			t := TiDBClusterClient{}
			t.normalizeRawSpec(tt.args.spec)
			require.True(t1, cmp.Equal(tt.expect.spec, tt.args.spec))
		})
	}
}
