mirror of
https://github.com/restic/rest-server.git
synced 2026-09-27 06:21:28 -07:00
test status code
This commit is contained in:
@@ -38,17 +38,21 @@ func TestRouter(t *testing.T) {
|
|||||||
|
|
||||||
getConfigResp, _ := http.Get(server.URL + "/config")
|
getConfigResp, _ := http.Get(server.URL + "/config")
|
||||||
getConfigBody, _ := ioutil.ReadAll(getConfigResp.Body)
|
getConfigBody, _ := ioutil.ReadAll(getConfigResp.Body)
|
||||||
|
require.Equal(t, 200, getConfigResp.StatusCode)
|
||||||
require.Equal(t, string(getConfig), string(getConfigBody))
|
require.Equal(t, string(getConfig), string(getConfigBody))
|
||||||
|
|
||||||
postConfigResp, _ := http.Post(server.URL+"/config", "binary/octet-stream", strings.NewReader("post test"))
|
postConfigResp, _ := http.Post(server.URL+"/config", "binary/octet-stream", strings.NewReader("post test"))
|
||||||
postConfigBody, _ := ioutil.ReadAll(postConfigResp.Body)
|
postConfigBody, _ := ioutil.ReadAll(postConfigResp.Body)
|
||||||
|
require.Equal(t, 200, postConfigResp.StatusCode)
|
||||||
require.Equal(t, string(postConfig), string(postConfigBody))
|
require.Equal(t, string(postConfig), string(postConfigBody))
|
||||||
|
|
||||||
getBlobsResp, _ := http.Get(server.URL + "/blobs/")
|
getBlobsResp, _ := http.Get(server.URL + "/blobs/")
|
||||||
getBlobsBody, _ := ioutil.ReadAll(getBlobsResp.Body)
|
getBlobsBody, _ := ioutil.ReadAll(getBlobsResp.Body)
|
||||||
|
require.Equal(t, 200, getBlobsResp.StatusCode)
|
||||||
require.Equal(t, string(getBlobs), string(getBlobsBody))
|
require.Equal(t, string(getBlobs), string(getBlobsBody))
|
||||||
|
|
||||||
getBlobResp, _ := http.Get(server.URL + "/blobs/test")
|
getBlobResp, _ := http.Get(server.URL + "/blobs/test")
|
||||||
getBlobBody, _ := ioutil.ReadAll(getBlobResp.Body)
|
getBlobBody, _ := ioutil.ReadAll(getBlobResp.Body)
|
||||||
|
require.Equal(t, 200, getBlobResp.StatusCode)
|
||||||
require.Equal(t, string(getBlob), string(getBlobBody))
|
require.Equal(t, string(getBlob), string(getBlobBody))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user