-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapps_test.go
More file actions
59 lines (49 loc) · 1.64 KB
/
Copy pathapps_test.go
File metadata and controls
59 lines (49 loc) · 1.64 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// (c) Siemens AG 2023
//
// SPDX-License-Identifier: MIT
package ieddata
import (
"os"
"path"
"time"
"github.com/jmoiron/sqlx"
"github.com/thediveo/lxkns/model"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/thediveo/fdooze"
. "github.com/thediveo/success"
)
var _ = Describe("IED app engine installed apps", func() {
BeforeEach(func() {
goodfds := Filedescriptors()
DeferCleanup(func() {
Expect(Filedescriptors()).NotTo(HaveLeakedFds(goodfds))
})
})
It("self-tests db", func() {
db := Successful(sqlx.Open(dbDriverName,
path.Join(Successful(os.Getwd()), "tests/sqlite-alpine-appengine-db/test-apps-and-device.db?mode=ro")))
defer func() { Expect(db.Close()).To(Succeed()) }()
Expect(db.Ping()).To(Succeed())
})
FIt("reads installed app information", func() {
// Use a local test database, so we don't need to rely on an (fake) edge
// core running.
cwd := Successful(os.Getwd())
db := Successful(open(path.Join(cwd, "tests/sqlite-alpine-appengine-db/test-apps-and-device.db"), model.PIDType(os.Getpid())))
defer func() { Expect(db.Close()).To(Succeed()) }()
apps := Successful(db.Apps())
Expect(apps).To(HaveLen(4))
t0 := Successful(time.Parse("2006-01-02", "2021-01-01"))
Expect(apps).To(HaveEach(SatisfyAll(
HaveField("Id", Not(BeZero())),
HaveField("Version", Not(BeZero())),
HaveField("VersionId", Not(BeZero())),
HaveField("ProjectId", Not(BeZero())),
HaveField("Created.Unix()", BeNumerically(">=", t0.Unix())),
HaveField("Id", Not(BeZero())),
HaveField("IconPath", Not(BeZero())),
)))
Expect(apps).To(ContainElement(HaveField("IsDebuggingEnabled", 1)))
})
})