summary refs log tree commit diff stats
path: root/svc
diff options
context:
space:
mode:
Diffstat (limited to 'svc')
-rw-r--r--svc/handlers_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/svc/handlers_test.go b/svc/handlers_test.go
index 41a8851..c393957 100644
--- a/svc/handlers_test.go
+++ b/svc/handlers_test.go
@@ -18,11 +18,15 @@ import (
 
 func basicHandlerTest(path string, name string, t *testing.T) {
 	initTestConf()
+
 	t.Run(name, func(t *testing.T) {
 		w := httptest.NewRecorder()
 		req := httptest.NewRequest("GET", path, nil)
+
 		indexHandler(w, req)
 		resp := w.Result()
+		defer resp.Body.Close()
+
 		if resp.StatusCode != http.StatusOK {
 			t.Errorf(fmt.Sprintf("%v", resp.StatusCode))
 		}
@@ -41,9 +45,11 @@ func Test_indexHandler(t *testing.T) {
 }
 func Benchmark_indexHandler(b *testing.B) {
 	initTestConf()
+
 	w := httptest.NewRecorder()
 	req := httptest.NewRequest("GET", "http://localhost"+testport+"/", nil)
 	b.ResetTimer()
+
 	for i := 0; i < b.N; i++ {
 		indexHandler(w, req)
 	}
@@ -85,17 +91,24 @@ var endpointCases = []struct {
 func Test_apiEndpointHandler(t *testing.T) {
 	initTestConf()
 	mockRegistry()
+
 	for _, tt := range endpointCases {
+
 		t.Run(tt.name, func(t *testing.T) {
 			w := httptest.NewRecorder()
 			apiEndpointHandler(w, tt.req)
+
 			resp := w.Result()
+			defer resp.Body.Close()
+
 			if resp.StatusCode != tt.status {
 				t.Errorf(fmt.Sprintf("%v", resp.StatusCode))
 			}
+
 			if tt.status == http.StatusOK {
 				var body []byte
 				buf := bytes.NewBuffer(body)
+
 				err := resp.Write(buf)
 				if err != nil {
 					t.Errorf("%v\n", err)
@@ -113,8 +126,10 @@ func Test_apiEndpointHandler(t *testing.T) {
 func Benchmark_apiEndpointHandler(b *testing.B) {
 	initTestConf()
 	mockRegistry()
+
 	w := httptest.NewRecorder()
 	b.ResetTimer()
+
 	for _, tt := range endpointCases {
 		for i := 0; i < b.N; i++ {
 			apiEndpointHandler(w, tt.req)
@@ -125,14 +140,19 @@ func Benchmark_apiEndpointHandler(b *testing.B) {
 func Test_apiTagsBaseHandler(t *testing.T) {
 	initTestConf()
 	mockRegistry()
+
 	t.Run("apiTagsBaseHandler", func(t *testing.T) {
 		w := httptest.NewRecorder()
 		req := httptest.NewRequest("GET", "http://localhost"+testport+"/api/plain/tags", nil)
+
 		apiTagsBaseHandler(w, req)
 		resp := w.Result()
+		defer resp.Body.Close()
+
 		if resp.StatusCode != http.StatusOK {
 			t.Errorf(fmt.Sprintf("%v", resp.StatusCode))
 		}
+
 		bd, err := ioutil.ReadAll(resp.Body)
 		if err != nil {
 			t.Errorf("%v\n", err)
@@ -148,6 +168,7 @@ func Benchmark_apiTagsBaseHandler(b *testing.B) {
 	w := httptest.NewRecorder()
 	r := httptest.NewRequest("GET", "http://localhost"+testport+"/api/plain/tags", nil)
 	b.ResetTimer()
+
 	for i := 0; i < b.N; i++ {
 		apiTagsBaseHandler(w, r)
 	}
@@ -155,15 +176,20 @@ func Benchmark_apiTagsBaseHandler(b *testing.B) {
 func Test_apiTagsHandler(t *testing.T) {
 	initTestConf()
 	mockRegistry()
+
 	t.Run("apiTagsHandler", func(t *testing.T) {
 		w := httptest.NewRecorder()
 		req := httptest.NewRequest("GET", "http://localhost"+testport+"/api/plain/tags/programming", nil)
+
 		apiTagsHandler(w, req)
 		resp := w.Result()
+		defer resp.Body.Close()
+
 		data, err := ioutil.ReadAll(resp.Body)
 		if err != nil {
 			t.Errorf("%v\n", err)
 		}
+
 		if resp.StatusCode != http.StatusOK {
 			t.Errorf(fmt.Sprintf("%v", resp.StatusCode))
 		}
@@ -179,6 +205,7 @@ func Benchmark_apiTagsHandler(b *testing.B) {
 	w := httptest.NewRecorder()
 	r := httptest.NewRequest("GET", "http://localhost"+testport+"/api/plain/tags/programming", nil)
 	b.ResetTimer()
+
 	for i := 0; i < b.N; i++ {
 		apiTagsHandler(w, r)
 	}
@@ -198,8 +225,12 @@ func Test_cssHandler(t *testing.T) {
 
 	t.Run(name, func(t *testing.T) {
 		cssHandler(w, req)
+
 		resp := w.Result()
+		defer resp.Body.Close()
+
 		body, _ := ioutil.ReadAll(resp.Body)
+
 		if resp.StatusCode != 200 {
 			t.Errorf("cssHandler(): %v\n", resp.StatusCode)
 		}
17 00:49:36 -0800 2453 - bugfix: trailing space after curly bracket' href='/akkartik/mu/commit/054dilated_reagent.cc?h=main&id=21c277062ef151ad86e2003ad0e2bfb09f3d4c2d'>21c27706 ^
79eef536 ^
a796831f ^


































d5f89e0f ^
a796831f ^




4ad0f652 ^
a796831f ^


c4e143d6 ^

be45c431 ^
c4e143d6 ^


be45c431 ^
c4e143d6 ^







08cf048f ^
79eef536 ^
b74443e5 ^
eb4eecea ^
a17f9186 ^
79eef536 ^
a17f9186 ^
a796831f ^
a796831f ^



79eef536 ^
a796831f ^
a072f674 ^
eb4eecea ^
a072f674 ^

a796831f ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134