Skip to content
Permalink
Browse files
feat: add IT test
  • Loading branch information
PhilYue committed Jan 23, 2022
1 parent 7b8a66a commit aafd16fb08b15d68513135dc7b52e8baac0f57bf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
@@ -108,7 +108,7 @@ func (sd *zookeeperDiscovery) QueryServicesByName(serviceNames []string) ([]serv
ids, err := sd.getClient().GetChildren(sd.pathForName(s))
logger.Debugf("%s get services %s, services instanceIds %s", common.ZKLogDiscovery, s, ids)
if err != nil {
logger.Errorf("%s get %s services node from zookeeper fail ", common.ZKLogDiscovery, err)
logger.Errorf("%s get services [%s] nodes from zookeeper fail: %s", common.ZKLogDiscovery, s, err.Error())
continue
}

@@ -42,3 +42,18 @@ func TestAuth(t *testing.T) {
s, _ := ioutil.ReadAll(resp.Body)
assert.True(t, strings.Contains(string(s), "test"))
}


func TestSpringCloudZookeeper(t *testing.T) {
url := "http://localhost:8888/pixiu-springcloud-server/hi"
client := &http.Client{Timeout: 5 * time.Second}
req, err := http.NewRequest("GET", url, nil)
assert.NoError(t, err)
req.Header.Add("Content-Type", "application/json")
resp, err := client.Do(req)
assert.NoError(t, err)
assert.NotNil(t, resp)
assert.Equal(t, 200, resp.StatusCode)
s, _ := ioutil.ReadAll(resp.Body)
assert.True(t, strings.Contains(string(s), "Hello Pixiu World!"))
}

0 comments on commit aafd16f

Please sign in to comment.