From afd7fa5db1467e722ac75525494aac0a049a738b Mon Sep 17 00:00:00 2001 From: Hunter Long Date: Wed, 8 Apr 2020 19:10:43 -0700 Subject: [PATCH] tests --- handlers/api_test.go | 20 -------------------- handlers/checkins_test.go | 2 +- handlers/groups_test.go | 2 +- handlers/services_test.go | 14 +++++++------- 4 files changed, 9 insertions(+), 29 deletions(-) diff --git a/handlers/api_test.go b/handlers/api_test.go index d0a10e80..9fc5025e 100644 --- a/handlers/api_test.go +++ b/handlers/api_test.go @@ -195,26 +195,6 @@ func TestMainApiRoutes(t *testing.T) { } } -//func TestExportSettings(t *testing.T) { -// data, err := ExportSettings() -// require.Nil(t, err) -// assert.Len(t, data, 50) -// -// var exportData ExportData -// err = json.Unmarshal(data, &exportData) -// require.Nil(t, err) -// -// assert.Len(t, exportData.Services, 4) -// assert.Len(t, exportData.Messages, 4) -// assert.Len(t, exportData.Checkins, 2) -// assert.Len(t, exportData.Groups, 1) -// -// assert.Equal(t, "Updated Core", exportData.Core.Name) -// assert.True(t, exportData.Core.Setup) -// assert.NotEmpty(t, exportData.Core.ApiKey) -// assert.NotEmpty(t, exportData.Core.ApiSecret) -//} - type HttpFuncTest func(*testing.T) error // HTTPTest contains all the parameters for a HTTP Unit Test diff --git a/handlers/checkins_test.go b/handlers/checkins_test.go index ad91003e..7c338761 100644 --- a/handlers/checkins_test.go +++ b/handlers/checkins_test.go @@ -16,7 +16,7 @@ func TestApiCheckinRoutes(t *testing.T) { SecureRoute: true, }, { Name: "Statping Create Checkin", - URL: "/api/checkin", + URL: "/api/checkins", Method: "POST", Body: `{ "service_id": 2, diff --git a/handlers/groups_test.go b/handlers/groups_test.go index 44d0e737..7bd857b6 100644 --- a/handlers/groups_test.go +++ b/handlers/groups_test.go @@ -52,7 +52,7 @@ func TestGroupAPIRoutes(t *testing.T) { URL: "/api/groups", Method: "GET", ExpectedStatus: 200, - ResponseLen: 2, + ResponseLen: 3, BeforeTest: UnsetTestENV, }, { diff --git a/handlers/services_test.go b/handlers/services_test.go index 5445bd45..e5c3f070 100644 --- a/handlers/services_test.go +++ b/handlers/services_test.go @@ -23,11 +23,11 @@ func TestApiServiceRoutes(t *testing.T) { Method: "GET", ExpectedContains: []string{`"name":"Google"`}, ExpectedStatus: 200, - ResponseLen: 5, + ResponseLen: 6, BeforeTest: SetTestENV, FuncTest: func(t *testing.T) error { count := len(services.Services()) - if count != 5 { + if count != 6 { return errors.Errorf("incorrect services count: %d", count) } return nil @@ -39,11 +39,11 @@ func TestApiServiceRoutes(t *testing.T) { Method: "GET", ExpectedContains: []string{`"name":"Google"`}, ExpectedStatus: 200, - ResponseLen: 4, + ResponseLen: 5, BeforeTest: UnsetTestENV, FuncTest: func(t *testing.T) error { count := len(services.Services()) - if count != 5 { + if count != 6 { return errors.Errorf("incorrect services count: %d", count) } return nil @@ -59,7 +59,7 @@ func TestApiServiceRoutes(t *testing.T) { }, { Name: "Statping Private Service 1", - URL: "/api/services/2", + URL: "/api/services/6", Method: "GET", ExpectedContains: []string{`"error":"not authenticated"`}, ExpectedStatus: 200, @@ -176,7 +176,7 @@ func TestApiServiceRoutes(t *testing.T) { ExpectedContains: []string{`"status":"success","type":"service","method":"create"`, `"public":false`, `"group_id":1`}, FuncTest: func(t *testing.T) error { count := len(services.Services()) - if count != 6 { + if count != 7 { return errors.Errorf("incorrect services count: %d", count) } return nil @@ -238,7 +238,7 @@ func TestApiServiceRoutes(t *testing.T) { ExpectedContains: []string{`"status":"success"`, `"method":"delete"`}, FuncTest: func(t *testing.T) error { count := len(services.Services()) - if count != 5 { + if count != 6 { return errors.Errorf("incorrect services count: %d", count) } return nil