test(pkg/logfile): compress temperature logfile
This commit is contained in:
parent
c8a1dd2935
commit
5f53207f0a
@ -21,7 +21,36 @@ type interfaceMap struct {
|
||||
logfileB logfile.Logfile
|
||||
}
|
||||
|
||||
func TestConvert(t *testing.T) {
|
||||
func TestCompression(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
testDir, cleanup := createTestDir(t)
|
||||
defer cleanup()
|
||||
|
||||
testfiles := []*interfaceMap{
|
||||
&interfaceMap{
|
||||
testFile: "pkg/logfile/test/json/testCompression_01.json",
|
||||
logfileA: logfile.New(filepath.Join(testDir, "testCompression_01.json")),
|
||||
goldenFile: "pkg/logfile/test/json/goldenCompression_01.json",
|
||||
logfileB: logfile.New(filepath.Join(testDir, "goldenCompression_01.json")),
|
||||
},
|
||||
}
|
||||
|
||||
createTestFiles(t, testfiles)
|
||||
|
||||
temperatures, err := testfiles[0].logfileA.ReadTemperatures()
|
||||
require.Nil(err)
|
||||
|
||||
temperatures = logfile.CompressTemperature(temperatures)
|
||||
|
||||
diffLogfile := logfile.New(filepath.Join(testDir, "diffCompression_01.json"))
|
||||
err = diffLogfile.WriteTemperatures(temperatures)
|
||||
require.Nil(err)
|
||||
|
||||
// verifyFileWithAsset(t, filepath.Join(testDir, "diffCompression_01.json"), "pkg/logfile/test/json/goldenCompression_01.json")
|
||||
}
|
||||
|
||||
func TestConvertTemperatures(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
markupLanguages := []string{"csv", "json", "xml"}
|
||||
|
22
pkg/logfile/test/json/goldenCompression_01.json
Normal file
22
pkg/logfile/test/json/goldenCompression_01.json
Normal file
@ -0,0 +1,22 @@
|
||||
[
|
||||
{
|
||||
"temperature_id": "96b93a1c-414c-49d7-82e0-fc57aa313551",
|
||||
"temperature_value": "28",
|
||||
"temperature_unit": "celsius",
|
||||
"temperature_from_date": "2019-06-24T20:27:16.455833877+02:00",
|
||||
"temperature_till_date": "2019-06-24T20:27:19.335708331+02:00",
|
||||
"sensor_id": "efcd755e-82d1-4789-a50b-355b8735b8d8",
|
||||
"creation_date": "2019-06-24T20:27:38.712842338+02:00",
|
||||
"update_date": "2019-06-24T20:27:19.338708331+02:00"
|
||||
},
|
||||
{
|
||||
"temperature_id": "2ae8be89-e31a-4b97-b8ba-aea9e54b8ed1",
|
||||
"temperature_value": "27.75",
|
||||
"temperature_unit": "celsius",
|
||||
"temperature_from_date": "2019-06-24T20:27:23.175690867+02:00",
|
||||
"temperature_till_date": "2019-06-24T20:27:23.175692898+02:00",
|
||||
"sensor_id": "efcd755e-82d1-4789-a50b-355b8735b8d8",
|
||||
"creation_date": "2019-06-24T20:27:38.712842338+02:00",
|
||||
"update_date": null
|
||||
}
|
||||
]
|
32
pkg/logfile/test/json/testCompression_01.json
Normal file
32
pkg/logfile/test/json/testCompression_01.json
Normal file
@ -0,0 +1,32 @@
|
||||
[
|
||||
{
|
||||
"temperature_id": "96b93a1c-414c-49d7-82e0-fc57aa313551",
|
||||
"temperature_value": "28",
|
||||
"temperature_unit": "celsius",
|
||||
"temperature_from_date": "2019-06-24T20:27:16.455833877+02:00",
|
||||
"temperature_till_date": "2019-06-24T20:27:16.455836117+02:00",
|
||||
"sensor_id": "efcd755e-82d1-4789-a50b-355b8735b8d8",
|
||||
"creation_date": "2019-06-24T20:27:38.712842338+02:00",
|
||||
"update_date": null
|
||||
},
|
||||
{
|
||||
"temperature_id": "da4c443b-81e7-4d23-9ad4-f912c476098a",
|
||||
"temperature_value": "28",
|
||||
"temperature_unit": "celsius",
|
||||
"temperature_from_date": "2019-06-24T20:27:19.33570604+02:00",
|
||||
"temperature_till_date": "2019-06-24T20:27:19.335708331+02:00",
|
||||
"sensor_id": "efcd755e-82d1-4789-a50b-355b8735b8d8",
|
||||
"creation_date": "2019-06-24T20:27:38.712842338+02:00",
|
||||
"update_date": null
|
||||
},
|
||||
{
|
||||
"temperature_id": "2ae8be89-e31a-4b97-b8ba-aea9e54b8ed1",
|
||||
"temperature_value": "27.75",
|
||||
"temperature_unit": "celsius",
|
||||
"temperature_from_date": "2019-06-24T20:27:23.175690867+02:00",
|
||||
"temperature_till_date": "2019-06-24T20:27:23.175692898+02:00",
|
||||
"sensor_id": "efcd755e-82d1-4789-a50b-355b8735b8d8",
|
||||
"creation_date": "2019-06-24T20:27:38.712842338+02:00",
|
||||
"update_date": null
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue
Block a user