Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
elasticsearch and couchdb: move testdata to version dir (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyam8 authored Nov 30, 2020
1 parent 07fcd59 commit d3ece5b
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 30 deletions.
30 changes: 15 additions & 15 deletions modules/couchdb/couchdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ import (
)

var (
responseRoot, _ = ioutil.ReadFile("testdata/v311_single_root.json")
responseActiveTasks, _ = ioutil.ReadFile("testdata/v311_single_active_tasks.json")
responseNodeStats, _ = ioutil.ReadFile("testdata/v311_node_stats.json")
responseNodeSystem, _ = ioutil.ReadFile("testdata/v311_node_system.json")
responseDatabases, _ = ioutil.ReadFile("testdata/v311_databases.json")
v311Root, _ = ioutil.ReadFile("testdata/v3.1.1/root.json")
v311ActiveTasks, _ = ioutil.ReadFile("testdata/v3.1.1/active_tasks.json")
v311NodeStats, _ = ioutil.ReadFile("testdata/v3.1.1/node_stats.json")
v311NodeSystem, _ = ioutil.ReadFile("testdata/v3.1.1/node_system.json")
v311DbsInfo, _ = ioutil.ReadFile("testdata/v3.1.1/dbs_info.json")
)

func Test_testDataIsCorrectlyReadAndValid(t *testing.T) {
for name, data := range map[string][]byte{
"responseRoot": responseRoot,
"responseActiveTasks": responseActiveTasks,
"responseNodeStats": responseNodeStats,
"responseNodeSystem": responseNodeSystem,
"responseDatabases": responseDatabases,
"v311Root": v311Root,
"v311ActiveTasks": v311ActiveTasks,
"v311NodeStats": v311NodeStats,
"v311NodeSystem": v311NodeSystem,
"v311DbsInfo": v311DbsInfo,
} {
require.NotNilf(t, data, name)
}
Expand Down Expand Up @@ -434,15 +434,15 @@ func prepareCouchDBEndpoint() *httptest.Server {
func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/_node/_local/_stats":
_, _ = w.Write(responseNodeStats)
_, _ = w.Write(v311NodeStats)
case "/_node/_local/_system":
_, _ = w.Write(responseNodeSystem)
_, _ = w.Write(v311NodeSystem)
case urlPathActiveTasks:
_, _ = w.Write(responseActiveTasks)
_, _ = w.Write(v311ActiveTasks)
case "/_dbs_info":
_, _ = w.Write(responseDatabases)
_, _ = w.Write(v311DbsInfo)
case "/":
_, _ = w.Write(responseRoot)
_, _ = w.Write(v311Root)
default:
w.WriteHeader(http.StatusNotFound)
}
Expand Down
30 changes: 15 additions & 15 deletions modules/elasticsearch/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ import (
)

var (
v790SingleNodesLocalStats, _ = ioutil.ReadFile("testdata/v790_single_nodes_local_stats.json")
v790SingleClusterHealth, _ = ioutil.ReadFile("testdata/v790_single_cluster_health.json")
v790SingleClusterStats, _ = ioutil.ReadFile("testdata/v790_single_cluster_stats.json")
v790SingleCatIndicesStats, _ = ioutil.ReadFile("testdata/v790_single_cat_indices_stats.json")
v790SingleInfo, _ = ioutil.ReadFile("testdata/v790_single_info.json")
v790NodesLocalStats, _ = ioutil.ReadFile("testdata/v7.9.0/nodes_local_stats.json")
v790ClusterHealth, _ = ioutil.ReadFile("testdata/v7.9.0/cluster_health.json")
v790ClusterStats, _ = ioutil.ReadFile("testdata/v7.9.0/cluster_stats.json")
v790CatIndicesStats, _ = ioutil.ReadFile("testdata/v7.9.0/cat_indices_stats.json")
v790Info, _ = ioutil.ReadFile("testdata/v7.9.0/info.json")
)

func Test_testDataIsCorrectlyReadAndValid(t *testing.T) {
for name, data := range map[string][]byte{
"v790SingleNodesLocalStats": v790SingleNodesLocalStats,
"v790SingleClusterHealth": v790SingleClusterHealth,
"v790SingleClusterStats": v790SingleClusterStats,
"v790SingleCatIndicesStats": v790SingleCatIndicesStats,
"v790SingleInfo": v790SingleInfo,
"v790NodesLocalStats": v790NodesLocalStats,
"v790ClusterHealth": v790ClusterHealth,
"v790ClusterStats": v790ClusterStats,
"v790CatIndicesStats": v790CatIndicesStats,
"v790Info": v790Info,
} {
require.NotNilf(t, data, name)
}
Expand Down Expand Up @@ -603,15 +603,15 @@ func prepareElasticsearchEndpoint() *httptest.Server {
func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case urlPathLocalNodeStats:
_, _ = w.Write(v790SingleNodesLocalStats)
_, _ = w.Write(v790NodesLocalStats)
case urlPathClusterHealth:
_, _ = w.Write(v790SingleClusterHealth)
_, _ = w.Write(v790ClusterHealth)
case urlPathClusterStats:
_, _ = w.Write(v790SingleClusterStats)
_, _ = w.Write(v790ClusterStats)
case urlPathIndicesStats:
_, _ = w.Write(v790SingleCatIndicesStats)
_, _ = w.Write(v790CatIndicesStats)
case "/":
_, _ = w.Write(v790SingleInfo)
_, _ = w.Write(v790Info)
default:
w.WriteHeader(http.StatusNotFound)
}
Expand Down

0 comments on commit d3ece5b

Please sign in to comment.