diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2020-06-12 20:00:13 +0200 |
---|---|---|
committer | kali kaneko (leap communications) <kali@leap.se> | 2020-06-12 20:03:03 +0200 |
commit | 0ac0afaaf312a02af01d1c307ecf9b5915f40b0d (patch) | |
tree | b2d0b9a776c47c5c2cac90595a9721730e59a519 /pkg/backend/mocks.go | |
parent | 1038fa83b820bbdaa9bcf37118cf23b0e48a86c5 (diff) |
[refactor] reorganize backend in its own module
Signed-off-by: kali kaneko (leap communications) <kali@leap.se>
Diffstat (limited to 'pkg/backend/mocks.go')
-rw-r--r-- | pkg/backend/mocks.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/pkg/backend/mocks.go b/pkg/backend/mocks.go new file mode 100644 index 0000000..a8ede73 --- /dev/null +++ b/pkg/backend/mocks.go @@ -0,0 +1,32 @@ +package backend + +import ( + "log" + "net/http" +) + +/* mock http server: easy way to mocking vpn behavior on ui interaction. This +* should also show a good way of writing functionality tests just for the Qml +* layer */ + +func mockUIOn(w http.ResponseWriter, r *http.Request) { + log.Println("changing status: on") + setStatus(on) +} + +func mockUIOff(w http.ResponseWriter, r *http.Request) { + log.Println("changing status: off") + setStatus(off) +} + +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) +} |