test version
parent
a406287127
commit
ac7833338c
|
|
@ -0,0 +1,30 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func TestVersion(t *testing.T) {
|
||||
rest := &REST{}
|
||||
w := httptest.NewRecorder()
|
||||
s := uuid.New().String()
|
||||
GitCommit = s
|
||||
rest.version(w, nil)
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatal(w.Code)
|
||||
}
|
||||
var resp struct {
|
||||
Version string `json:"version"`
|
||||
}
|
||||
if err := json.NewDecoder(w.Body).Decode(&resp); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if resp.Version != s {
|
||||
t.Fatal(string(w.Body.Bytes()))
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue