1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-18 08:26:38 +02:00
go-micro/util/qson/merge_test.go
Vasiliy Tolstov 6fa27373ed
bundle qson lib in util (#1561)
* copy qson from https://github.com/joncalhoun/qson
  as author not want to maintain repo
* latest code contains our fix to proper decode strings
  with escaped & symbol
* replace package in api/handler/rpc

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-23 11:08:09 +03:00

38 lines
823 B
Go

package qson
import "testing"
func TestMergeSlice(t *testing.T) {
a := []interface{}{"a"}
b := []interface{}{"b"}
actual := mergeSlice(a, b)
if len(actual) != 2 {
t.Errorf("Expected size to be 2.")
}
if actual[0] != "a" {
t.Errorf("Expected index 0 to have value a. Actual: %s", actual[0])
}
if actual[1] != "b" {
t.Errorf("Expected index 1 to have value b. Actual: %s", actual[1])
}
}
func TestMergeMap(t *testing.T) {
a := map[string]interface{}{
"a": "b",
}
b := map[string]interface{}{
"b": "c",
}
actual := mergeMap(a, b)
if len(actual) != 2 {
t.Errorf("Expected size to be 2.")
}
if actual["a"] != "b" {
t.Errorf("Expected key \"a\" to have value b. Actual: %s", actual["a"])
}
if actual["b"] != "c" {
t.Errorf("Expected key \"b\" to have value c. Actual: %s", actual["b"])
}
}