summaryrefslogtreecommitdiff
path: root/pkg/backend/mocks.go
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-06-18 20:42:29 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-06-26 12:17:30 +0200
commitcdb42f0d6b47a60ceb647e3ac6a6ce66352dbae4 (patch)
tree40f76de30181eb1036d44516e5dd05488c8c31dc /pkg/backend/mocks.go
parent4de5748e25678dce9c5a344afc5fd40508c0860f (diff)
[test] minimal qml tests
just a minimal boilerplate. the idea is to import the qml files and assert that the states/widgets change accordingly if we mock the backend status. - Closes: #300
Diffstat (limited to 'pkg/backend/mocks.go')
-rw-r--r--pkg/backend/mocks.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/pkg/backend/mocks.go b/pkg/backend/mocks.go
index a8ede73..226fa4e 100644
--- a/pkg/backend/mocks.go
+++ b/pkg/backend/mocks.go
@@ -9,6 +9,14 @@ import (
* should also show a good way of writing functionality tests just for the Qml
* layer */
+func enableMockBackend() {
+ log.Println("[+] You should not use this in production!")
+ http.HandleFunc("/on", mockUIOn)
+ http.HandleFunc("/off", mockUIOff)
+ http.HandleFunc("/failed", mockUIFailed)
+ http.ListenAndServe(":8080", nil)
+}
+
func mockUIOn(w http.ResponseWriter, r *http.Request) {
log.Println("changing status: on")
setStatus(on)
@@ -23,10 +31,3 @@ func mockUIFailed(w http.ResponseWriter, r *http.Request) {
log.Println("changing status: failed")
setStatus(failed)
}
-
-func mockUI() {
- http.HandleFunc("/on", mockUIOn)
- http.HandleFunc("/off", mockUIOff)
- http.HandleFunc("/failed", mockUIFailed)
- http.ListenAndServe(":8080", nil)
-}