Browse Source

fix: Adding proper Graph Manager global values for tests

Matthias Ladkau 4 years ago
parent
commit
127477fd54
1 changed files with 31 additions and 0 deletions
  1. 31 0
      api/v1/cluster_test.go

+ 31 - 0
api/v1/cluster_test.go

@@ -25,9 +25,29 @@ import (
 	"devt.de/krotik/eliasdb/api"
 	"devt.de/krotik/eliasdb/cluster"
 	"devt.de/krotik/eliasdb/cluster/manager"
+	"devt.de/krotik/eliasdb/graph"
 	"devt.de/krotik/eliasdb/graph/graphstorage"
 )
 
+func TestClusterStorage(t *testing.T) {
+	cluster2 := createCluster(2)
+
+	oldGM := api.GM
+	oldGS := api.GS
+	api.GS = cluster2[0]
+	api.GM = graph.NewGraphManager(cluster2[0])
+	api.DD = cluster2[0]
+	api.DDLog = datautil.NewRingBuffer(10)
+
+	defer func() {
+		api.GM = oldGM
+		api.GS = oldGS
+		api.DD = nil
+		api.DDLog = nil
+	}()
+
+}
+
 func TestClusterQuery(t *testing.T) {
 	queryURL := "http://localhost" + TESTPORT + EndpointClusterQuery
 
@@ -53,9 +73,20 @@ func TestClusterQuery(t *testing.T) {
 
 	cluster2 := createCluster(2)
 
+	oldGM := api.GM
+	oldGS := api.GS
+	api.GS = cluster2[0]
+	api.GM = graph.NewGraphManager(cluster2[0])
 	api.DD = cluster2[0]
 	api.DDLog = datautil.NewRingBuffer(10)
 
+	defer func() {
+		api.GM = oldGM
+		api.GS = oldGS
+		api.DD = nil
+		api.DDLog = nil
+	}()
+
 	// We should now get back a state
 
 	st, _, res = sendTestRequest(queryURL, "GET", nil)