示例#1
0
文件: editor_test.go 项目: fxnn/gone
func TestCreateUIAlreadyExists(t *testing.T) {

	var response = httptest.NewRecorder()
	var request = getRequest(t, "/someFile?create")
	var store = mockstore.New()
	var sut = createSut(store)

	store.GivenWriteAccess()
	store.GivenMimeType("text/plain")
	sut.ServeHTTP(response, request)

	assertResponseBodyNotEmpty(t, response)
	assertResponseCode(t, response, http.StatusConflict)

}
示例#2
0
文件: editor_test.go 项目: fxnn/gone
func TestCreateUISuccess(t *testing.T) {

	var response = httptest.NewRecorder()
	var request = getRequest(t, "/someFile?create")
	var store = mockstore.New()
	var sut = createSut(store)

	store.GivenWriteAccess()
	store.GivenNotExists()
	sut.ServeHTTP(response, request)

	assertResponseBodyNotEmpty(t, response)
	assertResponseCode(t, response, http.StatusOK)

}
示例#3
0
文件: editor_test.go 项目: fxnn/gone
func TestEditUIMissingReadPermission(t *testing.T) {

	var response = httptest.NewRecorder()
	var request = getRequest(t, "/someFile?edit")
	var store = mockstore.New()
	var sut = createSut(store)

	store.GivenWriteAccess()
	store.GivenMimeType("text/plain")
	sut.ServeHTTP(response, request)

	assertResponseBodyNotEmpty(t, response)
	assertResponseCode(t, response, http.StatusUnauthorized)

}
示例#4
0
文件: editor_test.go 项目: fxnn/gone
func TestWriteSuccess(t *testing.T) {

	var response = httptest.NewRecorder()
	var request = postRequest(t, "/someFile", "")
	var store = mockstore.New()
	var sut = createSut(store)

	request.PostForm.Set("content", "content")
	store.GivenWriteAccess()
	sut.ServeHTTP(response, request)

	assertResponseBody(t, response, "")
	assertResponseCode(t, response, http.StatusFound)
	assertResponseHeader(t, response, "Location", "/someFile?edit")

}