Skip to content

Commit

Permalink
bumped dependencies; updated test
Browse files Browse the repository at this point in the history
  • Loading branch information
skx committed May 4, 2024
1 parent 6e5ab4c commit bc98a42
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 81 deletions.
66 changes: 15 additions & 51 deletions cmd_serve_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
//
// Simple testing of the HTTP-server
//
//
package main

import (
Expand All @@ -20,10 +17,8 @@ import (
"github.com/gorilla/mux"
)

//
// Report IDs must be numeric. Submit some bogus requests to
// ensure they fail with a suitable error-message.
//
func TestNonNumericReport(t *testing.T) {
router := mux.NewRouter()
router.HandleFunc("/report/{id}/", ReportHandler).Methods("GET")
Expand Down Expand Up @@ -55,10 +50,8 @@ func TestNonNumericReport(t *testing.T) {
}
}

//
// API-state must use known values. Submit some bogus values to ensure
// a suitable error is returned.
//
func TestUknownAPIState(t *testing.T) {

// Wire up the route
Expand Down Expand Up @@ -102,14 +95,12 @@ func TestUknownAPIState(t *testing.T) {

}

//
// Test that our report-view returns content that seems reasonable,
// in all three cases:
//
// * text/html
// * application/json
// * application/xml
//
// - text/html
// - application/json
// - application/xml
func TestReportView(t *testing.T) {

// Create a fake database
Expand Down Expand Up @@ -191,9 +182,7 @@ func TestReportView(t *testing.T) {
os.RemoveAll(path)
}

//
// API state must be known.
//
func TestKnownAPIState(t *testing.T) {

// Create a fake database
Expand Down Expand Up @@ -270,9 +259,7 @@ func TestKnownAPIState(t *testing.T) {

}

//
// API state should accept XML, JSON, and plain-text
//
func TestAPITypes(t *testing.T) {

// Create a fake database
Expand Down Expand Up @@ -350,9 +337,7 @@ func TestAPITypes(t *testing.T) {

}

//
// Searching must be done via a POST.
//
func TestSearchMethod(t *testing.T) {

req, err := http.NewRequest("GET", "/search", nil)
Expand All @@ -379,9 +364,7 @@ func TestSearchMethod(t *testing.T) {

}

//
// The search handler must have a term-parameter.
//
func TestSearchEmpty(t *testing.T) {

req, err := http.NewRequest("POST", "/search", bytes.NewReader(nil))
Expand Down Expand Up @@ -410,9 +393,7 @@ func TestSearchEmpty(t *testing.T) {
}
}

//
// The search handler should run a search
//
func TestSearch(t *testing.T) {

// Create a fake database
Expand Down Expand Up @@ -464,9 +445,7 @@ func TestSearch(t *testing.T) {
os.RemoveAll(path)
}

//
// Submitting reports must be done via a POST.
//
func TestUploadReportMethod(t *testing.T) {

req, err := http.NewRequest("GET", "/upload", nil)
Expand All @@ -493,9 +472,7 @@ func TestUploadReportMethod(t *testing.T) {

}

//
// Submitting a pre-cooked report should succeed.
//
func TestUploadReport(t *testing.T) {

// Create a fake database
Expand Down Expand Up @@ -558,9 +535,7 @@ func TestUploadReport(t *testing.T) {
os.RemoveAll(path)
}

//
// Submitting a pre-cooked report which is bogus should fail.
//
func TestUploadBogusReport(t *testing.T) {

// Create a fake database
Expand Down Expand Up @@ -618,9 +593,7 @@ func TestUploadBogusReport(t *testing.T) {
os.RemoveAll(path)
}

//
// Unknown-nodes are handled.
//
func TestUnknownNode(t *testing.T) {

// Create a fake database
Expand Down Expand Up @@ -676,15 +649,12 @@ func TestUnknownNode(t *testing.T) {

}

//
// Test that our node-view returns content that seems reasonable,
// in all three cases:
//
// * text/html
// * application/json
// * application/xml
//
//
// - text/html
// - application/json
// - application/xml
func TestKnownNode(t *testing.T) {

// Create a fake database
Expand Down Expand Up @@ -761,14 +731,12 @@ func TestKnownNode(t *testing.T) {

}

//
// Test that our index-view returns content that seems reasonable,
// in all three cases:
//
// * text/html
// * application/json
// * application/xml
//
// - text/html
// - application/json
// - application/xml
func TestIndexView(t *testing.T) {

// Create a fake database
Expand Down Expand Up @@ -839,12 +807,10 @@ func TestIndexView(t *testing.T) {

}

//
// Test that static-resources work:
//
// 1. They produce content
// 2. They have sensible MIME-types
//
// 1. They produce content
// 2. They have sensible MIME-types
func TestStaticResources(t *testing.T) {

// Test-cases
Expand All @@ -856,7 +822,7 @@ func TestStaticResources(t *testing.T) {
tests := []TestCase{
TestCase{path: "/favicon.ico", mime: "image/vnd.microsoft.icon"},
TestCase{path: "/robots.txt", mime: "text/plain"},
TestCase{path: "/js/jquery.tablesorter.min.js", mime: "application/javascript"},
TestCase{path: "/js/jquery.tablesorter.min.js", mime: "text/javascript"},
TestCase{path: "/css/bootstrap.min.css", mime: "text/css"},
TestCase{path: "/fonts/glyphicons-halflings-regular.woff2", mime: "font/woff2"},
}
Expand Down Expand Up @@ -914,14 +880,12 @@ func TestStaticResources(t *testing.T) {
}
}

//
// Test that our radiator-view returns content that seems reasonable,
// in all three cases:
//
// * text/html
// * application/json
// * application/xml
//
// - text/html
// - application/json
// - application/xml
func TestRadiatorView(t *testing.T) {

// Create a fake database
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module github.com/skx/puppet-summary
go 1.12

require (
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/google/subcommands v1.2.0
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/gorilla/handlers v1.5.2
github.com/gorilla/mux v1.8.1
github.com/marpaia/graphite-golang v0.0.0-20190519024811-caf161d2c2b1
github.com/mattn/go-sqlite3 v1.14.8
github.com/mattn/go-sqlite3 v1.14.22
github.com/robfig/cron v1.2.0
github.com/skx/golang-metrics v0.0.0-20190325085214-453332cf54e8
github.com/smallfish/simpleyaml v0.1.0
Expand Down
39 changes: 13 additions & 26 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,46 +1,33 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/felixge/httpsnoop v1.0.2 h1:+nS9g82KMXccJ/wp0zyRW9ZBHFETmMGtkk+2CTTrW4o=
github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/google/subcommands v1.0.1 h1:/eqq+otEXm5vhfBrbREPCSVQbvofip6kIz+mX5TUH7k=
github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/gorilla/handlers v1.4.0 h1:XulKRWSQK5uChr4pEgSE4Tc/OcmnU9GJuSwdog/tZsA=
github.com/gorilla/handlers v1.4.0/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
github.com/gorilla/mux v1.7.0 h1:tOSd0UKHQd6urX6ApfOn4XdBMY6Sh1MfxV3kmaazO+U=
github.com/gorilla/mux v1.7.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/marpaia/graphite-golang v0.0.0-20171231172105-134b9af18cf3 h1:u29lpVaZAUUD6NlG1A0lIR7CnRgKlHNdDOJZw40L+/I=
github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE=
github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/marpaia/graphite-golang v0.0.0-20171231172105-134b9af18cf3/go.mod h1:llZw8JbFm5CvdRrtgdjaQNlZR1bQhAWsBKtb0HTX+sw=
github.com/marpaia/graphite-golang v0.0.0-20190519024811-caf161d2c2b1 h1:lODGHy+2Namopi4v7AeiqW106eo4QMXqj9aE8jVXcO4=
github.com/marpaia/graphite-golang v0.0.0-20190519024811-caf161d2c2b1/go.mod h1:llZw8JbFm5CvdRrtgdjaQNlZR1bQhAWsBKtb0HTX+sw=
github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o=
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU=
github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967 h1:x7xEyJDP7Hv3LVgvWhzioQqbC/KtuUhTigKlH/8ehhE=
github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
github.com/skx/golang-metrics v0.0.0-20180606065905-85a4b4e0641f h1:hfW+6CozS1gFV+SQ5Y/FoDefrQzs0/zRPmwugf/7xLs=
github.com/skx/golang-metrics v0.0.0-20180606065905-85a4b4e0641f/go.mod h1:ZX+VTMGkg8m8Da1GxWKj3bDaGIt08Qi6QSx8HlGxT6g=
github.com/skx/golang-metrics v0.0.0-20190325085214-453332cf54e8 h1:NVwRIqHO7J7vnKGbTz5dBwWjl5Wr6mR1U8JQ32tw7vk=
github.com/skx/golang-metrics v0.0.0-20190325085214-453332cf54e8/go.mod h1:P+OUoQPrBQUZg9lbHEu7iJsZYTC5Na4qghTSs5ZmTA4=
github.com/smallfish/simpleyaml v0.0.0-20170911015856-a32031077861 h1:9z0Ip656Pc+3cj/BpHkErOVg4iE0xcAdvJwfA3hMVzU=
github.com/smallfish/simpleyaml v0.0.0-20170911015856-a32031077861/go.mod h1:eGZ1jp5PTJ+XVhTErUmw0xyPbgctPFlixWPypUrDkSs=
github.com/smallfish/simpleyaml v0.1.0 h1:5uAZdLAiHxS9cmzkOxg7lH0dILXKTD7uRZbAhyHmyU0=
github.com/smallfish/simpleyaml v0.1.0/go.mod h1:gU3WdNn44dQVAbVHD2SrSqKKCvmzFApWD2UURhgEj1M=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 comments on commit bc98a42

Please sign in to comment.