test(pkg/logfile): remove old test files

This commit is contained in:
Markus Pesch 2019-07-14 19:05:44 +02:00
parent 3feee7764b
commit 31accbd742
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
14 changed files with 0 additions and 337 deletions

View File

@ -1,133 +1 @@
package logfile_test
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/go-flucky/flucky/pkg/logfile"
uuid "github.com/satori/go.uuid"
"github.com/stretchr/testify/require"
)
var tmpDir = os.TempDir()
type interfaceMap struct {
testFile string
logfileA logfile.Logfile
goldenFile string
logfileB logfile.Logfile
}
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"}
for _, markupLanguageFrom := range markupLanguages {
testDir, cleanup := createTestDir(t)
defer cleanup()
for _, markupLanguageTo := range markupLanguages {
convertMaps := []*interfaceMap{
&interfaceMap{
testFile: fmt.Sprintf("pkg/logfile/test/%v/validTemperatures_01.%v", markupLanguageFrom, markupLanguageFrom),
logfileA: logfile.New(filepath.Join(testDir, fmt.Sprintf("validTemperatures_01.%v", markupLanguageFrom))),
goldenFile: fmt.Sprintf("pkg/logfile/test/%v/validTemperatures_01.%v", markupLanguageTo, markupLanguageTo),
logfileB: logfile.New(filepath.Join(testDir, fmt.Sprintf("validTemperatures_01.%v", markupLanguageTo))),
},
&interfaceMap{
testFile: fmt.Sprintf("pkg/logfile/test/%v/validTemperatures_02.%v", markupLanguageFrom, markupLanguageFrom),
logfileA: logfile.New(filepath.Join(testDir, fmt.Sprintf("validTemperatures_02.%v", markupLanguageFrom))),
goldenFile: fmt.Sprintf("pkg/logfile/test/%v/validTemperatures_02.%v", markupLanguageTo, markupLanguageTo),
logfileB: logfile.New(filepath.Join(testDir, fmt.Sprintf("validTemperatures_02.%v", markupLanguageTo))),
},
}
createTestFiles(t, convertMaps)
for _, convertMap := range convertMaps {
temperatures, err := convertMap.logfileA.ReadTemperatures()
require.Nil(err)
err = convertMap.logfileB.WriteTemperatures(temperatures)
require.Nil(err)
verifyFileWithAsset(t, convertMap.logfileB.GetLogfile(), convertMap.goldenFile)
}
}
}
}
func createTestFiles(t *testing.T, interfaceMaps []*interfaceMap) {
require := require.New(t)
for _, interfaceMap := range interfaceMaps {
f, err := os.Create(interfaceMap.logfileA.GetLogfile())
require.Nil(err)
f.Write(MustAsset(interfaceMap.testFile))
f.Close()
verifyFileWithAsset(t, interfaceMap.logfileA.GetLogfile(), interfaceMap.testFile)
}
}
func createTestDir(t *testing.T) (string, func() error) {
require := require.New(t)
testDir := filepath.Join(tmpDir, uuid.NewV4().String())
err := os.MkdirAll(testDir, 0755)
require.Nil(err)
rmDir := func() error {
return os.RemoveAll(testDir)
}
return testDir, rmDir
}
func verifyFileWithAsset(t *testing.T, file string, asset string) {
require := require.New(t)
f, err := os.Open(file)
require.Nil(err)
defer f.Close()
bytes, err := ioutil.ReadAll(f)
require.Nil(err)
require.Equalf(string(MustAsset(asset)), string(bytes), "Asset %v and file %v not even", asset, file)
}

View File

@ -1,2 +0,0 @@
a469503b-fc16-4e72-8d29-7eeee08ba957,24.562,celsius,2019-06-14 21:15:28.504051541 +0200,2019-06-14 21:18:07.384104493 +0200,84eac248-6927-4db6-b6f9-7891ce2d301e,2019-06-14 21:18:07.465885864 +0200,2019-06-14 21:18:07.46587076 +0200
5f119ba3-bcea-4c3b-aabb-0406ea70f7e1,24.375,celsius,2019-06-14 21:15:28.583856443 +0200,2019-06-14 21:18:07.463893776 +0200,efcd755e-82d1-4789-a50b-355b8735b8d8,2019-06-14 21:18:07.465885864 +0200,2019-06-14 21:18:07.46587701 +0200
1 a469503b-fc16-4e72-8d29-7eeee08ba957 24.562 celsius 2019-06-14 21:15:28.504051541 +0200 2019-06-14 21:18:07.384104493 +0200 84eac248-6927-4db6-b6f9-7891ce2d301e 2019-06-14 21:18:07.465885864 +0200 2019-06-14 21:18:07.46587076 +0200
2 5f119ba3-bcea-4c3b-aabb-0406ea70f7e1 24.375 celsius 2019-06-14 21:15:28.583856443 +0200 2019-06-14 21:18:07.463893776 +0200 efcd755e-82d1-4789-a50b-355b8735b8d8 2019-06-14 21:18:07.465885864 +0200 2019-06-14 21:18:07.46587701 +0200

View File

@ -1,2 +0,0 @@
a469503b-fc16-4e72-8d29-7eeee08ba957,24.562,celsius,2019-06-14 21:15:28.504051541 +0200,2019-06-14 21:18:07.384104493 +0200,84eac248-6927-4db6-b6f9-7891ce2d301e,2019-06-14 21:18:07.465885864 +0200,2019-06-14 21:18:07.46587076 +0200
5f119ba3-bcea-4c3b-aabb-0406ea70f7e1,24.375,celsius,2019-06-14 21:15:28.583856443 +0200,2019-06-14 21:15:28.583856443 +0200,efcd755e-82d1-4789-a50b-355b8735b8d8,2019-06-14 21:18:07.465885864 +0200,
1 a469503b-fc16-4e72-8d29-7eeee08ba957 24.562 celsius 2019-06-14 21:15:28.504051541 +0200 2019-06-14 21:18:07.384104493 +0200 84eac248-6927-4db6-b6f9-7891ce2d301e 2019-06-14 21:18:07.465885864 +0200 2019-06-14 21:18:07.46587076 +0200
2 5f119ba3-bcea-4c3b-aabb-0406ea70f7e1 24.375 celsius 2019-06-14 21:15:28.583856443 +0200 2019-06-14 21:15:28.583856443 +0200 efcd755e-82d1-4789-a50b-355b8735b8d8 2019-06-14 21:18:07.465885864 +0200

View File

@ -1,12 +0,0 @@
[
{
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
"temperature_value": "24.562",
"temperature_unit": "celsius",
"temperature_from_date": "2019-10-01T00:00:00+02:00",
"temperature_till_date": "2019-05-01T00:00:00+02:00",
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
"creation_date": "2019-05-01T00:00:00+02:00",
"update_date": "2019-10-01T00:00:00+02:00"
}
]

View File

@ -1,12 +0,0 @@
[
{
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
"temperature_value": "24.562",
"temperature_unit": "celsius",
"temperature_from_date": "2019-05-01T00:00:00+02:00",
"temperature_till_date": "2019-10-01T00:00:00+02:00",
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
"creation_date": "2019-10-01T00:00:00+02:00",
"update_date": "2019-05-01T00:00:00+02:00"
}
]

View File

@ -1,12 +0,0 @@
[
{
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
"temperature_value": "24.562",
"temperature_unit": "celsius",
"temperature_from_date": "2019-05-01T00:00:00+02:00",
"temperature_till_date": "2019-10-01T00:00:00+02:00",
"sensor_id": "",
"creation_date": "2019-05-01T00:00:00+02:00",
"update_date": "2019-10-01T00:00:00+02:00"
}
]

View File

@ -1,12 +0,0 @@
[
{
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
"temperature_value": "0",
"temperature_unit": "celsius",
"temperature_from_date": "2019-05-01T00:00:00+02:00",
"temperature_till_date": "2019-10-01T00:00:00+02:00",
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
"creation_date": "2019-05-01T00:00:00+02:00",
"update_date": "2019-10-01T00:00:00+02:00"
}
]

View File

@ -1,12 +0,0 @@
[
{
"temperature_id": "",
"temperature_value": "24.562",
"temperature_unit": "celsius",
"temperature_from_date": "2019-05-01T00:00:00+02:00",
"temperature_till_date": "2019-10-01T00:00:00+02:00",
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
"creation_date": "2019-05-01T00:00:00+02:00",
"update_date": "2019-10-01T00:00:00+02:00"
}
]

View File

@ -1,22 +0,0 @@
[
{
"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
}
]

View File

@ -1,32 +0,0 @@
[
{
"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
}
]

View File

@ -1,22 +0,0 @@
[
{
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
"temperature_value": "24.562",
"temperature_unit": "celsius",
"temperature_from_date": "2019-06-14T21:15:28.504051541+02:00",
"temperature_till_date": "2019-06-14T21:18:07.384104493+02:00",
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
"creation_date": "2019-06-14T21:18:07.465885864+02:00",
"update_date": "2019-06-14T21:18:07.46587076+02:00"
},
{
"temperature_id": "5f119ba3-bcea-4c3b-aabb-0406ea70f7e1",
"temperature_value": "24.375",
"temperature_unit": "celsius",
"temperature_from_date": "2019-06-14T21:15:28.583856443+02:00",
"temperature_till_date": "2019-06-14T21:18:07.463893776+02:00",
"sensor_id": "efcd755e-82d1-4789-a50b-355b8735b8d8",
"creation_date": "2019-06-14T21:18:07.465885864+02:00",
"update_date": "2019-06-14T21:18:07.46587701+02:00"
}
]

View File

@ -1,22 +0,0 @@
[
{
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
"temperature_value": "24.562",
"temperature_unit": "celsius",
"temperature_from_date": "2019-06-14T21:15:28.504051541+02:00",
"temperature_till_date": "2019-06-14T21:18:07.384104493+02:00",
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
"creation_date": "2019-06-14T21:18:07.465885864+02:00",
"update_date": "2019-06-14T21:18:07.46587076+02:00"
},
{
"temperature_id": "5f119ba3-bcea-4c3b-aabb-0406ea70f7e1",
"temperature_value": "24.375",
"temperature_unit": "celsius",
"temperature_from_date": "2019-06-14T21:15:28.583856443+02:00",
"temperature_till_date": "2019-06-14T21:15:28.583856443+02:00",
"sensor_id": "efcd755e-82d1-4789-a50b-355b8735b8d8",
"creation_date": "2019-06-14T21:18:07.465885864+02:00",
"update_date": null
}
]

View File

@ -1,22 +0,0 @@
<temperatures>
<temperature>
<temperature_id>a469503b-fc16-4e72-8d29-7eeee08ba957</temperature_id>
<temperature_value>24.562</temperature_value>
<temperature_unit>celsius</temperature_unit>
<temperature_from_date>2019-06-14T21:15:28.504051541+02:00</temperature_from_date>
<temperature_till_date>2019-06-14T21:18:07.384104493+02:00</temperature_till_date>
<sensor_id>84eac248-6927-4db6-b6f9-7891ce2d301e</sensor_id>
<creation_date>2019-06-14T21:18:07.465885864+02:00</creation_date>
<update_date>2019-06-14T21:18:07.46587076+02:00</update_date>
</temperature>
<temperature>
<temperature_id>5f119ba3-bcea-4c3b-aabb-0406ea70f7e1</temperature_id>
<temperature_value>24.375</temperature_value>
<temperature_unit>celsius</temperature_unit>
<temperature_from_date>2019-06-14T21:15:28.583856443+02:00</temperature_from_date>
<temperature_till_date>2019-06-14T21:18:07.463893776+02:00</temperature_till_date>
<sensor_id>efcd755e-82d1-4789-a50b-355b8735b8d8</sensor_id>
<creation_date>2019-06-14T21:18:07.465885864+02:00</creation_date>
<update_date>2019-06-14T21:18:07.46587701+02:00</update_date>
</temperature>
</temperatures>

View File

@ -1,21 +0,0 @@
<temperatures>
<temperature>
<temperature_id>a469503b-fc16-4e72-8d29-7eeee08ba957</temperature_id>
<temperature_value>24.562</temperature_value>
<temperature_unit>celsius</temperature_unit>
<temperature_from_date>2019-06-14T21:15:28.504051541+02:00</temperature_from_date>
<temperature_till_date>2019-06-14T21:18:07.384104493+02:00</temperature_till_date>
<sensor_id>84eac248-6927-4db6-b6f9-7891ce2d301e</sensor_id>
<creation_date>2019-06-14T21:18:07.465885864+02:00</creation_date>
<update_date>2019-06-14T21:18:07.46587076+02:00</update_date>
</temperature>
<temperature>
<temperature_id>5f119ba3-bcea-4c3b-aabb-0406ea70f7e1</temperature_id>
<temperature_value>24.375</temperature_value>
<temperature_unit>celsius</temperature_unit>
<temperature_from_date>2019-06-14T21:15:28.583856443+02:00</temperature_from_date>
<temperature_till_date>2019-06-14T21:15:28.583856443+02:00</temperature_till_date>
<sensor_id>efcd755e-82d1-4789-a50b-355b8735b8d8</sensor_id>
<creation_date>2019-06-14T21:18:07.465885864+02:00</creation_date>
</temperature>
</temperatures>