summary refs log tree commit diff stats
path: root/post_test.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-05-27 18:25:30 -0400
committerBen Morrison <ben@gbmor.dev>2019-05-27 18:26:58 -0400
commit6f9383517d8dbee557d2b52113e20e08207b533e (patch)
tree1fd918f37cd963ab496e2f7b9ee1bef8fa7fa8ba /post_test.go
parent3c5dd59f5c3be00909df4a509eea940393fd060e (diff)
downloadgetwtxt-6f9383517d8dbee557d2b52113e20e08207b533e.tar.gz
modified POST test
Diffstat (limited to 'post_test.go')
-rw-r--r--post_test.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/post_test.go b/post_test.go
index 9d04c9e..a0d43ac 100644
--- a/post_test.go
+++ b/post_test.go
@@ -1,11 +1,14 @@
 package main
 
 import (
+	"fmt"
 	"net/http"
 	"net/http/httptest"
 	"net/url"
 	"strings"
 	"testing"
+
+	"github.com/getwtxt/registry"
 )
 
 var apiPostUserCases = []struct {
@@ -16,8 +19,8 @@ var apiPostUserCases = []struct {
 }{
 	{
 		name:    "Known Good User",
-		nick:    "soltempore",
-		uri:     "https://enotty.dk/soltempore.txt",
+		nick:    "gbmor",
+		uri:     "https://gbmor.dev/twtxt.txt",
 		wantErr: false,
 	},
 	{
@@ -42,6 +45,8 @@ var apiPostUserCases = []struct {
 
 func Test_apiPostUser(t *testing.T) {
 	initTestConf()
+	portnum := fmt.Sprintf(":%v", confObj.Port)
+	twtxtCache = registry.NewIndex()
 
 	for _, tt := range apiPostUserCases {
 		t.Run(tt.name, func(t *testing.T) {
@@ -49,17 +54,14 @@ func Test_apiPostUser(t *testing.T) {
 			params.Set("url", tt.uri)
 			params.Set("nickname", tt.nick)
 
-			req, err := http.NewRequest("POST", "http://localhost"+testport+"/api/plain/users", strings.NewReader(params.Encode()))
+			req, err := http.NewRequest("POST", "https://localhost"+portnum+"/api/plain/users", strings.NewReader(params.Encode()))
 			if err != nil {
 				t.Errorf("%v\n", err)
 			}
 
 			req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
-
 			rr := httptest.NewRecorder()
-			handler := http.HandlerFunc(apiEndpointPOSTHandler)
-
-			handler.ServeHTTP(rr, req)
+			apiEndpointPOSTHandler(rr, req)
 
 			if !tt.wantErr {
 				if rr.Code != http.StatusOK {