File: statistic_test.go

package info (click to toggle)
golang-github-influxdata-influxdb1-client 0.0~git20220302.a9ab567-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 380 kB
  • sloc: makefile: 2
file content (55 lines) | stat: -rw-r--r-- 1,318 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package models_test

import (
	"reflect"
	"testing"

	"github.com/influxdata/influxdb1-client/models"
)

func TestTags_Merge(t *testing.T) {
	examples := []struct {
		Base   map[string]string
		Arg    map[string]string
		Result map[string]string
	}{
		{
			Base:   nil,
			Arg:    nil,
			Result: map[string]string{},
		},
		{
			Base:   nil,
			Arg:    map[string]string{"foo": "foo"},
			Result: map[string]string{"foo": "foo"},
		},
		{
			Base:   map[string]string{"foo": "foo"},
			Arg:    nil,
			Result: map[string]string{"foo": "foo"},
		},
		{
			Base:   map[string]string{"foo": "foo"},
			Arg:    map[string]string{"bar": "bar"},
			Result: map[string]string{"foo": "foo", "bar": "bar"},
		},
		{
			Base:   map[string]string{"foo": "foo", "bar": "bar"},
			Arg:    map[string]string{"zoo": "zoo"},
			Result: map[string]string{"foo": "foo", "bar": "bar", "zoo": "zoo"},
		},
		{
			Base:   map[string]string{"foo": "foo", "bar": "bar"},
			Arg:    map[string]string{"bar": "newbar"},
			Result: map[string]string{"foo": "foo", "bar": "newbar"},
		},
	}

	for i, example := range examples {
		i++
		result := models.StatisticTags(example.Base).Merge(example.Arg)
		if got, exp := result, example.Result; !reflect.DeepEqual(got, exp) {
			t.Errorf("[Example %d] got %#v, expected %#v", i, got, exp)
		}
	}
}