From 23aee0fb68bb50ef74fee7f7578a6d3a361326f7 Mon Sep 17 00:00:00 2001 From: William Petit Date: Wed, 19 Sep 2018 15:29:44 +0200 Subject: [PATCH] Add flag to execute integration tests --- reach/test.go | 13 +++++++++++++ reach/test_results_test.go | 5 +++++ reach/wifi_networks_test.go | 10 ++++++++++ 3 files changed, 28 insertions(+) create mode 100644 reach/test.go diff --git a/reach/test.go b/reach/test.go new file mode 100644 index 0000000..2142a71 --- /dev/null +++ b/reach/test.go @@ -0,0 +1,13 @@ +package reach + +import "flag" + +var runIntegrationTests = flag.Bool( + "integration", false, + "Run the integration tests (in addition to the unit tests)", +) + +var reachHost = flag.String( + "reach-host", "192.168.42.1", + "The Reach module host to use in integration tests", +) diff --git a/reach/test_results_test.go b/reach/test_results_test.go index 5dbcf29..b7b242a 100644 --- a/reach/test_results_test.go +++ b/reach/test_results_test.go @@ -6,8 +6,13 @@ import ( func TestClientTestResults(t *testing.T) { + if !*runIntegrationTests { + t.Skip("To run this test, use: go test -integration") + } + client := NewClient( WithStandardLogger(), + WithEndpoint(*reachHost, 80), ) if err := client.Connect(); err != nil { t.Fatal(err) diff --git a/reach/wifi_networks_test.go b/reach/wifi_networks_test.go index 667e669..0d4e237 100644 --- a/reach/wifi_networks_test.go +++ b/reach/wifi_networks_test.go @@ -8,8 +8,13 @@ import ( func TestClientSavedWiFiNetworks(t *testing.T) { + if !*runIntegrationTests { + t.Skip("To run this test, use: go test -integration") + } + client := NewClient( WithStandardLogger(), + WithEndpoint(*reachHost, 80), ) if err := client.Connect(); err != nil { t.Fatal(err) @@ -26,8 +31,13 @@ func TestClientSavedWiFiNetworks(t *testing.T) { func TestClientCRUDWiFiNetwork(t *testing.T) { + if !*runIntegrationTests { + t.Skip("To run this test, use: go test -integration") + } + client := NewClient( WithStandardLogger(), + WithEndpoint(*reachHost, 80), ) if err := client.Connect(); err != nil { t.Fatal(err)