| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- package aggregator
- import (
- "reflect"
- "testing"
- "time"
- )
- func TestInfoAggregator_AdditionInfo(t *testing.T) {
- type update struct {
- value float64
- timestamp time.Time
- additionalInformation map[string]string
- }
- tests := map[string]struct {
- updates []update
- want map[string]string
- }{
- "no update": {
- updates: []update{},
- want: nil,
- },
- "empty update": {
- updates: []update{
- {},
- },
- want: nil,
- },
- "single update": {
- updates: []update{
- {
- additionalInformation: map[string]string{
- "test": "test",
- },
- },
- },
- want: map[string]string{
- "test": "test",
- },
- },
- "double update": {
- updates: []update{
- {
- additionalInformation: map[string]string{
- "test": "test",
- },
- },
- {
- additionalInformation: map[string]string{
- "test2": "test2",
- },
- },
- },
- want: map[string]string{
- "test2": "test2",
- },
- },
- }
- for name, tt := range tests {
- t.Run(name, func(t *testing.T) {
- agg := infoAggregator{}
- for _, u := range tt.updates {
- agg.Update(u.value, u.timestamp, u.additionalInformation)
- }
- got := agg.AdditionInfo()
- if !reflect.DeepEqual(got, tt.want) {
- t.Errorf("got = %v, want %v", got, tt.want)
- }
- })
- }
- }
|