mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
adding tests
This commit is contained in:
parent
0b1315f9bf
commit
000d98d934
@ -1,16 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"net/http/httptest"
|
||||
"encoding/base64"
|
||||
app "databag/internal"
|
||||
store "databag/internal/store"
|
||||
)
|
||||
|
||||
func TestClaim(t *testing.T) {
|
||||
func TestSetup(t *testing.T) {
|
||||
|
||||
store.SetPath("file::memory:?cache=shared");
|
||||
Claimable(t);
|
||||
Claim(t);
|
||||
}
|
||||
|
||||
func Claimable(t *testing.T) {
|
||||
r := httptest.NewRequest("GET", "/claimable", nil)
|
||||
w := httptest.NewRecorder()
|
||||
app.GetNodeClaimable(w, r);
|
||||
@ -19,3 +25,14 @@ func TestClaim(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func Claim(t *testing.T) {
|
||||
auth := base64.StdEncoding.EncodeToString([]byte("admin:pass"))
|
||||
r := httptest.NewRequest("GET", "/claimable", nil)
|
||||
r.Header.Add("Authorization","Basic " + auth)
|
||||
w := httptest.NewRecorder()
|
||||
app.GetNodeClaimable(w, r);
|
||||
if w.Code != 200 {
|
||||
t.Errorf("server not initially claimable");
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user