Beispiel #1
0
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)

}
Beispiel #2
0
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)

}
Beispiel #3
0
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)

}
Beispiel #4
0
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")

}