mirror of
https://github.com/lingble/databunker.git
synced 2026-03-20 00:54:10 +00:00
Add new tests
This commit is contained in:
@@ -76,7 +76,7 @@ func helpMetricsRequest(token string) ([]byte, error) {
|
||||
return helpServe0(request)
|
||||
}
|
||||
|
||||
func helpLoginPageRequest(token string) ([]byte, error) {
|
||||
func helpLoginPageRequest() ([]byte, error) {
|
||||
url := "http://localhost:3000/"
|
||||
request := httptest.NewRequest("GET", url, nil)
|
||||
return helpServe0(request)
|
||||
@@ -89,6 +89,18 @@ func helpConfigurationDump(token string) ([]byte, error) {
|
||||
return helpServe0(request)
|
||||
}
|
||||
|
||||
func helpLoginProfilePageRequest() ([]byte, error) {
|
||||
url := "http://localhost:3000/site/user-profile.html"
|
||||
request := httptest.NewRequest("GET", url, nil)
|
||||
return helpServe0(request)
|
||||
}
|
||||
|
||||
func helpNotFoundPageRequest() ([]byte, error) {
|
||||
url := "http://localhost:3000/not-fund-page.html"
|
||||
request := httptest.NewRequest("GET", url, nil)
|
||||
return helpServe0(request)
|
||||
}
|
||||
|
||||
func init() {
|
||||
fmt.Printf("**INIT*TEST*CODE***\n")
|
||||
masterKey, _ := hex.DecodeString("71c65924336c5e6f41129b6f0540ad03d2a8bf7e9b10db72")
|
||||
@@ -147,7 +159,7 @@ func TestMetrics(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoginPage(t *testing.T) {
|
||||
raw, err := helpLoginPageRequest(rootToken)
|
||||
raw, err := helpLoginPageRequest()
|
||||
if err != nil {
|
||||
//log.Panic("error %s", err.Error())
|
||||
log.Fatalf("failed to get login page %s", err.Error())
|
||||
@@ -157,6 +169,28 @@ func TestLoginPage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoginProfilePage(t *testing.T) {
|
||||
raw, err := helpLoginProfilePageRequest()
|
||||
if err != nil {
|
||||
//log.Panic("error %s", err.Error())
|
||||
log.Fatalf("failed to get login profile page %s", err.Error())
|
||||
}
|
||||
if strings.Contains(string(raw), "profile") == false {
|
||||
t.Fatalf("login profile page failed\n")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotFoundPage(t *testing.T) {
|
||||
raw, err := helpNotFoundPageRequest()
|
||||
if err != nil {
|
||||
//log.Panic("error %s", err.Error())
|
||||
//log.Fatalf("failed to get not found page %s", err.Error())
|
||||
}
|
||||
if strings.Contains(string(raw), "not found") == false {
|
||||
t.Fatalf("not found page failed\n")
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigurationOK(t *testing.T) {
|
||||
fmt.Printf("root token: %s\n", rootToken)
|
||||
raw, err := helpConfigurationDump(rootToken)
|
||||
|
||||
Reference in New Issue
Block a user