Browse Source
Merge commit '35a4e68ad6f3142c5bbb7f9ec4671e3514f3f64a' into HEAD
feature/add-pipeline-loading
Jenkins
3 years ago
committed by
Fabian Vowie
No known key found for this signature in database
GPG Key ID: C27317C33B27C410
4 changed files with
49 additions and
1 deletions
-
go.mod
-
go.sum
-
main.go
-
main_test.go
|
@ -3,3 +3,10 @@ module github.com/geplauder/lithium |
|
|
go 1.17 |
|
|
go 1.17 |
|
|
|
|
|
|
|
|
require github.com/gorilla/mux v1.8.0 |
|
|
require github.com/gorilla/mux v1.8.0 |
|
|
|
|
|
|
|
|
|
|
|
require ( |
|
|
|
|
|
github.com/davecgh/go-spew v1.1.0 // indirect |
|
|
|
|
|
github.com/pmezard/go-difflib v1.0.0 // indirect |
|
|
|
|
|
github.com/stretchr/testify v1.7.0 // indirect |
|
|
|
|
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect |
|
|
|
|
|
) |
|
@ -1,2 +1,12 @@ |
|
|
|
|
|
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/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= |
|
|
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= |
|
|
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= |
|
|
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= |
|
|
|
|
|
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/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/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
|
|
|
|
|
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= |
|
@ -1,13 +1,23 @@ |
|
|
package main |
|
|
package main |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
|
|
|
"encoding/json" |
|
|
"net/http" |
|
|
"net/http" |
|
|
|
|
|
|
|
|
"github.com/gorilla/mux" |
|
|
"github.com/gorilla/mux" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const Name string = "Lithium" |
|
|
|
|
|
const Version string = "0.1.0" |
|
|
|
|
|
|
|
|
|
|
|
type Metadata struct { |
|
|
|
|
|
Name string |
|
|
|
|
|
Version string |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func IndexHandler(w http.ResponseWriter, r *http.Request) { |
|
|
func IndexHandler(w http.ResponseWriter, r *http.Request) { |
|
|
w.Write([]byte("hello world!")) |
|
|
|
|
|
|
|
|
w.Header().Set("Content-Type", "application/json") |
|
|
|
|
|
json.NewEncoder(w).Encode(Metadata{Name, Version}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func main() { |
|
|
func main() { |
|
|
|
@ -0,0 +1,21 @@ |
|
|
|
|
|
package main |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
|
"net/http" |
|
|
|
|
|
"net/http/httptest" |
|
|
|
|
|
"testing" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert" |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func TestIndexRoute(t *testing.T) { |
|
|
|
|
|
t.Run("Index route returns valid response", func(t *testing.T) { |
|
|
|
|
|
request := httptest.NewRequest(http.MethodGet, "/", nil) |
|
|
|
|
|
responseRecorder := httptest.NewRecorder() |
|
|
|
|
|
|
|
|
|
|
|
IndexHandler(responseRecorder, request) |
|
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, responseRecorder.Code, 200, "Response code should be 200") |
|
|
|
|
|
assert.NotNil(t, responseRecorder.Body, "Response should contain body") |
|
|
|
|
|
}) |
|
|
|
|
|
} |