Skip to content
This repository was archived by the owner on Mar 22, 2025. It is now read-only.

Commit 9996348

Browse files
committed
test
1 parent d6de189 commit 9996348

File tree

2 files changed

+45
-6
lines changed

2 files changed

+45
-6
lines changed

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Updates 3rd party packages and tools
2+
deps:
3+
go mod download
4+
go install github.com/securego/gosec/v2/cmd/gosec@latest
5+
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
16

27
# Run tests and log the test coverage
38
test:
@@ -21,12 +26,6 @@ analyse:
2126
@echo -e "\nCYCLOMATIC COMPLEXITY\n===================="
2227
gocyclo -avg -top 10 .
2328

24-
# Updates 3rd party packages and tools
25-
deps:
26-
go mod download
27-
go install github.com/securego/gosec/v2/cmd/gosec@latest
28-
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
29-
3029
# Show documentation of public parts of package, in the current dir
3130
docs:
3231
go doc -all

ZigBeeValve/zigbee_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,43 @@ func TestNewResource(t *testing.T) {
171171
sys.UAssets[ua.GetName()] = &ua
172172
}
173173
}
174+
175+
func TestfeedbackLoop() {
176+
ctx, cancel := context.WithCancel(context.Background())
177+
defer cancel()
178+
179+
// instantiate the System
180+
sys := components.NewSystem("testsys", ctx)
181+
182+
// Instatiate the Capusle
183+
sys.Husk = &components.Husk{
184+
Description: " is a controller for smart thermostats connected with a RaspBee II",
185+
Certificate: "ABCD",
186+
Details: map[string][]string{"Developer": {"Arrowhead"}},
187+
ProtoPort: map[string]int{"https": 0, "http": 8870, "coap": 0},
188+
InfoLink: "https://github.com/sdoque/systems/tree/master/ZigBeeValve",
189+
}
190+
191+
// instantiate a template unit asset
192+
assetTemplate := initTemplate()
193+
assetName := assetTemplate.GetName()
194+
sys.UAssets[assetName] = &assetTemplate
195+
196+
// Configure the system
197+
rawResources, servsTemp, err := usecases.Configure(&sys)
198+
if err != nil {
199+
log.Fatalf("Configuration error: %v\n", err)
200+
}
201+
sys.UAssets = make(map[string]*components.UnitAsset) // clear the unit asset map (from the template)
202+
for _, raw := range rawResources {
203+
var uac UnitAsset
204+
if err := json.Unmarshal(raw, &uac); err != nil {
205+
log.Fatalf("Resource configuration error: %+v\n", err)
206+
}
207+
ua, startup := newResource(uac, &sys, servsTemp)
208+
startup()
209+
sys.UAssets[ua.GetName()] = &ua
210+
}
211+
212+
// TODO: Test feedbackloop and processfeedbackloop
213+
}

0 commit comments

Comments
 (0)