-
Notifications
You must be signed in to change notification settings - Fork 0
/
knxproj_test.go
41 lines (32 loc) · 909 Bytes
/
knxproj_test.go
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
package knxproj_test
import (
"bytes"
"encoding/json"
"flag"
"io/ioutil"
"os"
"testing"
"github.com/yene/knxproj"
)
const tmpFolder = "temp/"
var update = flag.Bool("update", false, "update golden file")
func TestAll(t *testing.T) {
knxprojFile := "test-fixtures/DemoCase.knxproj"
err := knxproj.Unzip(knxprojFile, tmpFolder)
if err != nil {
t.Error("unzip error", err)
}
knxproj.Language = "en-US"
knxproj.ParseManufacturers(tmpFolder)
knxproj.ReadManufacturerData(tmpFolder)
knxproj.ReadProjects(tmpFolder)
os.RemoveAll(tmpFolder)
rankingsJSON, _ := json.MarshalIndent(knxproj.MainProject, "", " ")
if *update {
ioutil.WriteFile("test-fixtures/DemoCase.json.golden", rankingsJSON, 0644)
}
expected, _ := ioutil.ReadFile("test-fixtures/DemoCase.json.golden")
if !bytes.Equal(rankingsJSON, expected) {
t.Error("Generated JSON is different from DemoCase.json.golden")
}
}