From f25ef58c0a1941ce88cb026b44ca34a99133b366 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Tue, 29 Sep 2015 19:49:07 -0700 Subject: [PATCH] Separate error case of Particle nee Spark tests to avoid confusion --- platforms/spark/spark_core_adaptor_test.go | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/platforms/spark/spark_core_adaptor_test.go b/platforms/spark/spark_core_adaptor_test.go index b4b748d1..e3e05ec5 100644 --- a/platforms/spark/spark_core_adaptor_test.go +++ b/platforms/spark/spark_core_adaptor_test.go @@ -100,19 +100,22 @@ func TestSparkCoreAdaptorAnalogRead(t *testing.T) { testServer := getDummyResponseForPathWithParams("/"+a.DeviceID+"/analogread", params, response, t) a.setAPIServer(testServer.URL) + defer testServer.Close() val, _ := a.AnalogRead("A1") gobot.Assert(t, val, 5) +} - testServer.Close() - +func TestSparkCoreAdaptorAnalogReadError(t *testing.T) { + a := initTestSparkCoreAdaptor() // When error - testServer = createTestServer(func(w http.ResponseWriter, r *http.Request) { + testServer := createTestServer(func(w http.ResponseWriter, r *http.Request) { http.NotFound(w, r) }) defer testServer.Close() + a.setAPIServer(testServer.URL) - val, _ = a.AnalogRead("A1") + val, _ := a.AnalogRead("A1") gobot.Assert(t, val, 0) } @@ -182,19 +185,23 @@ func TestSparkCoreAdaptorDigitalRead(t *testing.T) { testServer = getDummyResponseForPathWithParams("/"+a.DeviceID+"/digitalread", params, response, t) a.setAPIServer(testServer.URL) + defer testServer.Close() val, _ = a.DigitalRead("D7") gobot.Assert(t, val, 0) +} - testServer.Close() - +func TestSparkCoreAdaptorDigitalReadError(t *testing.T) { + a := initTestSparkCoreAdaptor() // When error - testServer = createTestServer(func(w http.ResponseWriter, r *http.Request) { + testServer := createTestServer(func(w http.ResponseWriter, r *http.Request) { http.NotFound(w, r) }) defer testServer.Close() - val, _ = a.DigitalRead("D7") + a.setAPIServer(testServer.URL) + + val, _ := a.DigitalRead("D7") gobot.Assert(t, val, -1) }