about summary refs log tree commit diff stats
path: root/svc/post_test.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-06-12 02:26:06 -0400
committerGitHub <noreply@github.com>2019-06-12 02:26:06 -0400
commitf5d40abf409016f297b2f0749ce9d26299381828 (patch)
treef3464aaa2cb16e922295cd7321d3b8cba01c8564 /svc/post_test.go
parent3681615abf46112646c009cf17f29d07c2755c11 (diff)
parenta6900c200808dbc5aa77dbf1454c6e369fb328e9 (diff)
downloadgetwtxt-f5d40abf409016f297b2f0749ce9d26299381828.tar.gz
Merge pull request #5 from getwtxt/test-development
Additional Tests
Diffstat (limited to 'svc/post_test.go')
-rw-r--r--svc/post_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/svc/post_test.go b/svc/post_test.go
index 99c174a..cee324c 100644
--- a/svc/post_test.go
+++ b/svc/post_test.go
@@ -75,3 +75,23 @@ func Test_apiPostUser(t *testing.T) {
 		})
 	}
 }
+func Benchmark_apiPostUser(b *testing.B) {
+	initTestConf()
+	portnum := fmt.Sprintf(":%v", confObj.Port)
+	twtxtCache = registry.NewIndex()
+
+	params := url.Values{}
+	params.Set("url", "https://gbmor.dev/twtxt.txt")
+	params.Set("nickname", "gbmor")
+	req, _ := http.NewRequest("POST", "https://localhost"+portnum+"/api/plain/users", strings.NewReader(params.Encode()))
+	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
+	rr := httptest.NewRecorder()
+
+	for i := 0; i < b.N; i++ {
+		apiEndpointPOSTHandler(rr, req)
+
+		b.StopTimer()
+		twtxtCache = registry.NewIndex()
+		b.StartTimer()
+	}
+}