mirror of
https://github.com/eolinker/apinto
synced 2025-10-02 23:54:58 +08:00
95 lines
1.7 KiB
Go
95 lines
1.7 KiB
Go
package plugin
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestMergeConfig(t *testing.T) {
|
|
type args struct {
|
|
high map[string]*Config
|
|
low map[string]*Config
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want map[string]*Config
|
|
}{
|
|
{
|
|
name: "high nil",
|
|
args: args{
|
|
high: nil,
|
|
low: map[string]*Config{
|
|
"low": {
|
|
Disable: false,
|
|
Config: "low",
|
|
},
|
|
},
|
|
},
|
|
want: map[string]*Config{
|
|
"low": {
|
|
Disable: false,
|
|
Config: "low",
|
|
},
|
|
},
|
|
}, {
|
|
name: "low nil",
|
|
args: args{
|
|
high: map[string]*Config{
|
|
"high": {Disable: false, Config: "high"},
|
|
},
|
|
},
|
|
want: map[string]*Config{
|
|
"high": {Disable: false, Config: "high"},
|
|
},
|
|
}, {
|
|
name: "merge",
|
|
args: args{
|
|
high: map[string]*Config{
|
|
"high": {Disable: false, Config: "high"},
|
|
}, low: map[string]*Config{
|
|
"low": {
|
|
Disable: false,
|
|
Config: "low",
|
|
},
|
|
},
|
|
},
|
|
want: map[string]*Config{
|
|
"high": {Disable: false, Config: "high"},
|
|
"low": {
|
|
Disable: false,
|
|
Config: "low",
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "high",
|
|
args: args{
|
|
high: map[string]*Config{
|
|
"high": {Disable: false, Config: "high"},
|
|
"low": {Disable: false, Config: "high"},
|
|
}, low: map[string]*Config{
|
|
"low": {
|
|
Disable: false,
|
|
Config: "low",
|
|
},
|
|
},
|
|
},
|
|
want: map[string]*Config{
|
|
"high": {Disable: false, Config: "high"},
|
|
"low": {
|
|
Disable: false,
|
|
Config: "high",
|
|
},
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := MergeConfig(tt.args.high, tt.args.low); !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("MergeConfig() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|