Add new tests

This commit is contained in:
Yuli
2020-02-18 18:08:19 +02:00
parent eae26489f5
commit 1af336cb38

View File

@@ -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)