// Copyright (c) 2025 Huawei Technologies Co., Ltd.
// openFuyao is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
//          http://license.coscl.org.cn/MulanPSL2
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.

package common

import (
	"reflect"
	"testing"
)

func TestListLabels(t *testing.T) {
	tests := []struct {
		name     string
		labelers Labelers
		want     Labels
	}{
		{
			name: "test list labels",
			labelers: Labelers{
				Labels{"label1": "value1", "label2": "value2"},
				Labels{"label3": "value3", "label4": "value4"},
			},
			want: Labels{"label1": "value1",
				"label2": "value2",
				"label3": "value3",
				"label4": "value4"},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := tt.labelers.Labels(); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("Labels() = %v, want %v", got, tt.want)
			}
		})
	}
}

func TestMergeSuccess(t *testing.T) {
	type args struct {
		labelers Labelers
	}
	tests := []struct {
		name string
		args args
		want Labeler
	}{
		{
			name: "test merge",
			args: args{
				labelers: Labelers{
					Labels{"label1": "value1"},
					Labels{"label2": "value2"},
				},
			},
			want: Labelers{Labels{"label1": "value1"}, Labels{"label2": "value2"}},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := Merge(tt.args.labelers...); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("merge() = %v, want %v", got, tt.want)
			}
		})
	}
}