Skip to content

Commit a790603

Browse files
committed
Added last value
1 parent a0f62cb commit a790603

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

business/tsextractor/tsextractor_test.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ func TestExtractionFlow_defaultAggregation(t *testing.T) {
7070
thingId := "91f30213-2bd7-480a-b1dc-f31b01840e7e"
7171
propertyId := "c86f4ed9-7f52-4bd3-bdc6-b2936bec68ac"
7272
propertyStringId := "a86f4ed9-7f52-4bd3-bdc6-b2936bec68bb"
73+
propertyIdOnChange := "b77f4ed5-7f52-4bd3-bdc6-b2936bec12de"
7374

7475
// Init client
7576
iotcl := iotMocks.NewAPI(t)
@@ -106,7 +107,8 @@ func TestExtractionFlow_defaultAggregation(t *testing.T) {
106107

107108
tsextractorClient := New(iotcl, logger)
108109

109-
propCount := int64(2)
110+
lastValueTime := now.Add(-time.Minute * 1)
111+
propCount := int64(3)
110112
thingsMap := make(map[string]iotclient.ArduinoThing)
111113
thingsMap[thingId] = iotclient.ArduinoThing{
112114
Id: thingId,
@@ -122,6 +124,14 @@ func TestExtractionFlow_defaultAggregation(t *testing.T) {
122124
Id: propertyStringId,
123125
Type: "CHARSTRING",
124126
},
127+
{
128+
Name: "pOnChange",
129+
Id: propertyIdOnChange,
130+
Type: "FLOAT",
131+
UpdateStrategy: "ON_CHANGE",
132+
LastValue: 2.34,
133+
ValueUpdatedAt: &lastValueTime,
134+
},
125135
},
126136
PropertiesCount: &propCount,
127137
}
@@ -149,6 +159,7 @@ func TestExtractionFlow_defaultAggregation(t *testing.T) {
149159
"91f30213-2bd7-480a-b1dc-f31b01840e7e,test,a86f4ed9-7f52-4bd3-bdc6-b2936bec68bb,pstringVar,CHARSTRING,a,",
150160
"91f30213-2bd7-480a-b1dc-f31b01840e7e,test,a86f4ed9-7f52-4bd3-bdc6-b2936bec68bb,pstringVar,CHARSTRING,b,",
151161
"91f30213-2bd7-480a-b1dc-f31b01840e7e,test,a86f4ed9-7f52-4bd3-bdc6-b2936bec68bb,pstringVar,CHARSTRING,c,",
162+
"91f30213-2bd7-480a-b1dc-f31b01840e7e,test,b77f4ed5-7f52-4bd3-bdc6-b2936bec12de,pOnChange,FLOAT,2.34,LAST_VALUE",
152163
}
153164
for _, entry := range entries {
154165
assert.Contains(t, string(content), entry)
@@ -162,6 +173,7 @@ func TestExtractionFlow_rawResolution(t *testing.T) {
162173
thingId := "91f30213-2bd7-480a-b1dc-f31b01840e7e"
163174
propertyId := "c86f4ed9-7f52-4bd3-bdc6-b2936bec68ac"
164175
propertyStringId := "a86f4ed9-7f52-4bd3-bdc6-b2936bec68bb"
176+
propertyIdOnChange := "b77f4ed5-7f52-4bd3-bdc6-b2936bec12de"
165177

166178
// Init client
167179
iotcl := iotMocks.NewAPI(t)
@@ -189,7 +201,8 @@ func TestExtractionFlow_rawResolution(t *testing.T) {
189201

190202
tsextractorClient := New(iotcl, logger)
191203

192-
propCount := int64(2)
204+
lastValueTime := now.Add(-time.Minute * 1)
205+
propCount := int64(3)
193206
thingsMap := make(map[string]iotclient.ArduinoThing)
194207
thingsMap[thingId] = iotclient.ArduinoThing{
195208
Id: thingId,
@@ -205,6 +218,14 @@ func TestExtractionFlow_rawResolution(t *testing.T) {
205218
Id: propertyStringId,
206219
Type: "CHARSTRING",
207220
},
221+
{
222+
Name: "pOnChange",
223+
Id: propertyIdOnChange,
224+
Type: "FLOAT",
225+
UpdateStrategy: "ON_CHANGE",
226+
LastValue: 2.34,
227+
ValueUpdatedAt: &lastValueTime,
228+
},
208229
},
209230
PropertiesCount: &propCount,
210231
}
@@ -232,6 +253,7 @@ func TestExtractionFlow_rawResolution(t *testing.T) {
232253
"91f30213-2bd7-480a-b1dc-f31b01840e7e,test,a86f4ed9-7f52-4bd3-bdc6-b2936bec68bb,pstringVar,CHARSTRING,a",
233254
"91f30213-2bd7-480a-b1dc-f31b01840e7e,test,a86f4ed9-7f52-4bd3-bdc6-b2936bec68bb,pstringVar,CHARSTRING,b",
234255
"91f30213-2bd7-480a-b1dc-f31b01840e7e,test,a86f4ed9-7f52-4bd3-bdc6-b2936bec68bb,pstringVar,CHARSTRING,c",
256+
"91f30213-2bd7-480a-b1dc-f31b01840e7e,test,b77f4ed5-7f52-4bd3-bdc6-b2936bec12de,pOnChange,FLOAT,2.34",
235257
}
236258
for _, entry := range entries {
237259
assert.Contains(t, string(content), entry)

0 commit comments

Comments
 (0)