From cdb42f0d6b47a60ceb647e3ac6a6ce66352dbae4 Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Thu, 18 Jun 2020 20:42:29 +0200 Subject: [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 --- pkg/backend/mocks.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'pkg/backend/mocks.go') 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) -} -- cgit v1.2.3