summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-06-09 14:59:12 -0400
committerBen Morrison <ben@gbmor.dev>2019-06-09 15:25:02 -0400
commit2fd6b1aaa6b8382fabf1361259188f4ef36472d3 (patch)
tree684b67165facce0507cbe8816668f47b42ea93ae
parent3ea7e8890f8d13789de2c69ac1476c824399e011 (diff)
downloadgetwtxt-2fd6b1aaa6b8382fabf1361259188f4ef36472d3.tar.gz
moving mock registry creation to its own func
-rw-r--r--svc/init_test.go9
-rw-r--r--svc/query_test.go10
2 files changed, 10 insertions, 9 deletions
diff --git a/svc/init_test.go b/svc/init_test.go
index a9fe624..385db0e 100644
--- a/svc/init_test.go
+++ b/svc/init_test.go
@@ -3,11 +3,13 @@ package svc // import "github.com/getwtxt/getwtxt/svc"
 import (
 	"fmt"
 	"log"
+	"net"
 	"os"
 	"strings"
 	"sync"
 	"time"
 
+	"github.com/getwtxt/registry"
 	"github.com/spf13/viper"
 )
 
@@ -89,3 +91,10 @@ func testConfig() {
 	confObj.Instance.Mail = viper.GetString("Instance.Email")
 	confObj.Instance.Desc = viper.GetString("Instance.Description")
 }
+
+func mockRegistry() {
+
+	statuses, _, _ := registry.GetTwtxt("https://gbmor.dev/twtxt.txt")
+	parsed, _ := registry.ParseUserTwtxt(statuses, "gbmor", "https://gbmor.dev/twtxt.txt")
+	_ = twtxtCache.AddUser("gbmor", "https://gbmor.dev/twtxt.txt", "1", net.ParseIP("127.0.0.1"), parsed)
+}
diff --git a/svc/query_test.go b/svc/query_test.go
index 3e7e5d3..9fe6496 100644
--- a/svc/query_test.go
+++ b/svc/query_test.go
@@ -76,15 +76,7 @@ func Benchmark_parseQueryOut(b *testing.B) {
 
 func Test_compositeStatusQuery(t *testing.T) {
 	initTestConf()
-	statuses, _, err := registry.GetTwtxt("https://gbmor.dev/twtxt.txt")
-	if err != nil {
-		t.Errorf("%v\n", err)
-	}
-	parsed, err := registry.ParseUserTwtxt(statuses, "gbmor", "https://gbmor.dev/twtxt.txt")
-	if err != nil {
-		t.Errorf("%v\n", err)
-	}
-	_ = twtxtCache.AddUser("gbmor", "https://gbmor.dev/twtxt.txt", "1", net.ParseIP("127.0.0.1"), parsed)
+	mockRegistry()
 
 	t.Run("Composite Query Test", func(t *testing.T) {
 		out1, err := twtxtCache.QueryInStatus("sqlite")
'#n174'>174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328